Posts

Showing posts from July, 2011

How to send a UDP packet from inside linux kernel -

i'm modifying udp protocol such when connect() called on udp socket, in addition finding route, "hello" packet sent destination. from udp proto structure, figured out function ip4_datagram_connect job of finding route destination. @ end of function, need send hello packet. i don't think can use udp_sendmsg() it's used copying , sending data userspace. i think udp_send_skb() should used sent hello. problem don't know how create appropriate skbuff store hello message (it should proper udp datagram) passed on udp_send_skb() . i've tried this int quic_connect(struct sock *sk, struct flowi4 *fl4, struct rtable *rt){ struct sk_buff *skb; char *hello; int err = 0, exthdrlen, hh_len, datalen, trailerlen; char *data; hh_len = ll_reserved_space(rt->dst.dev); exthdrlen = rt->dst.header_len; trailerlen = rt->dst.trailer_len; datalen = 200; //create buffer send without fragmentation skb = sock_alloc_send_skb(sk, exthdrlen + datalen + h...

python - Changing the default ValueError of file.index -

i using file.index search string in file. def ifstringexistsinfile(self,path,linetextcheck): file = open(path).read() if file.index(linetextcheck): print (linetextcheck + " found in: " + path) else: raise valueerror (linetextcheck + " not found in: " + path) my issue if not find string, automatically raises default valueerror , not go "else" code contains custom valueerror: valueerror: substring not found is there way change default valueerror? currently, way came wrap sentence "try except", so: def ifstringexistsinfile(self,path,linetextcheck): file = open(path).read() try: if file.index(linetextcheck): print (linetextcheck + " found in: " + path) except: raise valueerror(linetextcheck + " not found in: " + path) any better way appreciated. thank in advance! any better way appreciated you solved how should solved. note ...

powershell - TFS - No default subscription has been designated. Use Select-AzureSubscription -Default <subscriptionName> to set the default subscription -

Image
i trying run task on tfs requires ad set up. managed set connections, reason subscription on tfs not selected. not sure account have log in, set default subscription. -default parameter deprecated btw. task add-on trying use downloadable here: https://marketplace.visualstudio.com/items?itemname=rbengtsson.appservices-start-stop&showreviewdialog=true tfs build error: i tried set via power-shell: i have tested azure appservices stop task on side, , found task works azure classic connection type, while used azure resource manager connection type, got same error message you. according source code of azure appservices stop task on github , task uses azure power shell below stop service: $website = get-azurewebsite -name $webappname stop-azurewebsite -name $webappname it seems stop-azurewebsite works azure classic, can't find in using azure powershell azure resource manager . in conclusion, if want use azure appservices stop task, need choose azure cl...

javascript - Auto scroll to Bottom -

i working on application chat screen. normal screen starts scrolling top bottom. should bottom top. application in telerik nativescript platform. view.xml <scrollview row="0" col="0"> <stacklayout class="history-content-area"> <repeater items="{{messagehistory}}"> <repeater.itemtemplate> <stacklayout> <!-- items go here --> </stacklayout> </repeater.itemtemplate> </repeater> </stacklayout> </scrollview> i need in above code how can scroll bottom automatically on page load ? let me know if need javascript code. thanks in advance. on scrollview can use scrolltoverticaloffset can pass offset scroll to. for example: view.xml <scrollview row="0" col="0" id="myscroller"> <stacklayout class="history-content-area...

matlab - Why dlmwrite eliminate colnames of matrix? -

im' new in matlab. have double matrix m this: 3.4452e-10 3.727e-10 5.3276e-11 5.4956e-11 -4.5277e-12 -1.5932e-10 9.5572e-11 -2.9293e-11 4.8192e-11 -7.5237e-11 -1.0847e-10 3.5613e-11 and gave name columane name data follow dataset({m, 'a','b'}) write folder using dlmwrite('mynewfile',m) but when open mynewfile, see column names of matrix eliminated. knows how can keep column names when write in directory? first, dataset deprecated, should use table instead. second, matlab documentation: dlmwrite(filename,m) writes numeric data in array m ascii format file so write contents of matrices not non-numeric data. you can use write first column headers in file , append data, or use matlab writing function handles text , numeric data

php - MySQL Random Result Group By Order By -

how random result on group by group_id? its similar this: random order group of rows in mysql here fiddle: http://sqlfiddle.com/#!9/1c73d/3 not sure why gives me same result. create table job (`job_id` int, `group_id` int, `user_id` int, `title` varchar(50), `description` varchar(55), `type` tinyint) ; insert job (`job_id`, `group_id`, `user_id`, `title`, `description`,`type`) values (1, 1, 100, 'title 1', 'text 1', 1), (2, 1, 100, 'title 2', 'text 2', 1), (3, 1, 200, 'title 3', 'text 3', 1), (4, 1, 200, 'title 4', 'text 4', 1), (5, 1, 300, 'title 5', 'text 5', 2), (6, 1, 400, 'title 6', 'text 6', 1), (7, 1, 200, 'title 7', 'text 7', 1); query: select * job type = 1 group group_id order rand() assuming want 1 random record each group under type = 1 : select * ( select * job type...

sum - SQL query command -

Image
i new sql , need find command in order generate report regarding table have: column1 tax amount 350 45 x 6500 53 y 800 25 z i need calculate x, y , z. need math: =if(column1 <= 5000, column1 + tax, column1) in words: need calculate x/y/z sum of column1+tax options: if column1 smaller or equal 5000 x = column1 + tax; if column1 > 5000 x or y or z should have column1 value result can me find sql query calculates x or y or z? select column1, tax, case when column1 <= 5000 column1 + tax else column1 end amount yourtable

java - How to call one controller method in another controller with RedirectAttributes -

code have written below. controller1 { @autowired controller2 controller2 //caller method void method1() { controller2.furnction1(model,redirectattributes); } } controller2 { public void function1(model model, redirectattributes atr){ } } question is: how intialize redirectattributes ( redirectattributes )in new controller( controller1 ). controller1 not form submit, couldn't redirectattributes default. how call funcation1 in controller2. redirect not work here. form data lost. try forwarding request url. try controller1 { @requestmapping("url1") public string method1() { return "forward:/url2"; } } controller2 { @requestmapping("/url2") public string function1(model model, redirectattributes atr){ //do } }

datetime - java 8 Instant.now() is showing wrong instant time -

in java 8 instant.now() method showing wrong time . code looks : import java.time.*; import java.time.temporal.*; public class datetimedemo{ public static void main(string []args){ instant = instant.now(); system.out.println(now); } } its date part correct time part . eg 2016-07-11t11:01:25.498z in system 4.31 pm i using asia/calcutta timezone that's correct time. note "z" @ end, indicating utc - 11:01:25 in utc 16:31:25 in asia/calcutta. if want represent "now" in default time zone, use zoneddatetime.now() instead.

go - Golang - Removing all Unicode newline characters from a string -

how remove unicode newlines utf-8 string in golang? found this answer php . you can use strings.map : func filternewlines(s string) string { return strings.map(func(r rune) rune { switch r { case 0x000a, 0x000b, 0x000c, 0x000d, 0x0085, 0x2028, 0x2029: return -1 default: return r } }, s) } playground

php - Set different targets for form with multiple submit buttons -

i have form contains wysiwyg editor, , 2 submit buttons : <input type='submit' name='pdf' value='pdf preview'/> <input type='submit' name='save' value='save'/> "pdf" action displays content of editor pdf output. "save" action regular form submit. want pdf output open in new tab, , can't figure how that. there no "target" attribute "input" tag. add "target=_blank" "form" tag, submit "save" action in new tab well, don't want. i tried replace "pdf" submit button : <a href="same_page" target="_blank" onclick="submitform();"> that didn't work. form submitted in current tab , new tab query receives nothing in $_post. is there magic trick don't know yet ? note : server-side code php use button , onclick event jquery. <button type='submit' name='pdf' oncl...

appium ios - FAILED: invokeApp org.openqa.selenium.SessionNotCreatedException: A new session could not be created -

import java.io.file; import java.net.malformedurlexception; import java.net.url; import org.openqa.selenium.remote.desiredcapabilities; import org.testng.annotations.test; import io.appium.java_client.android.androiddriver; public class demo { androiddriver driver =null; desiredcapabilities capabilities; file app = new file("/data/app/com.philips.sleepmapper.root-1/base.apk"); @test public void invokeapp() throws malformedurlexception { capabilities = new desiredcapabilities(); capabilities.setcapability("automationname", "appium"); capabilities.setcapability("paltformname", "android"); capabilities.setcapability("platformversion", "6.0.1"); capabilities.setcapability("devicenmae", "galaxy s6"); capabilities.setcapability("app", app.getabsolutepath()); capabilities.setcapability("apppackage","com.philips.sleepmapper.root"); c...

sql - PostgreSQL WHERE IN LIKE query -

i wondering if it's possible query using in clause options inside clauses, example have existing sql returns same results intend seems round way it. select * pg_stat_activity application_name not '%psql%' , (current_timestamp - state_change) > interval '30 minutes' , state in ( select state pg_stat_activity state '%idle%' or state '%disabled%' ) is there way replace along lines of select * pg_stat_activity application_name not '%psql%' , (current_timestamp - state_change) > interval '30 minutes' , state in ('%idle%', '%disabled%') use similar to instead of like and state similar '%(idle|disabled)%' https://www.postgresql.org/docs/9.0/static/functions-matching.html

twitter - Crontab and perl -

i have issue perl script , cpan twitter module. i have script runs speedtest, , trying post result twitter. i have managed script running manually running ./speedtest.pl user account, when try , run using crontab error. i have installed net::twitter , file::homedir , config::tiny using cpanm net::twitter etc. (note: no sudo) following error when run script local crontab:- can't locate net/twitter.pm in @inc (you may need install net::twitter module) (@inc contains: /etc/perl /usr/local/lib/arm-linux- gnueabihf/perl/5.20.2 /usr/local/share/perl/5.20.2 /usr/lib/arm-linux- gnueabihf/perl5/5.20 /usr/share/perl5 /usr/lib/arm-linux-gnueabihf /perl/5.20 /usr/share/perl/5.20 /usr/local/lib/site_perl .) @ /home/pi /speedtest.pl line 99. begin failed--compilation aborted @ /home/pi/speedtest.pl line 99. can please point me in right direction? suspect has net::twitter etc ended i've no idea how fix crontab knows find it. speedtest.pl here the perl insta...

php - Unexpected space at the begining of file -

for php courses have create note pad start sample text, when edit , click on save button, text inside file edited , saved. if refresh page / open file directly have new content edited user displayed. it works, have unexpected space in file. if put @ first character on first line "sample text", i'll not see "sample text" instead: sample text and that's first line, ever if edited file manually or page. next lines start @ first characters. below notes.txt file (where notes are) after edit web page: mes jeux préférés:&#13;&#10; =&#62; fallout 3&#13;&#10; =&#62; natural selection 2&#13;&#10; =&#6 2; l4d2 i don't see strange character in @ beginning of file. index.php: <?php define('fichier_de_notes', 'notes.txt'); $fichier = fopen(fichier_de_notes, 'r+'); if (array_key_exists('note', $_post)) { $note = filter_var($_post['note'], fil...

ruby on rails - Hash Table Column Values as Integer -

i have followed this tutorial have hash column on model works great. when work out codes in rails console , becomes different within controller code. in console: foo.update_attributes(bar: {"a" => 1, "b" => 2}) my values shown integer, in console. in controller, if i'm doing calculations, have add .to_i or .to_f , becomes messy. values forever number. can simple add int or float column? add_column :foos, :bar, :hstore, :integer, default: {}, null: false the above not work. you can use hook on model: before_save -> r { r.bar.each{|k, v| r.bar[k] = v.to_i} }

ios - How to fix memory leak in AFNetworking 3.1? -

i'm testing app in instruments below code getting memory leak. please tell me how fix it. nsurlsessionconfiguration *configuration = [nsurlsessionconfiguration defaultsessionconfiguration]; afhttpsessionmanager *manager = [[afhttpsessionmanager alloc]initwithsessionconfiguration:configuration]; you can try code: static dispatch_once_t oncetoken; dispatch_once(&oncetoken, ^{ nsurlsessionconfiguration *sessionconfiguration = [nsurlsessionconfiguration defaultsessionconfiguration]; sessionconfiguration.httpmaximumconnectionsperhost = 10; self.manager = [[afurlsessionmanager alloc] initwithsessionconfiguration:sessionconfiguration]; });

Reading iOS app requests via ssl proxy -

i'm trying use charles/burb suite read request responses sent ios app server. requests sent via ssl i've enabled ssl proxy , installed cert on iphone. seems work fine. request response , post still unreadable. note response headers readable not actual message. is there way make response readable or result of ssl pinning? 1) have add ios device certificate (which have done). 2) need add locations sll proxying table. from menu: proxy--->ssl proxy settings...--->ssl proxying click add. in host box, put site name translate (use wildcards if needed). example: *.mysite.com leave port blank. click ok. make sure enable ssl proxying checked, , host filter checked. click ok. restart charles.

jquery - Pre populating Select2 using AJAX - "No Results Found" -

i've been following sample guide ( http://rails-select2-example.herokuapp.com/ ) create select2 drop down search countries database. however select box comes empty "no results found". why wont pick values js/ajax? view (new.html.erb) <select class="form-control" id="country_select"> </select> controller (searches_controller.rb) class searchescontroller < applicationcontroller before_action :require_user respond_to :html, :json def new @countries = country.all respond_with @countries end end javascript $('#country_select').select2({ theme: "bootstrap", ajax: { url: "<%= user_searches_path(format: 'json') %>", datatype: "json", results: function(data, page) { return { results: $.map( data, function(country, i) { return { id: country.id, text: country.name } } ) } } ...

Does anyone know how to bcc in R? -

library("mailr") sender <- "sender@gmail.com" bcc<- c("bcc recipient <bcc1@gmail.com.tr>","bcc recipient<bcc2@gmail.com.tr>") send.mail(from = sender, bcc<- c("bcc recipient <bcc1@gmail.com.tr>","bcc recipient<bcc2@gmail.com.tr>"), subject = "subject", body = "body ", authenticate=true, smtp = list(host.name = "smtp.gmail.com", port = 465, user.name = "yourusername@gmail.com", passwd = "yourpassword", ssl = true), send = true, attach.files = c("c:/users/admin/desktop/forecast.csv"), file.names = c("demand_forecast.csv")) do u know how send mail bcc, format?it working recipents can see eachother you have mistak...

c# - Drawing a rectangle annotation with PDFTron (PdfNet) -

i'm trying user create rectangle in pdf. user can drag rectangle on screen. on mouseup event, rect object created , passed method addrectannotationtopage(rectangle rect) the problem rectangle annotation differs rect user dragged. when user clicks or scrolls, annotation rectangle gets it's correct size (equal dragged rect passed argument) why not take it's correct size immediately? , why resizes correct size whenever click on random spot in pdf? private void addrectannotationtopage(rectangle rect) { if (rect != null) { if (this.m_pagenumber < 0) { m_pagenumber = this.getcurrentpage(); } _cur_page = this.m_pagenumber; if (_cur_page < 0) { return; } double width = rect.width; double height = rect.height; double startx = rect.left; double starty = rect.bottom; ...

android - Sinch instant messaging: synchronising messages across devices with differing clocks -

using sinch instant messaging android , how sync messages appear in correct order, if 2 devices have different clocks? when read the docs message#gettimestamp() , state "returns server side timestamp of message", seems promising. did not work, though: in practice, appears onmessagesent() called local time while onincomingmessage() called server time. imagine device 1 , device 2 have different clocks , chatting eachother, , device1 ahead of device2. example, device1 has 7:15 while device2 has 7:00. server time 7:00. these findings: device1 sends "first message!" device1: onmessagesent() triggered. m.gettimestamp() returns 7:15 (the local time device1) device2: onincomingmessage() triggered. m.gettimestamp() returns 7:00 (the server time, , local time device2) shouldn't gettimestamp() return server-side time? missing something?

Error when I compile an example from Contiki -

when run command on contiki sudo make target=srf06-cc26xx board=sensortag/cc2650 cc26xx-demo.bin cpu_family=cc26xx it returns following error: cc ../../platform/srf06-cc26xx/./contiki-main.c make: arm-none-eabi-gcc: command not found make: *** [obj_srf06-cc26xx/contiki-main.o] error 127 to run make, if contiki repo in directory permissions user don't need run sudo. install arm-none-eabi-gcc package, run: sudo apt-get install arm-none-eabi-gcc after having installed, can check version have installed: arm-none-eabi-gcc --version and output should (this ubuntu 16.04): arm-none-eabi-gcc (15:4.9.3+svn231177-1) 4.9.3 20150529 (prerelease) copyright (c) 2014 free software foundation, inc. free software; see source copying conditions. there no warranty; not merchantability or fitness particular purpose. i hope helps! br, virginia

android - After macOS Sierra Update, Eject USB trigger hard-reset -

i'm using android studio , samsung galaxy s4. after updated macos sierra devpreview version. when eject phone usb connection, retina macbook pro mid2015 freeze , not response. (two times encountered this) need enforce hard-reset keyboard hold power key. after restart gives me below error. what mean? need to. informed bug report. tue jun 28 12:53:54 2016 *** panic report *** panic(cpu 4 caller 0xffffff8002cb260e): preemption level underflow, possible cause unlocking unlocked mutex or spinlock backtrace (cpu 4), frame : return address 0xffffff9238053c00 : 0xffffff8002d0475c 0xffffff9238053c80 : 0xffffff8002cb260e 0xffffff9238053c90 : 0xffffff8002cb232f 0xffffff9238053ca0 : 0xffffff800329473b 0xffffff9238053cf0 : 0xffffff80032957a0 0xffffff9238053d40 : 0xffffff80032ed07e 0xffffff9238053db0 : 0xffffff8002dce792 0xffffff9238053e00 : 0xffffff8002d092e9 0xffffff9238053e40 : 0xffffff8002ce6eb1 0xffffff9238053e90 : 0xffffff8002cfaca1 0xffffff9238053f10 : 0xffffff8002dfa3b9 0xffffff...

Way to fast change color for group of clusters in Gephi -

after running cluster algorithm prefer set colors of own choice. , want highlight important clusters. in partitionig -> nodes -> clustering (chinese whispers) convenient option "all blacks". i'm using black background. maybe knows change (in config files or that, don't know exactly) nodes become whites after pressing "all blacks"? or maybe know better way group them , set color. using filter portion -> clustering (chinese whispers) -> set clusters -> go data lab -> create column color , set white. not convenient. thank you! you can use partition tab in gephi. check slides here p. 38-40. can modify colours each partition right-clicking on each partition color

php 5.6 - PHP setcookie not working despite headers looking right -

i handling post request, setting cookie , redirecting user so: // (handle post request) // fine set cookie $ciphertext = crypto::encrypt($_post['soulmates_member_id'], key::loadfromasciisafestring($this->encryption_key)); $expires = 60 * 60 * 24 * 30; setcookie('soulmates_member_id', $ciphertext, $expires, '/', $_server['http_host']); // redirect header("location: ".$_post['soulmates_redirect']); the following response returned: http/1.1 302 found date: tue, 28 jun 2016 10:53:21 gmt server: apache/2.4.17 (win32) openssl/1.0.2d php/5.6.21 x-powered-by: php/5.6.21 expires: wed, 11 jan 1984 05:00:00 gmt cache-control: no-cache, must-revalidate, max-age=0 pragma: no-cache access-control-allow-origin: http://local.wordpress.com access-control-allow-credentials: true x-robots-tag: noindex x-content-type-options: nosniff x-frame-options: sameorigin set-cookie: soulmates_member_id=def5020032ce3903334d3564b22303993dc3bd59232566322...

executing commands in own shell - C -

i have troubles creating own shell in c. here code have far #include "interpreter.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/wait.h> #include <syslog.h> void readconfig(int *timeout, char *file){ file * fp; char * line = null; size_t len = 0; char * token; fp = fopen(config, "r"); if (fp == null) { *timeout = defaulttime; } else { while ((getline(&line, &len, fp)) != -1){ token = strtok(line, token); if ((strcmp(token,time_period) == 0)){ *timeout = atoi(strtok(null, token)); } if ((strcmp(token,history)==0)){ strcpy(file,trim_command(strtok(null, token))); } } } } int waitperiod(pid_t pid){ if(pid) { int stat_val; pid_t child_pid; int time = 0; while(time < time_per...

excel - Error while reading CSV with VBA -

i'm trying read csv vba. when following this tutorial , following code: sub opentextfile() dim filepath string filepath = "c:\path\to\file\mycsv.csv" open filepath input #1 row_number = 0 until eof(1) line input #1, linefromfile lineitems = split(linefromline, ",") activecell.offset(row_number, 0).value = lineitems(2) activecell.offset(row_number, 1).value = lineitems(1) activecell.offset(row_number, 2).value = lineitems(0) row_number = row_number + 1 loop close #1 end sub this csv: peter,paris,23 mary,london,34 steve,rome,56 lily,madrid,65 when executing code, error: index out of range and line marked yellow: activecell.offset(row_number, 0).value = lineitems(2) you have typo: lineitems = split(linefromline, ",") should lineitems = split(linefromfile, ",") this not have happened if used option explicit @ beginning of module ;)

c# - TreeView tab navigation -

i have usercontrol grid contain simple treeview. i'm able navigate in forward direction (tab) while in backwards direction (alt+tab) not working. (it's focus last button in item template). have suggestions? <treeview itemssource="{binding mylist}" keyboardnavigation.tabnavigation="continue" tabindex="4" istabstop="false"> <treeview.itemcontainerstyle> <style targettype="{x:type treeviewitem}"> <setter property="isexpanded" value="true" /> <setter property="keyboardnavigation.tabnavigation" value="continue"/> </style> </treeview.itemcontainerstyle> <treeview.itemtemplate> <hierarchicaldatatemplate itemssource="{binding mysublist}"> <textblock text="{binding name}" fontweight="bold"/> <hierarchicaldatatemplate.itemtemplate> ...

Bukkit Player removeResourcePack? -

i know how send specific resourcepack player on server. work multiple small minigames servers , 1 of minigames needs resourcepack send resourcepack function: p.setresourcepack("url"); but if player sent lobby-server, resourcepack not removed automatically. i'd remove resourcepack because if player plays game might confused special textures. tryed send "null" resourcepack p.setresourcepack(null); but throws exception. http://hastebin.com/gojuqesafa.profile so know solution sending him default-resourcepack? i think best way set players resource pack default, this: first of all, create new folder called default (or whatever). then go .minecraft/versions open folder version of minecraft plugin supports, open jar file program winrar, , copy assets folder default texture pack folder created. create file called pack.mcmeta these contents: { "pack": { "pack_format": 1, "description": "default te...

It is possible to remove user message from Facebook Bot chat? -

i need feature remove user input message conversation facebook bot. i need make authorization routine server application, because working private user information. therefore want make prompt of user password , of course must removed chat or replaced ******. how handle kind of scenario via facebook bot chat ? if impossible, can suggest me workaround problem ? many thanks i tried find way delete message / conversation facebook bot chat via facebook apis not able find way or specific api delete message / conversation. however particular scenario facebook has given way authenticate user our own system with. https://developers.facebook.com/docs/messenger-platform/account-linking so use authenticate user system login process , unauthenticated logout process. hope helps others has similar thoughts.

php - Display related data from database based on dropdown selection JavaScript -

in task want select 1 name drop down. want print technology related name in other div tag. don't know how this. data data base dropdown option. here code. candidate name: <select name="candidate_id" class="form-control" id="can_name" value="<?php echo set_value('candidate_id');?>"palceholder="candidate full name" required> <option></option> <?php foreach ($candidate $r): ?> <option value="<?php echo $r->candidate_id; ?>"><?php echo $r->candidate_name." "; ?></option> <?php endforeach; ?> </select> </select> <div class="error"><?php echo form_error("candidate_name");?></div><br> <div></div><br> <!-- here want print technology related canididate name --> let's use jquery library, simplify syntax of want considerably. you i...

Javascript - setHours() for cookie not working -

i creating cookie expires @ 4 pm each day. have sethours() function supposed set cookie's expiration time 16:00:00 pm instead sets hours 12:00:00 pm . tell me why doing this? code used below: var date = new date(); var expire = new date(); // check if time before midnight after blackout if (date.gethours() >= 16 && date.gethours() <= 23) { expire.setfullyear(date.getfullyear()); expire.setmonth(date.getmonth()); expire.setdate(date.getdate()+1); expire.sethours(16); expire.setminutes(0); } // check if time after midnight before blackout else if (date.gethours() >= 0 && date.gethours() < 11) { expire.setfullyear(date.getfullyear()); expire.setmonth(date.getmonth()); expire.setdate(date.getdate()); expire.sethours(16); expire.setminutes(0); } // create disabled order cookie document.cookie = "orderdisabled=true; expires=" + expire.tostring() +"; path=/"; console.log(expire.tostring()); ...

php - Laravel Excel: how to get value of a cell? -

i've loaded .xls file laravel excel : excel::load('public/files/20160621.xls', function($reader) { // read cell value }); how read values of cells of loaded excel file? documentation seems unclear on part. public function get() { $excelfile ... return excel::load($excelfile, function($doc) { $sheet = $doc->getsheetbyname('data'); // sheet name data, can use sheet indexes. $sheet->getcell('a1'); $sheet->getcellbycolumnandrow(0,0); }); } you're right, documentation read cells unclear. hope you.

php - How to connect php7 with mongoDB -

i'm trying connect php 7 mongodb, installed "new" mongodb driver using pecl following page instructions. can see mongodb version 1.1.8 phpinfo() output, can't figure out how initiate connection php code :p . following code includes attempts connect (tried connect using old fashion way) // new fashion way $connection = new mongodb\driver\client(); // or using old fashion way $conn = new mongoclient(); // random try :p $randconn = new mongodb\client(); and in both cases, i'm getting not defined class exception. please let me know i'm missing , mistake, please provide , example easier follow if possible ;) . ps: used operating system ubuntu 14.04 lts. thanks in advance. the page referring low-level php driver mongodb. api same hhvm driver mongodb . documentation both of them same, , can found @ http://docs.php.net/manual/en/set.mongodb.php the driver written bare bone layer talk mongodb, , therefore misses many convenience features. i...

android - Properly tracking install referrals on Play Store -

i have simple task: want track referral id of app install , pass backend. what did: created link parameter referrer , appended invite link. when opened, javascript detects if browser android mobile browser , prepares intent , issues redirect intent. while preparing intent, referrer field extracted url , appended intent this: intent://scan/#intent;scheme=com.example.android;package=com.example.android&referrer=4;end and here code broadcastreceiver : public class installreferrerreceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { tinydb tinydb = new tinydb(context); string referrer = intent.getstringextra("referrer"); tinydb.putstring(appconstants.referral_id, referrer); tinydb.putboolean(appconstants.referral_sent, false); } } so, expect here value of referrer 4 based on above intent . value getting string utm_source=google-play&utm_medium=organic what...

How to add +91 before mobile number in edit text in android? -

i have activity contain edit text in want add +91 before mobile number ,right problem when start entering mobile number 9888888 when enter 9 +91 visible , after 888888.it skip 9 first time...how can resolve issue. code:- textwatcher m_mobilewatcher = new textwatcher() { @override public void beforetextchanged(charsequence s, int start, int count, int after) { } @override public void ontextchanged(charsequence s, int start, int before, int count) { } @override public void aftertextchanged(editable s) { if (!s.tostring().contains("+91")) { m_inputmobie.settext("+91"); selection.setselection(m_inputmobie.gettext(), m_inputmobie.gettext().length()); } } }; m_inputmobie = (edittext) m_main.findviewbyid(r.id.input_number); m_inputmobie.addtextchangedlistener(m_mobilewatcher); you missing line m_inputmobie.settext("+91" + s.tostring()); you have add character ...

sql server - SQL Azure CONTAINS not returning all results -

Image
we added free text search on following table: | 1 | kayer-meyar | | 2 | ka-me | but, select * names contains(name, '"me*"') returns only: | 1 | kayer-meyar | while, select * names contains(name, '"ka*"') returns both: | 1 | kayer-meyar | | 2 | ka-me | when run: select * sys.dm_fts_parser('"ka-me"', 1033, null, 0) returns: ka-me ka me after searching , tuning problem have found 2 major fault in full-text searching: the hyphen might treated word break . return | 1 | kayer-meyar | when use '"me*"' . doesn't return | 2 | ka-me | . problem because condition allow word start (not end with or in middle ) me + @ least 1 character . you can say , "then how come return | 1 | kayer-meyar | string me in middle of word ?" . because fulltext serach not consider silgle word, consider 2 seperate word(something kayer meyar ) fullfill requrement( me* ). again in ca...

osx - Updating the Perm Gen Memory Jenkins - MacOSX -

i trying update perm gen memory in jenkins, have read adding org.jenkins.plist file trick not changing me: <key>-xx:permsize</key> <string>512m</string> <key>-xx:maxpermsize</key> <string>1024m</string> when use jenkins monitoring tool still tells me that: perm gen memory: 81mb am doing wrong? thanks according http://mgrebenets.github.io/mobile%20ci/2015/02/01/jenkins-ci-server-on-osx , should using <string> not <key> , eg: <string>-xx:maxpermsize=1024m</string> <key> denotes section. in case, setting program arguments fall under <key>programarguments</key> section. specified key sections confusing launcher. @ link complete example , compare yours. abridged example: <plist version="1.0"> <dict> <key>label</key> <string>homebrew.mxcl.jenkins</string> <key>programarguments</key> <array> ....

php - How to put in a <select> categories and Subcategories from a DB? -

i want http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_optgroup have main categories , subcategories in db, , don't know how manage in while cycle. how can ? cycle that, because of necessities can't use anymore <select class="form-control" id="subcategory" name="subcategory" required> <?php $categories="select name,category subcategory order category asc, name asc;"; $query_categories=mysqli_query($connh,$categories); while($rows_categories=mysqli_fetch_array($query_categories)){ echo'<option>'.$rows_categories['category'].'/'.$rows_categories['name'].'</option>'; } ?> </select> p.s: category main category, name subcategory i want have main category <optgroup> because of 1 category contains more 1 subcategory, don't know how place <optgroup> in way...

java - Append TextView of another activity through main -

i'm trying create game log, show happened on each round of game. log in activity want updated whatever player does. player presses buttons things. it's code post, have made new bundle, , intent. in mainactivity. bundle bundle = new bundle(); intent gamelogswitch = new intent(getapplicationcontext(),gamelog.class); i trying put send other activity don't know if can put variables in it. otherwise works simple words such ("key","it works") gamelogswitch.putextra("break","---break---"+"\n"+player1name+": "+greenresult.gettext()+"("+grtop1+","+grtop2+","+grtop3+")"+"\n"+player2name+": "+redresult.gettext()+"("+rdtop1+","+rdtop2+","+rdtop3+")"); and of course have when gamelog button pressed startactivity(gamelogswitch); now in gamelog.class have this. package com.example.adam.snookerproject; import an...

module - How to add checkbox into manufacturers in Magento? -

i've changed way how brands displayed in menu (logos/images instead of text/names). there problem can't solve. how add field (show/hide) manufacturers(brands) table ? or table contain manufacturers (can't locate it) . in meantime testing solutions ... not work ;( tried add field eav_attributes, based on value 0/1 show or hide brand in list of favourites :) any ideas ? here how or achieve: "checkbox" not "radio". module let me display favourite brands inside dropdown menu in order: favourite brands/products first non favourite (limited 10 in dropdown "see more" ... if required :)). checkbox used select these brands (if checked shown "favourite brand/product"). (images presents products checkbox work brands in menu "brands" - now) my menu - example 1 my menu - example 2 displays products none of products "in promotion/featured" because can't select them yet. so that's plan ;) do need ch...

PHP class variable not assigned -

i having strange issue php code. php version using php 5.3.2-1ubuntu4.30 suhosin-patch . the issue having cannot assign variable part of class namespace stats\potsportstats; use pdo; use stats\port; use stats\potsportstats\iphosts\iphosts; class portstats extends port { public $vcportonhookstatus; public $vcportimpedance; public $iphosts; /** * @param $secretvalue int * @param $pdo_conn pdo * @return portstats[] */ public static function getall($secretvalue, $pdo_conn){ try { $query = "select * secrettable secretcolumn = :secretvalue"; $pdo_stmt = $pdo_conn->prepare($query); $pdo_stmt->bindvalue(":secretvalue", $secretvalue, pdo::param_int); $pdo_stmt->execute(); /** @var portstats $result */ //this works right $result = $pdo_stmt->fetchall(pdo::fetch_class, __class__); //other assigned array o...

loops - Tag Names As Variables And Displaying It In Matlab GUI -

i’m building gui in matlab (my first one), have 160 static text boxes tag name “tag_matrix_1, tag_matrix_2, etc”. i’m trying build loop puts tag names in vector: for = 1:160 tagnames(i) = ['tag_matrix_' num2str(i)]; end but i’ll error: “in assignment a(i) = b, number of elements in b , must same.” why? , how fix it? my second question displaying in loop. possible loop it, don’t have 160 lines of setting static text boxes? like: for = 1:160 set(handles."how can implement tagnames(i) in there",'string',data2d(i,:); end rather trying store tag names in array (this fail because different sizes), create struct fieldname tag name , value handle itself. can use dynamic field referencing this. for k = 1:160 field = ['tag_matrix_', num2str(k)]; myhandles.(field) = findobj(gcf, 'tag', field); end then in second loop (to fill in values), you'd access fields of struct. for k = 1:160 set(myhandles.(['tag_matrix...

node.js - Mockgoose: how to simulate a error in mongoose? -

i trying unit test around mongoose powered application. while mockgoose great work @ simulating mongoose can test around it, didn t find way push fail call, can test error handling logic. is supported use case? or should find framework? code: var mongoose = require('mongoose'); var test = {}, doc = require('./model/doc.js'); var dburl = 'mongodb://127.0.0.1/', dbname = 'test'; function connect(callback) { test = mongoose.createconnection(dburl + dbname); //<-- push fail test.on('error', (err) => { callback(err); }); test.once('open', function () { callback(); }); } test: var chai = require('chai'), expect = chai.expect, util = require('util'); var config = require('./config.json'); var proxyquire = require('proxyquire').nopreservecache(); var sinon = require('sinon'); var mongoose = require('mongoose'); var mockgo...

Count of group by in CodeIgniter -

i wan display first 9 places have highest number of reservations. must have count of $this->db->group_by('t.id_pl') , order of counted number. i've managed don't understand should put count : function select_pop () { $this->db->select( 's.place place, s.price price, s.title title' ); $this->db->from('places s'); $this->db->join('reservations t', 't.id_pl= s.place', 'inner'); $this->db->group_by('t.id_pl'); $this->db->order_by(''); $this->db->limit(9); $result = $this->db->get(); return $result; } any suggestions? you can add count in select statement below- $this->db->select('count(t.id_pl) reservation_count,s.place place, s.price price, s.title title'); then order can use like- $this->db->order_by('reservation_count','desc'); i hope you..

methods - Is Java "pass-by-reference" or "pass-by-value"? -

i thought java pass-by-reference ; i've seen couple of blog posts (for example, this blog ) claim it's not. don't think understand distinction they're making. what explanation? java pass-by-value . unfortunately, decided call location of object "reference". when pass value of object, passing reference it. confusing beginners. it goes this: public static void main( string[] args ) { dog adog = new dog("max"); // pass object foo foo(adog); // adog variable still pointing "max" dog when foo(...) returns adog.getname().equals("max"); // true, java passes value adog.getname().equals("fifi"); // false } public static void foo(dog d) { d.getname().equals("max"); // true // change d inside of foo() point new dog instance "fifi" d = new dog("fifi"); d.getname().equals("fifi"); // true } in example adog.getname() still retur...

java - How to Subtract number of days from current date in HQL query -

i using hql data inserted exact 21 days now. here code query querythreeweek = session.createquery("from users createddate = curdate()-21"); list<users> userdetailsthreeweeklist = querythreeweek.list(); i can not use createsqlquery . right not getting data, there data date 2016-06-20 . , because of month changed because when used curdate()-7 got correct data of date 2016-07-04 . calculation dat like; 2016-07-11 - 7 = 20160704 2016-07-11 - 21 = 20160690 i tired using interval native sqlquery . here code using interval in hql: query querythreeweek = session.createquery("from users createddate = date( date_sub( now() , interval 21 day ) )"); list<users> userdetailsthreeweeklist = querythreeweek.list(); also tried query querythreeweek = session.createquery("from users createddate = date( date_sub( curdate() , interval 21 day ) )"); list<users> userdetailsthreeweeklist = querythreeweek.list(); but giving me exception lik...