Posts

Showing posts from May, 2011

Flatten Tree Structure Output html List (php) -

Image
i have ordered tree (the nodes in correct order output). each node has name, depth , parent_id properties. trying output nested list can visually see structure. having bit of trouble coming right. best way fix this? need change data structure and/or logic? here data: array(24) { [5]=> array(3) { ["depth"]=> int(0) ["name"]=> string(16) "basketball sport" ["parent_id"]=> null } [3]=> array(3) { ["depth"]=> int(1) ["name"]=> string(16) "basketball shoes" ["parent_id"]=> string(1) "5" } [2]=> array(3) { ["depth"]=> int(2) ["name"]=> string(6) "jordon" ["parent_id"]=> string(1) "3" } [4]=> array(3) { ["depth"]=> int(2) ["name"]=> string(6) "lebron" ["par

c# - How to Host Portable Class Library Class Instance in ViewState -

i have asp.net web-forms application 2 projects: main web project , portable class library project . have following code: in portable project have item class: public class item { public int id { get; set; } public string name { get; set; } } and in default.aspx.cs page have following demo code: protected void page_load(object sender, eventargs e) { item item = new item(); item.id = 1; item.name = "john"; viewstate["mykey"] = item; } protected void button1_click(object sender, eventargs e) // have button named "button1" on page. { if (viewstate["mykey"] != null) { item item = (item)viewstate["mykey"]; button1.text = item.id + " " + item.name; } } obviously causing error: type 'portableproject.item' in assembly 'portableproject, version=1.0.0.0, culture=neutral, publickeytoken=null' not marked serializable while i'm aware of prob

c++ - libvlc_video_set_subtitle_file not working -

i'm using following code set subtitle file, reason it's not working. qstring selectedfile = qfiledialog::getopenfilename(this, "open"); if(selectedfile == null) { return; } qdebug("before %d %d", libvlc_video_get_spu(player), libvlc_video_get_spu_count(player)); //int = libvlc_video_set_subtitle_file(player, selectedfile.tostdstring().c_str()); int = libvlc_video_set_subtitle_file(player, selectedfile.tolatin1().data()); qdebug("a = %d",a); qdebug("after %d %d", libvlc_video_get_spu(player), libvlc_video_get_spu_count(player)); subtitle index , count same before , after setting specific file, , function returns 1 (int a). however, setting subtitle libvlc_video_set_spu works. i'm using vlc 2.2.1 if on windows, qdir::tonativeseparators help: const qstring selectedfile = qfiledialog::getopenfilename(this, "open"); const qstring nativepath = qdir::tonativeseparators(selectedfile); libvlc_video_s

svg groups and fill inheritance -

my goal have first group of 3 squares blue , next group of 3 squares red. minimize code, want take advantage of grouping in svg. rectangles remain blue. have tried inline styling on second group element , on use element, doesn't solve problem. thank assistance.. here's code: <svg width="1000" height="800" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink"> <style> .blue {fill:blue;} .red {fill:red;} </style> <g id="g1" class="blue"> <rect x="0" y="0" width="100" height="100" /> <rect x="0" y="105" width="100" height="100" /> <rect x="0" y="210" width="100" height="100" /> </g> <g class="red"> <use xlink:href="#g1" transform="translate(0,315)"

jquery - Horizontal to off-canvas nav with splash screen, absolute positioning conflicts -

Image
i'm working on same site previous question (and i'm css3 noob). site i'm working on has horizontal navigation menu switches off canvas menu. i'm turning classes on , off jquery , it's looking pretty good. html divided 2 divs, #drawer , #site-canvas. simplified, html looks this <body> <nav id="drawer"> //ul menu stuff </nav> <div id="site-canvas"> <header> // header mobile version </header> <div class="splash">//splash screen<div> <div id="site-content">//lorem ipsum<div> </div> <!--end #site-canvas--> </body> it's going feature splash screen image take 100% of viewport , stay centered. /* splash page */ .splash { background: url('//image') center center; background-size: cover; min-height: 100%; } so far good, in desktop styles (1000px+ width) have conflict nav div being outside site canvas causin

how can i use angularjs iterate a json string -

i have json string : {"age":[459,918],"id":["bizno459","bizno459"],"name":["name459","wrongname459"]} now want show using angular js : <table> <tr> <th>column</th> <th>value1</th> <th>value2<th> </tr> <tr> <td>age</td> <td>459</td> <td>918</td> </tr> <tr> <td>id</td> <td>bizno459</td> <td>bizno459</td> </tr> </table> the column dynamic, in example, there 3 : age, id, name. in example, have 2 columns: id,name. how achieve this? you can use json.parse convert json string object. after can use ng-repeat iterate on keys, , on each value every key: function tablectrl($scope){ var jsonstring = '{"age":[459,918],"id":["bizno459","bizno459"],"name

SQL Server Get Updated Column Value -

i have col1 in table initial value of 0 1 row, want updated value of col1. my update query : update table set col1 = col1 + 1 i can last update put output : update table set col1 = col1 + 1 output inserted.col1 but not sure output value related same query or last updated other query @ same time. the value returned value of update statement. not reflect updates made other users. edit: you can store value in variable without output clause ( https://msdn.microsoft.com/en-us/library/ms177523.aspx ): update table set @col1 = col1 = col1 + 1;

php - Cross Database Joins Doctrine -

i have 2 connection in doctrine zf2, need make join in twoo databases. big question is: possible perform join on 2 tables in different databases , connections? 'connection' => array( // default db connection 'orm_default' => array( 'driverclass' => 'doctrine\dbal\driver\pdomysql\driver', 'params' => array( 'host' => 'localhost', 'user' => 'root', 'port' => '3306', 'password' => '', 'dbname' => 'mysql_test', 'driveroptions' => array( pdo::mysql_attr_init_command => "set names 'utf8'" ) ), ), // alternative db connection 'orm_alternati

r - Error in clusplot function -

i playing cluster analysis in r , plot cluster: teste<-data.frame(v1=rnorm(100),v2=rexp(100),v3=runif(100) ) fit.c<- kmeans(teste,2) aggregate(teste,by=list(fit.c$cluster),fun=mean) clusplot(teste, fit.c$cluster, color=true, shade=true,labels=2, lines=0) but gives me error: error in clusplot.default(teste, fit.c$cluster, color = true, shade = true, : 4 arguments passed .internal(nchar) requires 3 does know happening? thank you i ran code , got no problems. guessing there version mismatch between r , packages using. can make sure cluster package date (and other packages using matter), and/or update latest version of r? if doesn't work, can add sessioninfo() information? helpful diagnosing these sorts of problems.

Swift optional property using KVC causes crash -

i found using kvc in swift causes many problems, optional properties. here specific problem: here class named person . has normal property called age ,and optional(int) property called ageoptional . class person: nsobject { var age: int var ageoptional: int? override init(age: int){ self.age = 0 } } now, use kvc in person's instance: //new instance var person = person() //kvc normal property: work person.setvalue(28, forkeypath: "age") //but, time ,it doesn't work well!!!! person.setvalue(28, forkeypath: "ageoptional") the app crashes, , here exception: 2015-07-11 11:17:31.546 cfruntime[4646:607] *** terminating app due uncaught exception 'nsunknownkeyexception', reason: '[ setvalue:forundefinedkey:]: class not key value coding-compliant key ageoptional.' i found that, if property optional, kvc couldn't find key. but,i can't find useful key optional property ,and resolve s

containers - docker run with -p and a single port (instead of mapping) -

what different between following commands when creating container in docker? docker run -d -p 8080 sample/image and docker run -d -p 8080:8080 sample/image i have seen majority of them use second command, not sure if mean different things, or if first shorthand. i couldn't find material on this. docker run -d -p 8080 sample/image exposes port 8080 of container arbitrary port on host. port is docker. whereas, docker run -d -p 8080:8080 sample/image exposes port 8080 of container port 8080 on host. in both cases, can see mapping using docker inspect , or docker ps : 380af8c2bcc6 ubuntu "bash" 15 seconds ago 13 seconds 0.0.0.0:32768->1234/tcp elegant_meitner in case, port 1234 of container exposed port 32768 on host.

user interface - Need sample AXML for Android Card content blocks -

android has list of ux/ui samples here , i'm looking example axaml layouts match ux/ui illustrations. does such layout library exist? prefer copy , paste ui code, since isn't expertise. i not know of direct 1 one library google's design spec platforms google runs vs. actual implementation on specific device/browser (android being one). you tagged question xamarin, asked axaml(?)/axml. if looking axml examples of android cards (vs. tamarin's form xaml), load android studio , browse github based googlesamples. use github directly, have axml gui designer can edit cards visually (and in text mode) , copy axml on xamarin load gui of android app via resource. starting cardview sample best bet: <?xml version="1.0" encoding="utf-8"?> <!-- copyright 2014 android open source project licensed under apache license, version 2.0 (the "license"); may not use file except in compliance license. may obtain copy of license @

ios - Organising programmatically added views inside UIView with AutoLayout -

i'm trying rearrange programmatically created views inside uilabel. numero.text = string(indexpath.row) status.text = atividade?.status nomeatividade.text = atividade?.nome numero.sizetofit() status.sizetofit() nomeatividade.sizetofit() cellatividade.textlabel?.addsubview(numero) cellatividade.textlabel?.addsubview(status) cellatividade.textlabel?.addsubview(nomeatividade) that's code creates views , add 'em uilabel. var viewsdictionary = ["numero":numero, "status":status, "nomeatividade":nomeatividade] let view_constraint_v:nsarray = nslayoutconstraint.constraintswithvisualformat("h:|-[numero]-[status]-[nomeatividade]", options: nslayoutformatoptions(0), metrics: nil, views: viewsdictionary) cellatividade.textlabel?.addconstraints(view_constraint_v [anyobject]) and that's 1 i'm using create autolayout. so, i'm getting autolayout errors, "unable simultaneously satisfy constraints" , can imagine

python - Trouble with getting data into JSON dict from html file -

i'm trying scrape website , far code has gotten me copied html code below. however, want access variable tablelist, 'defjson:' part , parse data in there. looks .split('\n') not working, splitting on spaces not work because data in defjson has random spaces. there other way access defjson? <script type="text/javascript"> function _dozoom(t){ setcookie(fontcookiename,h,9999); var a=document.getelementsbytagname("dl"); var k=[],c=[],g=[]; var b=a.length; for(var f=0;f<b;f++){ if(a[f].getelementsbytagname("span").length>0){ g.push(a[f]);k.push(a[f].getelementsbytagname("span")[0]); c.push(a[f].getelementsbytagname("span")[1]) } } b=g.length; var e=document.getelementbyid("combinationscontainer"); switch(parseint(h)){ case 0:e.style.fontsize="14px

How to store other languages in mysql database using ruby? -

Image
i want store languages other english in mysql database using ruby. i've tried store hindi language characters in mysql database, got activerecord::statementinvalid error. here attached screenshot - please me solve problem. in advance. you run following command on desired table(s): alter table <table_name> convert character set utf8 collate utf8_unicode_ci; mysql docs on collation , character set configuration. hope helps!

linux - Cant connect to mysql ssl with compiled php (ubuntu 12) -

i have been bashing head against wall couple of days now. cant figure out. i run ubuntu 12 plesk 12 , apache 2.2. i have compiled php 5.6.10 , php 5.6.11 these options: ./configure --prefix=/opt/php-5.6.11-apache --with-config-file-path=/opt/php-5.6.11-apache/etc --disable-debug --enable-roxen-zts --enable-short-tags --enable-magic-quotes --enable-sigchild --enable-libgcc --with-libdir=/lib/x86_64-linux-gnu --with-openssl --with-openssl-dir=/usr/bin --with-zlib --enable-bcmath --with-bz2 --enable-calendar --enable-ctype --with-curl=/usr/bin --with-cdb --enable-inifile --enable-flatfile --enable-dba --with-xsl --enable-dom --enable-exif --enable-filter --enable-ftp --with-gd --with-png-dir=/usr --with-jpeg-dir=/usr --enable-gd-native-ttf --with-freetype-dir=/usr --with-gettext --with-gmp --enable-hash --with-iconv --with-imap --with-imap-ssl --with-kerberos --with-ldap --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-mcrypt=/usr --with-mhash --with-mys

android - Editing text size of a sub item in a listview -

i want edit textsize, textcolor , textstyle of subitem in listview. <listview android:id="@+id/order_list" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/network_progress_bar" android:layout_marginleft="15dp" android:layout_weight="2" android:divider="@color/list_divider" android:dividerheight="1dp" android:listselector="@drawable/list_row_selector" android:stackfrombottom="true" android:transcriptmode="normal" android:textsize="@dimen/subhead" android:textcolor="@color/black_percent_87" android:textstyle="bold|italic" > what attributes of listview can use change color, style , size of subitems? you need make custom layout list row this... http://www.learn2crack.com/2013/10/android-custom-listview-images-text-exa

sql server - Are stored procedures declarative or imperative? -

please read following example first. i have database table named product , table has column named id data type int. i'm writing stored procedure adds new product. 1 of rules of database when adding new product, id assigned must smallest integer started 1, , of course ids unique. for example, if existent ids 1, 2, 3, 4, 5, 6 new product have id of 7. if existent ids 1, 2, 3, 5, 6, 8 new id 4. this try: declare @newid int set @newid = 1 while exists (select * product product.id = @newid) set @newid = @newid + 1 /*then use @newid insert new item table product*/ but friend told me code not efficient because query inside while loop's condition evaluated each iteration. and part of code: declare @currentid int, @lastid int, @newid int set @lastid = 0 declare idcursor cursor select product.id product order product.id open idcursor fetch next idcursor @currentid while @@fetch_status = 0 begin if @currentid <> @lastid + 1 break

parallel processing - Python - multiprocessing unexpected results -

i have code containing iterator, works well: import multiprocessing m = [0,1,2,3] class gener(object): def __init__(self, m): self.m = m self.c = 0 def __iter__(self): return self def next(self): time.sleep(1) ret = self.m[self.c] self.c += 1 return ret tt = gener(m) def gen(t): return t.next() print gen(tt) print gen(tt) print gen(tt) out: 0 1 2 but if try insert parallel process don't expected results: import time import multiprocessing m = [0,1,2,3] class gener(object): def __init__(self, m): self.m = m self.c = 0 def __iter__(self): return self def next(self): time.sleep(1) ret = self.m[self.c] self.c += 1 return ret tt = gener(m) def gen(t): return t.next() job1 = multiprocessing.process(target=gen, args=(tt,)) print job1.start() job2 = multiprocessing.process(target=gen, args=(tt,)) print job

scrapy spider - Xpath error message "exceptions.ValueError: Invalid XPath:" -

i try use xpath @content attribute of following html code: <meta content="52222" name="dcsext.job_id"> i use xpath code portion of scrapy spider: def parse(self, response): hxs = htmlxpathselector(response) sites = hxs.select('//*') site in sites: il = dataitemloader(response=response, selector=site) il.add_xpath('listing_id', 'meta[@name="dcsext.job_id"]@content') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ il.add_xpath('loc_pj', substring-after('h1[@class="title heading"]/text()',':')) il.add_xpath('title', 'head/title/text()') il.add_xpath('post_date', 'div[@id="extr"]/div/dl/dd[3]/text()') il.add_xpath('web_url', 'head/link[@rel="canon"]@href') yield il.load_item() i got error message of of underlined

php - Convert mysql_result to mysqli -

i'm no programmer , know little php, i'm trying fix code in oscommerce store giving following error on php 5.4: mysql_result(): supplied argument not valid mysql result resource this code: $products = $cart->get_products(); ($i=0, $n=sizeof($products); $i<$n; $i++) { $id_produto = (int)$products[$i]['id']; $sql = tep_db_query("select p.manufacturers_id,m.manufacturers_cep,m.manufacturers_name products p left join manufacturers m on m.manufacturers_id = p.manufacturers_id p.products_id = '$id_produto'")or die(mysql_error()); $id_fabricante = mysql_result($sql,'0','manufacturers_id'); $cep_fabricante = mysql_result($sql,'0','manufacturers_cep'); $nome_fabricante = mysql_result($sql,'0','manufacturers_name'); $id_fabricantes[$id_fabricante]['peso'] += $products[$i]['quantity']*$products[$i]['weight']; $id_fabricantes[$id_fab

templates - How to use parentheses for generics? -

i'm getting compile error: angle-bracket notation not stable when used fn family of traits, use parentheses [e0215] what mean? how "use parentheses"? use std::hash::hash; use std::collections::hashmap; struct memoedfun<a, r> { fun: fn(&a) -> r, map: hashmap<a, r>, } fn memoize<a: eq + hash, r>(fun: fn(&a) -> r) -> memoedfun<a, r> { memoedfun { fun: fun, map: hashmap::new(), } } impl<'a, a, r> fnonce<a> &'a memoedfun<a, r> { type output=&'a r; } there several problems code. first of all, cannot use fn* traits directly in stable rust. includes 1) using angle-brackets notation, , 2) implementing these traits. possible enable feature flag both of these things in unstable rust though. second, if use angle brackets closure traits, have use tuples arguments, if there 1 argument: fnonce<(a,)> third, error message instead of fnon

Elasticsearch Date Range Aggregation and Time Zone -

i try build date range aggregation, have problem add time zone. timestamps in search documents like: "2015-06-29t00:00:00.000+02:00". it`s yoga-time german time zone. the date histogramm aggregation , date range filter have setting time zone: for example: "range" : { "valid_to" : { "from" : "now/d", "to" : "now/d+1d", "time_zone" : "+02:00" } } but can not find similar in date range aggregation: "valid_to" : { "date_range" : { "field" : "valid_to", "ranges" : [ { "key" : "today", "from" : "now/d", "to" : "now/d+1d" }, { "key" : "week", "from" : "now/d", "to" : "now/d+6d" }, ... ] }

matlab - system of non-linear equations given in matrix form ( using fsolve) -

Image
i trying solve system of nonlinear equations using fsolve . system given in matrix form (image), u_i being unknowns. plz suggest how can create function given input fsolve . thanks check out the documentation fsolve . can create function handle, either function in own file or anonymously, , call using fsolve : h = @(u) p'*u.^2; % function handle u_next = fsolve(h, u); if doing inner product, need make sure left-hand side has same number of columns right-hand side has rows . instance, if have arbitrary 4x1 matrix p , initial 1x4 vector u , have take transposes make sure inner product works out: p = rand(4, 1); % random column vector u = rand(1, 4); % random row vector h = @(u) p'*u'.^2; % (1x4) * (4x1) = scalar result or if trying element-wise multiplication: h = @(u) p'.*u.^2; % (1x4) .* (1x4) = (1x4) result element-wise multiplication

Spring 4 @Value where property default is a java system property -

in spring 4, using @value annotation, right way specify system property default if specified property not exists? whereas works no-default case: @value("${myapp.temp}") private string tempdirectory; this doesn't work when need default: @value("#{myapp.temp ?: systemproperties.java.io.tmpdir}") private string tempdirectory; nor this: @value("#{myapp.temp ?: systemproperties(java.io.tmpdir)}") private string tempdirectory; both of these give me exception @ time spring trying create bean: org.springframework.beans.factory.beancreationexception: error creating bean name 'configurationservice': invocation of init method failed; nested exception java.lang.nullpointerexception can done? i tried following , worked me: @value("${myapp.temp:#{systemproperties['java.io.tmpdir']}}") private string tempdirectory; the missing parts believe not using ?: , needing #{} . according answer : $

R - Generate a sequence of numbers -

i trying create sequences of number of 6 cases, 144 cases intervals. like 1 example c(1:6, 144:149, 288:293) 1 2 3 4 5 6 144 145 146 147 148 149 288 289 290 291 292 293 how generate automatically such sequence seq or function ? i find sequence function helpful in case. if had data in structure this: (info <- data.frame(start=c(1, 144, 288), len=c(6, 6, 6))) # start len # 1 1 6 # 2 144 6 # 3 288 6 then in 1 line with: sequence(info$len) + rep(info$start-1, info$len) # [1] 1 2 3 4 5 6 144 145 146 147 148 149 288 289 290 291 292 293 note solution works if sequences you're combining different lengths.

angularjs - How to test angular-ui-Selectize using Protractor? -

i want test simple user creation form contains few dropdown controls (each 1 angular-ui-select) i didn't find doc on how select 1 of items.. this html: <ui-select ng-model="user.assignedgroup" theme="selectize" class="dropdown"> <ui-select-match placeholder="{{::strings('userdetails.assigntogroupplaceholder')}}">{{$select.selected.name}}</ui-select-match> <ui-select-choices repeat="group.name group in groups"> <span ng-bind-html="group.name | highlight: $select.search"></span> </ui-select-choices> </ui-select> i able dropdown list open by: element(by.model('user.assignedgroup')).click(); what's next?? edit the current solution found using typing , searching specific element , "hit" enter k

c - sentinel controlled loop does not work -

why wont sentinel controlled loop work? i should able enter many names when enter -1 should terminate. can point me in proper direction? #include <stdio.h> #include <string.h> int main() { char namedata[50]; int n, count = 0, names = 1; while (names > 0) { printf("enter family member name:\n"); scanf("%s", &names); printf("name:"); puts(namedata); if (names > 0) { namedata[count] = names; count = count + 1; } } if (strcmp(names, "crystal") == 0) { printf("crsytal cool"); } return 0; } your program has numerous problems. i'm lazy explain them , suggest fix them. i've rewritten code: #include <stdio.h> #include <string.h> int main(){ char namedata[100][50]; /* 2d array of 100x50 bytes size can hold upto max of 100 strings each of max 50 byt

ruby on rails - Multiple arguments with block in FactoryGirl -

i have method in spec\factories\campaigns.rb : def campaign_trait(name, *callback_attrs, &block) trait name association :campaign_type, factory: [:campaign_type, name] after(:build) |campaign, evaluator| eval_str = "" callback_attrs.each |arg| arg = [arg] unless arg.is_a? array method_name = arg.shift method_args = arg method_name = "add_#{method_name}" unless respond_to? method_name eval_str << method_name.to_s eval_str << "(campaign" eval_str << ", evaluator" if method_name == "add_campaign_scopes" if method_args.any? method_args.map! { |i| i.is_a?(symbol) ? ":#{i}" : } eval_str << ", " << method_args.map(&:to_s).join(', ') end eval_str << ")\n" end eval eval_str end yield(block) if block_given? end end

ios - Titanium Facebook module issue -

i'm using native facebook titanium module , have following issue. in app, can login fb 2 different windows. in first one, instatiated module , added module 'login' listener. in second window did same, instantiated module , added 'login' listener. problem following: second addeventlistener doesn't overwrite first (it looks second facebook 'require' pointer module instantiated in first window). so, happens following: when try authorize user , enter login listener, turns out i'm calling first one, not second (the second never gets called). i tried remove first eventlistener no luck. moreover, 'live' in distant windows , seems there's no way remove listener correctly. any appreciated, iannis i hope clarify seeing: it's standard commonjs behaviour modules cached , second , following require() reference first instance. like name says addeventlistener adds event listener , not replace 1 added earlier. you

javascript - new to grunt - warning: task "concat, uglify" not found -

as title says i'm new grunt. following tutorial located at: http://24ways.org/2013/grunt-is-not-weird-and-hard/ . older tutorial seems work same. have installed "grunt-contrib-concat" , "grunt-contrib-uglify" , can run both individually. when run grunt , following error: warning: task "concat, uglify" not found. use --force continue. aborted due errors. i've been looking around , can't seem figure out. files follows: gruntfile.js: module.exports = function(grunt) { // 1. configuration goes here grunt.initconfig({ pkg: grunt.file.readjson('package.json'), concat: { dist: { src: [ 'js/libs/*.js', // js in libs folder 'js/controls.js', // specific file ], dest: 'dist/built.js', }

java - if and else statement both executed within onclicklistener for linearlayout -

i have onclicklistener linearlayout: linearlayout closedbets = (linearlayout) findviewbyid (r.id.closedbetslayout); closedbets.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { textview closedtxt = (textview) findviewbyid(r.id.settledbetstxtview); closedtxt.settextcolor(color.parsecolor("#09ad21")); textview openbetstxt = (textview) findviewbyid(r.id.openbetstxtview); openbetstxt.settextcolor(color.parsecolor("#b4b5ae")); listwriter = getlistwriter(); if (listwriter.size() ==0) { log.d("empty listwriter","empty"); textview emptybet = (textview) findviewbyid(r.id.nobetstxtbox); emptybet.settext("none of bets have been settled yet."); emptybet.setvisibility(view.visible); } else { populatelist();

c# - Why does ReSharper default to boolean when extracting a new method? -

as refactoring old code , extracting logic methods using resharper's create method, have noticed whenever method needs return default return type in signature boolean. i wondering if knew why so? why wouldn't default more generic such object? this not urgent problem need solve, since admire working tool know more it. is choice jetbrains made based on statistical data or there more subtle missing? thank time.

php - Twilio lookup API not working? -

Image
i'm trying use twilio's lookup api properties of mobile number via php... little success: $twilioclient = new lookups_services_twilio(credential::twiliosid, credential::twiliotoken); $number = $twilioclient->phone_numbers->get($somenumber); note example code present within 'getting started' page here . by taking @ $number in debugger, can confirm returning something: the highlighted property of object recursive no new information. attempting evaluate $number->phone_number returns null . have tried perhaps half dozen valid numbers , response get. attempting json_encode($number) returns false . i have no idea why not working, it'd helpful if know i'm doing wrong. i'm gonna go ahead , assume phone numbers you've tried neither us, nor in international format. from twilio's lookups quickstart tutorial : you'll want include country code of phone number formatted. if not included, country code defa

regex - PHP remove numbers in brackets -

i have string looks following in php: foo [123][bar] , i'd remove [123] string entirely end foo [bar] . another example blah [9484][m0200 blah blah blah] makes things more complicated because can't remove numbers , remove empty brackets. first set of brackets contains 3-4 digit number, , never letters, second brackets can contain anything. any suggestions how i'd go doing this? thanks. this regex \[\d{3,4}\] will find 3-4 digit numbers inside brackets. demo: https://regex101.com/r/kh3nz5/1 used preg_replace, http://php.net/manual/en/function.preg-replace.php , replace found instances. echo preg_replace('~\[\d{3,4}\]~', '', 'blah [9484][m0200 blah blah blah]'); output: blah [m0200 blah blah blah] \d single number , {3,4} says @ least 3 occurrences of number , no more 4. pages more detailed info on regexs, http://www.rexegg.com/ http://www.regular-expressions.info/

c - Declaring inner structure variable in nested structure without referring outer structure -

i creating simple nested structure aware it's functioning process.here example: struct employee { char ename[20]; int ssn; float salary; struct date { int date; int month; int year; }doj; }emp1; in case if want access members of inner structure need like emp1.doj.date = 10; but in above structure if omit variable declaration of structure date i.e doj , try declare separately it did not require reference emp1 i.e struct date doj; the compiler did not give error in case. can access members of structure date without reference emp1 like doj.date =15; i want know how possible? there no special scoping rules inner structures in c means scope of struct date same scope of struct employee . free declare objects of inner structure type anywhere can declare object of outer structure type. for example, these declarations same yours: struct date { int date; int month; int year; }; struct employee {

android - save bookmark or favorite item in ionic framework when i close app -

i have item-list , mark of them . when close app , open aggain , marks removed . please me save , load app list.html <ion-view class="text-center bfont" view-title="کافی شاپ"> <ion-nav-buttons side="left"> <button class="button button-icon ion-help-circled" ng-click="openmodal()"></button> </ion-nav-buttons> <ion-nav-buttons side="right"> <button class="button button-icon ion-gear-a" ng-click()="openmodal()"></button> </ion-nav-buttons> <div class="bar bar-subheader item-input-inset bar-light"> <label class="item-input-wrapper"> <i class="icon ion-search placeholder-icon"></i> <input type="search" class="text-right" ng-model="query" placeholder="جست و جو"> </label> </div> <ion-content class=&

android - Update and delete specific marker in Google Map -

i displaying location of buses in google map getting location bus database table on server. facing problem delete or update locations on google map since new marker being created when longitude , latitude change in bus table. how can delete , update specific marker in google map? i appreciate help. code: private void gotolocation(double lat, double lng, string route_direct) { supportmapfragment mapfragment = (supportmapfragment) getsupportfragmentmanager() .findfragmentbyid(r.id.map); mapfragment.getmapasync(this); final float zoom = 11; latlng ll = new latlng(lat, lng); if (lat != 0 && lng != 0 && !route_direct.isempty()) { markeroptions markeropt = new markeroptions().title(route_direct) .position(ll).visible(true); marker marker = map.addmarker(markeropt); marker.showinfowindow(); cameraupdate update = cameraupdatefactory.newlatlngzoom(ll, zoom); map.movecamera(update

checkbox - HTML5 Browser Validation for Checkboxes - given multiple checkboxes how can I make sure at-least one is selected? -

given simple this: <form ...> <input type="checkbox" required name="op1"> option 1</u> <input type="checkbox" required name="op2"> option 2</u> <input type="submit"> </form> is there way using html5 validation validate if 1 of boxes checked , if none selected focus required tooltip on form? you cannot html5 here way javascript html <form onsubmit="return checkcheckboxes(this);"> <input type="checkbox" required name="op1"> option 1</u> <input type="checkbox" required name="op2"> option 2</u> <input type="submit"> </form> javascript <script type="text/javascript" language="javascript"> <!-- function checkcheckboxes(theform) { if ( theform.opt1.checked == false && theform.opt2.checked == false)

node.js - Node JS Request + Express Pipe -

i have problem streaming video files server another. i wrote script var request = require("request"), express = require("express"); var app = express(); app.get("/cast", function(req, res) { var url = req.query.video; res.writehead(200, { 'content-type': 'video/mp4' }); request({ url: url, headers: { referer: "http://example.com/1706398/" + url } }) .on('response', function(response) { response.on('data', function(data) { console.log("data chunk received: " + data.length) }); response.on('end', function(data) { console.log('video completed'); }); }) .pipe(res); }); app.listen(8080); but video response works corrupted, instead if request's data written in writeable buffer , saved video file works

unicode - What is a good strategy when it comes to Python I/O and user input from command prompt? -

i freaking out lately because have spent week writing totally useless pyton module transforms spacial data .csv format. i got not problemwith handling spatial data when software runs ask user submit input command prompt or cygwin. after lot of effort , googling got somehow work utf-8. i made compromise use english language , not (greek) needed errors english! take @ error: please respond 'yes' or 'no' or 'y' or 'n'). add trips route id ''no5leho'' , direction 0? [y/n] y traceback (most recent call last): file "main.py", line 296, in <module> inputaddtrips = query_yes_no('would add trips route id \'\'%s\'\' , direction 0?\r\n' % (i)) file "main.py", line 33, in query_yes_no choice = input().lower() file "c:\python34\lib\codecs.py", line 319, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) unicodedecodeerror: 'utf-8' codec can't de

excel - How to check the date is in US format in java -

the user enters date follows: 20/05/2015 now know in format date invalid. how check in java? in code date value excel sheet , how i'm processing it. date read excel sheet numerical. example-3124.0 i.e., no. of days passed since 1/1/1990. converting format mm/dd/yyy: simpledateformat sdf = new simpledateformat("mm/dd/yyyy"); string s = sdf.format(cell.getdatecellvalue()); format method of simpledateformat takes in date parameter. hence cell.getdatecellvalue() gives date type value passed format method converts string value. simpledateformat sdf = new simpledateformat("mm/dd/yyyy"); string s = sdf.format(cell.getdatecellvalue()); system.out.println(s); sdf.setlenient(false); date d= sdf.parse(s); system.out.println(sdf.format(d)); so if excel cell value 12/08/2015 system.out.println(s); // prints 12/08/2015 system.out.println(sdf.format(d)); //prints 12/28/2015 don't understand. if date comes string can try regex:

indexing - Re-index table in mysql -

i have table in database re-index. because rows deleted, have : id name phone 1 xxxx xxxxx 4 xxxx xxxxx 6 xxxx xxxxx and like: id name phone 1 xxxx xxxxx 2 xxxx xxxxx 3 xxxx xxxxx id auto-incremented. change of id row won't have impact on rest of site, it's single , simple customer list. i've searched on internet , found things repair table i'm not sure it's adapted case :/ thanks ! you can try dropping id field , re-create this: alter table `my_table` modify column id int not null; alter table `my_table` drop primary key, add primary key(id); alter table `my_table` modify column id int not null auto_increment; i suggest trying on development database first ideally, or otherwise @ least duplicate table , try on first. don't want risk "production" data.

How to Create a Button to Upload documents to a document library (Sharepoint 2010) -

need link via button upload.aspx page. want "upload document" page open when click custom button (pic). you can add button(pic), , on click call bellow function newitem2(event, "http://<web>/sites/sitecollectionname/_layouts/upload.aspx?list={ec8746e1-77f4-4b60-b50d-9427e0c0be57}&rootfolder=") please change guid document library guid. open "upload document" page in popup can upload documents.

android - How to access invidual json objects from a json array? -

i have following response, , want display eqid 's in invidual textview 's, don't know how achive this, below snippet code , response data server , display in textview. can me this? { "earthquakes":[ { "eqid":"c0001xgp", }, { "eqid":"c000905e", }, { "eqid":"2007hear", }, { "eqid":"c00090da", }, { "eqid":"2007aqbk", }, { "eqid":"2007hec6", }, { "eqid":"a00043nx", }, { "eqid":"2010utc5", }, ] } code servicehandler sh = new servicehandler(); jsonstr = sh.makeservicecall(user_url, servicehandler.get); log.d("response: ", "> " + jsonstr); try{ jsonobject json = new jsonobject(jsonstr); jsonarray items = json.getjsonarray(&qu

MySQL 5.6.x & PHP 5.6 - seems to intermittantly lock up -

Image
i've got multiple computers mysql 5.6.21 installed. upgraded 5.5, others have ever had 5.6 on them. every 1 of them lock every during routine sql queries our php scripts can't run further queries whatsoever. when database locks up, there's 2 options running again: restart mysql server kill process that's holding else up all mysql servers running innodb databases , seem freeze when running queries in quick succession or when running non-finalized queries aren't written correctly, have syntax errors, etc during development process. i've noticed process causing database lock seem 'sleep' command (at least that's "show processlist" indicates). it should noted when these computers working mysql 5.5.x databases never locked up. these databases aren't networked in way. these developer machines databases setup on localhost. this seems similar else knew tried mysql 5.6.x. running queries within threaded web application. under mysq