Posts

Showing posts from January, 2015

c# - WPF returning a List to the class -

new wpf , c# vb web forms, sorry poorly structured question add needed improve. trying implement example adding database calls mysql populate on-demand tree view control. here link sample code... sample code got db connection working , data populating dataset. iterate place in list. can not seem figure out issue passing list class populate control... public class level1 { public level1(string level1name) { this.level1name = level1name; } public string level1name { get; private set; } readonly list<level2> _level2s = new list<level2>(); public list<level2> level2s { { return _level2s; } } } i have database class queries db , parses data.... list<string> level1s = new list<string>(); dataset ds = new dataset(); foreach (datatable table in ds.tables) { foreach (datarow row in table.rows) { level1s.add((string)row["name"]); } } **update**: trying return list... re...

objective c - Xcode Google Signin Button Image And Text not showing in Iphone -

i'm following link steps , setup google login pods google login integration link when run app, can show google sign-in button text , image in simulator not showing in device. can show blue button. (i add view inherit gidsigninbutton, not button). how can solve problem ? thanks.

optimization - Combination Algorithm to Find Target Value from Finite List of Values -

i have problem in have finite set of values, say: [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10] i write algorithm in provide target value, , in list of 2 (quantity, value) pairs returned such following rules followed. rules listed in decreasing order of importance, un-numbered rules being 'nice-to-have' note 'have-to-have'. the sum of products of quantity-value pairs equals target value either 1 or 2 quantity-value pairs used each pair in integer quantity , 1 of values list the sum of quantities minimized the 2 values within 2 of each other, such (value2 - value1) <= 2 the number of 1/2 values minimized the lowest values possible in list used my question follows: parameters of problem fall within of 'classic', or well-known/researched computer algorithms? if of conditions tweaked, problem made more 'classic' optimization problem? i interested in approaching problem in other way 'brute force...

c# - Using LINQ, how would you filter out all but one item of a particular criteria from a list? -

i realize title isn't clear here's example: i have list of objects 2 properties, , b. public class item { public int { get; set; } public int b { get; set; } } var list = new list<item> { new item() { = 0, b = 0 }, new item() { = 0, b = 1 }, new item() { = 1, b = 0 }, new item() { = 2, b = 0 }, new item() { = 2, b = 1 }, new item() { = 2, b = 2 }, new item() { = 3, b = 0 }, new item() { = 3, b = 1 }, } using linq, what's elegant way collapse = 2 items first = 2 item , return along other items? expected result. var list = new list<item> { new item() { = 0, b = 0 }, new item() { = 0, b = 1 }, new item() { = 1, b = 0 }, new item() { = 2, b = 0 }, new item() { = 3, b = 0 }, new item() { = 3, b = 1 }, } i'm not linq expert , have "manual" solution expressiveness of linq , curious see if done better. how about: var collapsed = list.groupby(i => i.a) ...

javascript - How to get link specific php varaible to pass through ajax -

i dont know ajax or jquery yet have ajax script send variable through , work properly. -- the way have set loop: <?php $tt= mysql_query("select * monsters"); while ($row= mysql_fetch_array($tt)) { $namee= $row['name']; echo "<a id='namee' onclick='post();'>$namee</a>", "</br>"; } which echos: horseman dragon ---the results make list of names table shown above , clickable working great my ajax request this: <script type="text/javascript"> function post(){ var hr = new xmlhttprequest(); var url = "mess.php"; var vars =document.getelementbyid("namee").innerhtml; hr.open("post", url, true); hr.setrequestheader("content-type", "application/x-www-form-urlencoded"); hr.onreadystatechange = function() { if(hr.readystate == 4 && hr.status == 200) { var return_data = hr.responsetext; document.getelement...

performance testing - How to test with jMeter against basic auth protected domain? -

Image
i running staging cluster of apache/nginx webservers domain has basic authentication restricted access. goal test performance of cluster jmeter. in order pass authentication have added http authentication controler of jmeter. works, every request shows 2 logentries @ apache. 1 200 , 1 401. normal behavior of first request user must authenticated. unfortunatelly, jmeter on every request. how can make sure each thread/user requests access once. or better, how grant jmeter access without every user needing authenticat. believe impact test results. thank hint on this. it sounds jmeter bug given proper "authorization" header provided there shouldn't www-authenticate challenge. if file via jmeter bugzilla or flag via jmeter users mailing list great in meantime can work around using 1 of following approaches: inject credentials directly url - in case of jmeter "path" input field like: http://username:password@host.domain/path use beanshel...

command line interface - What does git log --exit-code mean? -

the git-log man page describes --check option incompatible --exit-code option. i'd know --exit-code means can't find anywhere. i've tried man git log , man git , google , direct search here on so... no avail! what --exit-code mean git log ? tl; dr i'd know --exit-code means [...] --exit-code diff-* 1 option makes git command exit 1 if there changes, , 0 otherwise. [...] can't find anywhere. you can read in git-diff man page, not in git-log man page, because makes no sense in context of git-log . more details both --check , --exit-code described in git-diff man page (more specifically, in documentation/diff-options.txt ): --check warn if changes introduce whitespace errors. considered whitespace errors controlled core.whitespace configuration. default, trailing whitespaces (including lines solely consist of whitespaces) , space character followed tab character inside initial indent of line considered whit...

ios - Migration fail because Realm accessed before migration -

i using storyboards , of viewcontrollers fetch realm default property values? because of application access realm before application(_:didfinishlaunchingwithoptions:) called. exception raised every time app launches , tries realm migration. is there way solve issue? further, since in dev stage , don't want deal migration every time made changes realm object models, there way purge realm file , have fresh start if migration detected needed? find issue reported on github ( https://github.com/realm/realm-cocoa/issues/1692 ) seems no solution provided. ps, using latest realm ios. if you're unable control order storyboards being loaded automatically ios in contrast app delegate methods, recommendation remove initial storyboard setting app's info.plist file , manually set , display app's delegate instead: func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject: anyobject]?) -> bool { let storyboard = uist...

c - Is brother-brother pipe safer than father-child? -

in case of establishing pipe between 2 processes, if 2 have brother brother relationship rather father-child, more error prone ? my question arose when investigated code example below: #include <stdlib.h> #include <stdio.h> #include <sys/wait.h> void runpipe(); int main(int argc, char **argv) { int pid, status; int fd[2]; pipe(fd); switch (pid = fork()) { case 0: /* child */ runpipe(fd); exit(0); default: /* parent */ while ((pid = wait(&status)) != -1) { fprintf(stderr, "process %d exits %d\n", pid, wexitstatus(status)); exit(0); } case -1: perror("fork"); exit(1); } exit(0); } char *cmd1[] = { "ls", "-al", "/", 0 }; char *cmd2[] = { "tr", "a-z", "a-z", 0 }; void runpipe(int pfd[]) { int pid; switch (pid = fork()) { case 0: /* child */ ...

javascript - Angular JS - Retrieve URL parameters -

what correct angular approach retrieving url parameters? example: http://example.com/mypage.html?product=1234&region=4&lang=en thanks this convert query object var querydata = url.split('?')[url.split('?').length - 1].split('&').reduce(function(prev, curr){ var fieldname = curr.split('=')[0]; var value = curr.split('=').length > 1 ? curr.split('=')[1] : ''; prev[fieldname] = value; return prev }, {}); and can access them querydata.product, example. not angular, it's solution. for angular way, can use $location.search() described here http://www.angulartutorial.net/2015/04/get-url-parameter-using-angular-js.html

javascript - Pass IEnumerable List data to Controller -

i need pass model.component_grouppanel_component list controller. have following code couldn't achieve it. code in view:----- var test = { rows : @html.raw(model.component_grouppanel_component) , cmp_db_id: @model.component_grouppanel_component[0].child_cmp_dbid }; $("#btnupdate").click(function() { $.ajax({ url: "@url.action("editmy", "componentgrouppanel")", data: json.stringify(test), type: 'post', contenttype: "application/json", }); }); code in controller:----- public jsonresult editmy(ienumerable<cmp_grouppanel_cmp> rows, int cmp_db_id) { return json(true); } i think looks should using ajax action link. available in razor can run client side code here , load objects need. https://msdn.microsoft.com/en-us/library/system.web.mvc.ajax.ajaxextensions.actionlink(v=vs.118).aspx http://www.c-sharpco...

c# - Checking the time difference between boolean values -

i've got boolean value called ispressed active when keyboard , mouse buttons active. want achieve when ispressed boolean value true start timer (preferably using stopwatch class). while ispressed true keep timer going , ispressed false stop timer , difference. after it's stopped , it's true again , stops again, add difference previous timer. i tried use code post couldn't work. tried doing like: stopwatch stopwatch = new stopwatch(); timespan ts = stopwatch.elapsed; if (ispressed) { stopwatch.start(); } else { stopwatch.stop(); string elapsedtime = string.format("{0:00}:{1:00}:{2:00}.{3:00}", ts.hours, ts.minutes, ts.seconds, ts.milliseconds / 10); lbltime.text = string.format("{0}", elapsedtime); } the lbltime label stayed @ 0. i'm thinking stopwatch maybe unnecessary overhead. mark time ispressed set true , time ispressed set false , calculation. private long _pressedticks; private long _dur...

java - Class in Android like Struct in Swift -

in app in swift have code: struct question { var questionlbl : string! var answers : [string]! var answer : int! } after use struct this var questions = [question]() questions = [question(questionlbl: "whats name?", answers: ["john","josh","adam","leo"], answer: 0), question(questionlbl: "whats moms name?", answers: ["jessica","crystal","samanta","kate"], answer: 3), question(questionlbl: "whats fathers name?", answers: ["ed","blake","jeff","jonhson"], answer: 2)] now, i'm trying make same app android.. created class , tried same thing that.. class file: public class question { string questionlabel; string[] answersoptions; integer correctanswer; public question(string questionlabel, string[] answersoptions, integer correctanswer) { this....

android - ParseTwitterUtils initialize throws NullPointerException -

i getting nullpointerexception calling parsetwitterutils.initialize(twitter_consumer_key, twitter_consumer_secret); here stack trace java.lang.runtimeexception: unable create application com.myapp.app.android.application: java.lang.nullpointerexception: attempt invoke virtual method 'java.io.file com.parse.parseplugins.getparsedir()' on null object reference @ android.app.activitythread.handlebindapplication(activitythread.java:5015) @ android.app.activitythread.access$1600(activitythread.java:172) @ android.app.activitythread$h.handlemessage(activitythread.java:1482) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:145) @ android.app.activitythread.main(activitythread.java:5837) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$metho...

javascript - How to get function return result? -

i developing file reading service this: angular.factory('fileservice', fileservice); function fileservice($cordovafile){ var service = { readfile: readfile }; return service; /////////////// function readfile(path, file){ $cordovafile.readastext(path, file) .then(function (success) { console.log("read file success"); console.log(success); return success; }, function (error) { alert("fail read file:"+error); console.log("fail read file"); console.log(error); return false; }); } } and using this: var data = fileservice.readfile(cordova.file.datadirectory,filename); console.log(data) //return undefined the problem fail return data. how can data return back? your problem not returning result readfile function. returning data callback functions if come think of it...that result retur...

javascript - If/else if/else error - unexpected identifier -

i'm trying execute if/elseif/else statement, getting unexpected identifier error on second else if . rest of statement works fine. i'm new coding, apologize if simple mistake. if (jquery("#question").val() === "" && (rowcount == 1)) { analysis_empty=1; } else if (rowcount > 1) { jquery('.analysis_empty_title').css({"line-height":"normal"}); jquery('.analysis_empty_title').text("results displayed date groups"); jquery('#here').html(jquery('#dategrouptable').clone().attr('id', 'tableb_copy')); jquery('#tableb_copy').css({"font-style":"italic"}); var ptr = jquery("#tableb_copy").find("tr"); ptr.find("td:last").remove(); } else if ((rowcount > 1) , (jquery("#question").val() != "" )){ jquery('#analquestion_empty').css({"display...

computer vision - Google Inceptionism: obtain images by class -

in famous google inceptionism article, http://googleresearch.blogspot.jp/2015/06/inceptionism-going-deeper-into-neural.html show images obtained each class, such banana or ant. want same other datasets. the article describe how obtained, feel explanation insufficient. there's related code https://github.com/google/deepdream/blob/master/dream.ipynb but produce random dreamy image, rather specifying class , learn looks in network, shown in article above. could give more concrete overview, or code/tutorial on how generate images specific class? (preferably assuming caffe framework) i think this code starting point reproduce images google team published. procedure looks clear: start pure noise image , class (say "cat") perform forward pass , backpropagate error wrt imposed class label update initial image gradient computed @ data layer there tricks involved, can found in original paper . it seems main difference google folks tried more "r...

jquery - Using AJAX/PHP/mysqli to create a load more button -

in code below trying create load more button using ajax. have main.php includes php code calling blogs database initially, jquery code , load more button. have ajax_more.php calls more data database when load more clicked. load more buttons displayed , when clicked change loading , disappear. nothing else happens , main.php still shows 2 initial blogs call first. please code , code has gone wrong. main.php <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $(document).on('click', '.show_more', function () { var id = $(this).attr('id'); $('.show_more').hide(); $('.loding').show(); $.ajax({ type: 'post', url: 'ajax_more.php', data: 'id=' + id, success: functio...

How can I create a CSV file with PHP that preserves the Japanese characters? -

Image
below code snippet creating , downloading csv file browser. $input_array[] = ['注文日時', '受注番号',]; $input_array[] = ['2015-09-30', 'inv-00001',]; /** open raw memory file, no need temp files, careful not run out of memory thought */ $f = fopen('php://memory', 'w'); /** loop through array */ foreach ($input_array $line) { /** default php csv handler **/ fputcsv($f, $line, ','); } /** rewrind "file" csv lines **/ fseek($f, 0); /** modify header downloadable csv file **/ header('content-encoding: utf-8'); header('content-type: application/csv; charset=utf-8'); header('content-disposition: attachement; filename="my_csv_file.csv";'); /** send file browser download */ fpassthru($f); die(); when open created/downloaded csv file, japanese characters become weird characters. not yet correct in code snippet? how can ...

Android app background fails to run on phone but works on android studio preview -

Image
not sure why happening. first let me homework assignment (as open (we have learn somehow). not late or on due). error getting not part of assignment, assignment done, experimenting things. added background image app. in preview works fine. but when run in on samsung note 4 here code...can tell me error be? <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivity" android:background="@drawable/cool_red_and_black_desktop_wallpaper_hd_3"> your phone's resolution higher. need inc...

swift - UITableView - Multiple selection AND single selection -

Image
i have 2 sections in uitableview. want first section allow multiple cell selection , second section allow single selection. tried code didn't work well. code in swift if possible. thank you. perhaps implement table view's delegate methods: tableview(_:shouldhighlightrowatindexpath:) and tableview(_:didselectrowatindexpath:) ...and determine (from indexpath.row , indexpath.section ) if relevant section supports single/multiple selection (this depend on data model's custom logic -e.g.: "section 0 supports multiple selection section 1 not"), , if supports single selection, check whether there row selected (by accessing tableview.indexpathsforselectedrows ). if there selected row already, can: return false tableview(_:shouldhighlightrowatindexpath:) , , do nothing (just return ) tableview(_:didselectrowatindexpath:) (i'm not sure if method called when return false shouldhighlight... , perhaps check it).

r - Error when importing raster file -

i transformed shapefile raster file using rasterize r function, , saved raster writeraster function (.bil , .asc). now, can't import new file, returning error: error in .local(.object, ...) : ehdr driver not support 64 nbits value. erro em .rasterobjectfromfile(x, band = band, objecttype = "rasterlayer", : cannot create rasterlayer object file. my script: library(maptools) library(raster) # shapefile natural earth website <- readshapespatial('ne_10m_roads.shp') e <- extent( -180, 180, -60, 90 ) r <- raster(e, nrow=3600, ncol=8640) s2r <- rasterize(a,r) i have using notebook ubuntu 14.10 - 64bit, , 4gb ram, rstudio software , r version 3.1.1: r version 3.1.1 (2014-07-10) copyright (c) 2014 r foundation statistical computing platform: x86_64-pc-linux-gnu (64-bit) *after format computer, new file correctly open before install dependences of rgdal via terminal. ** directories correctly choosen, , file found directory. ...

ios - Setting a PFUser.CurrentUser() pointer field -

i working on project using parse, , having hard time changing value. every user, there field called "privatedata", has fields. access it, have no problem doing this: pfuser.currentuser()!["privatedata"]!["locations"]! however, when try change "locations, errors. field name invalid, cannot subscript value of type ... or trying change immutable value. i tried: pfuser.currentuser()!["privatedata"]!["locations"]! = bla bla bla i "trying change immutable value" and when user .valueforkey: pfuser.currentuser()!["privatedata"]!.valueforkey("locations",blabla) i error 105, bad field name. any ideas? thanks time charles

javascript - mysql query for children and grandchildren -

column view +-----------------------+ | name | +-----------------------+ | electronics | | televisions | | tube | | lcd | | plasma | | game consoles | | portable electronics | | mp3 players | | flash | | cd players | | 2 way radios | | frs | +-----------------------+ table core.category id parentid name 1 null electronics 2 1 televisions 3 2 tube 4 2 lcd 5 2 plasma 6 1 game consoles 7 1 portable electronics 8 7 mp3 players 9 8 flash 10 7 cd players 11 1 2 way radios 12 11 frs if select 1, result (shows children , grandchildren) expect there more 1 grandparent(electronics) +-----+ | id | +-----+ | 1 | | 2 | | 3 | | 4 | | 5 | ...

Formatting boolean values in datagridview in vb.net -

i have datagridview display table data @ runtime,some of columns in table having data type boolean.but @ runtime check boxes getting displayed on datagirdview,i need show true or false value instead of check box.can 1 give me proper solution..? try converting value in boolean field string data type.

html - Issue with Colomn count in CSS -

columns should fill height constraint. working fine in chrome not in ie , firefox. in ie , firefox distributing evenly instead of taking height of column. have total 16 sub divs , want them come in 5 5 5 1. working fine in chrome (5 5 5 1) not in firefox , ie (4 4 4 4) here code - <div class="example"> <div class="example-auto">1a</div> <div class="example-auto">1b</div> <div class="example-auto">1c</div> <div class="example-auto">1d</div> <div class="example-auto">2a</div> <div class="example-auto">2b</div> <div class="example-auto">2c</div> <div class="example-auto">2d</div> <div class="example-auto">3a</div> <div class="example-auto">3b</div> <div class="example-auto">3c</di...

mysql - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) on MAC OSX -

i'm trying reinstall mysql on mac os x yosemite. followed instruction mentioned below sudo rm /usr/local/mysql sudo rm -rf /usr/local/mysql* sudo rm -rf /library/startupitems/mysqlcom sudo rm -rf /library/preferencepanes/mysql* vim /etc/hostconfig , removed line mysqlcom=-yes- rm -rf ~/library/preferencepanes/mysql* sudo rm -rf /library/receipts/mysql* sudo rm -rf /library/receipts/mysql* sudo rm -rf /var/db/receipts/com.mysql.* i tried brew uninstall mysql after installed mysql using homebrew using command brew install mysql . after installation when tried run mysql -u root throws following error error 1045 (28000): access denied user 'root'@'localhost' (using password: no) i didn't set password mysql.i don't know what's going wrong.any suggestion appreciated. thank you i have resolved issue myself. please check github link: https://github.com/levantuan/access_sql error 1045 (28000): access denied user 'root...

c# - generic type of class property -

i have following classes: basefield: public abstract class basefield { ... public basefield() { } public basefield(e_fieldtype fieldtype) { _fieldtype = fieldtype; } } textfield: public class textfield : basefield { ... public textfield() : base(e_fieldtype.text) { } } datefield: public class datefield : basefield { ... public datefield() : base(e_fieldtype.date) { } } and datablock class should contain textfield or datefield : public class datablock<t> : baseblock t : basefield, new() { ... private t _field; public datablock(string name): base(name, e_blocktype.data) { _field = new t(); } } the following line works fine: datablock<textfield> db = new datablock<textfield>("qwe"); but not possible write code: public observablecollection<datablock<basefield>> datablocklist { get; set; } public datablockvie...

sockets - java.io.StreamCorruptedException: invalid stream header: 70707070 -

so have seen lot of different questions no definitive help, @ least understanding or personal application. making socket "chat room" program allows user send images selected users through central server. can establish clients connect when sending image error occurs. here code: client: thread thread = new thread() { @override public void run() { try { s = new socket("localhost", 4000); while (s.isconnected()) { oos = new objectoutputstream(s.getoutputstream()); if (!initialized) { oos.writeobject(identity); oos.flush(); oos.reset(); initialized = true; } baos = new bytearrayoutputstream(1000); // take screenshot bufferedimage img = new robot() .createscree...

javascript - Detect position of first difference in 2 strings -

what cleanest way of finding position of first difference in 2 strings in javascript? var = 'in the'; var b = 'in he'; findfirstdiffpos(a, b); // 3 var c = 'in beginning'; findfirstdiffpos(a, c); // 6 you can iterate through strings , check character-by-character. document.body.innerhtml += findfirstdiffpos("in he", "in the") + "<br/>"; document.body.innerhtml += findfirstdiffpos("abcd", "abcde") + "<br/>"; document.body.innerhtml += findfirstdiffpos("zxc", "zxc"); function findfirstdiffpos(a, b) { var shorterlength = math.min(a.length, b.length); (var = 0; < shorterlength; i++) { if (a[i] !== b[i]) return i; } if (a.length !== b.length) return shorterlength; return -1; } the output 3 4 -1 : 3 : because strings differ @ position 3 4 : string abcd prefix of abcde , of different length. 4-th (...

parse.com - unrecognized selector sent to instance Error with Facebook SDK for Xcode 7 -

i using recent facebook sdk , parse sdk ios. when try run app on simulator following error: parsestarterproject-swift[2841:107652] -[pfuserauthenticationcontroller authenticationdelegateforauthtype:]: unrecognized selector sent instance 0x7fd0bbc34620 2015-09-30 00:56:33.960 parsestarterproject-swift[2841:107652] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[pfuserauthenticationcontroller authenticationdelegateforauthtype:]: unrecognized selector sent instance 0x7fd0bbc34620' this error when call facebook application in appdelegate file. pffacebookutils.initializefacebookwithapplicationlaunchoptions(launchoptions) the following stack trace. first throw call stack: ( 0 corefoundation 0x00000001102cef65 __exceptionpreprocess + 165 1 libobjc.a.dylib 0x000000011280fdeb objc_exception_throw + 48 2 corefoundation 0x00000001102d758d -[nsobject(ns...

Symfony installation exception in my wamp server -

e:\wamp\www>composer create-project symfony/framework-standard-edition myproject i got following error while running above command cmd [symfony\component\dependencyinjection\exception\invalidargumentexception] $id must string, or alias object. script sensio\bundle\distributionbundle\composer\scripthandler::clearcache handl ing post-install-cmd event terminated exception [runtimeexception] error occurred when executing ""cache:clear --no-warmup"" command. create-project [-s|--stability="..."] [--prefer-source] [--prefer-dist] [--repos itory-url="..."] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--n o-scripts] [--no-progress] [--keep-vcs] [--no-install] [--ignore-platform-reqs] [package] [directory] [version] when try open in browser displaying following things ( ! ) fatal error: uncaught exception 'symfony\component\dependencyinjection\exception\invalidargumentexception' message '$id must ...

if statement - if/else coding style consequences -

i novice programmer , in lecture 1 evening, studying "if,else" coding section professor , curious aspect of it. curious if have bunch of nested if,else's in our program, bad coding style end if,else "else,if" line of code instead of if "x", else "y"? example, if "x" else if "y" else if "z" end compared if "x" else if "y" else "z" end it still run program without error, there consequences later on other having bad programming style? behind curtain js dont have else if, doing generating if statement when parsed. e.g: if(foo){ } else if (baz){ } becomes if (foo){ } else { if (baz){ } } so reason using else if in end instead of else when want control else statement as-well , not pass case else don't fit in first condition... (in order control else condition , filter necessary items only) if have long statement lot of else-if conditions shoul...

Ionic App behaving differently across browsers and devices -

i building ionic app , have been testing app on google chrome canary , working fine expected. recently, tried testing app on mozilla firefox , app behaving bit weird buttons weren't working , app getting stucked. ignored considering might issue mozilla firefox. today, installed app on device , surprise app behaving same behaving in firefox. buttons aren't working , app getting stucked. need release app production, possible , stucked weird issue. please me out. p.s. - have added crosswalk plugin.

security - spring authentication entry point -

i have controller method, annotated with @requestmapping(value = "/someting") @preauthorize("hasanyrole('role_active')") ... when users without role transit on mapping want make users without appropriate role of redirect home page , displays alert, fact access denied. to solve problem make custom accessdeniedhandler, works perfectly, authenticated users for users without authentication found authenticationentrypoint looks like public class customauthenticationentrypoint implements authenticationentrypoint { @override public void commence(httpservletrequest httpservletrequest, httpservletresponse httpservletresponse, authenticationexception e) throws ioexception, servletexception { flashmap flashmap = requestcontextutils.getoutputflashmap(httpservletrequest); if(flashmap != null) { alerts.addwarningalert(flashmap, "access denied"); } httpserv...

php - How to get value of array by checking its value -

how can object has value of [existence] == 1 if [existence] == 1 want object has [existence] == 1 and remove [existence] == 0 this array . array ( [0] => array ( [id] => 3 [accountcode_naisen] => [extentype] => 0 [extenrealname] => [name] => 0090000270 [extenktaiemail] => [secret] => myojyo42_f [username] => 0090000270 [guestipaddr] => 192.168.236.15 [participantsetting] => array ( [id] => 13 [existence] => 1 [leader] => 1 [simultaneous] => ) ) ) this code far foreach ($participants $participant=>$c) { if ($c['existence'] != 1) { unset($participants[$participant]); } } and getting error message ********** ...

ios - Memoy leak on NSJSONSerialization JSONObjectWithData -

Image
i have searched problem didn't proper solution. in application giving multiple recursive asynchronous calls server. using mknetworkkit performing network operation. pseudocode of implementation: - updateforms{ [networkcall completionblock:^(mknetworkoperation *op){ dictionaryobject = op.responsejson if(moreforms) [self updateforms] // recursive call else save data in db , proceed further } } however while executing above code memory usage getting increased 4 - 10 mbs after each call in completion block(i think on line dictionaryobject = op.responsejson). after using instruments, showing memory leak @ line nsjsonserialization jsonobjectwithdata in mknetworkkit function : following actual code have written: - (void)updateforms:(int)requestcount { /* ==================================== * update forms webserver * ==================================== * */ __block in...

google chrome - Show all CSS styles for an element, even when not currently matching media query -

Image
is there way (preferably in chrome developer tools) see css styles apply element? the styles tab in chrome devtools shows rules media queries match. you can click on element tab , on stylesheet document link, take source tab can edit stylesheet , can see styles given in stylesheet.

asp.net - Changing DataSourceId of a dropdown from JavaScript -

can change datasourceid of drop down depending on dropdown selection in javascript got 3 dropdown value on base of selection of dropdown want change datasource of sqldatasource <script type="text/javascript"> function abc() { if (document.getelementbyid('type').value == "c") { } else if (document.getelementbyid('type').value == "g") { } else if (document.getelementbyid('type').value == "s") { } } </script> <asp:dropdownlist id="type" runat="server" onblur ="abc();"> <asp:listitem>c</asp:listitem> <asp:listitem>g</asp:listitem> <asp:listitem>s</asp:listitem> </asp:dropdownlist> <asp:sqldatasource id="c" runat="server" data...

How to send multiple parameters to php using ajax -

here trying send multiple variable values php page through ajax. here calling javascript function values form , submit values ajax. in javascript getting multiple values form. want pass these values php page. how can achieve that? here have done. function sendinvite(){ var from_name = document.getelementbyid('invite_username').value; var name_string = 'invitename='+ from_name; var email = document.getelementbyid('friendemail').value; var mail_string = 'friendemail='+ email; var product_name = document.getelementbyid('invite_productname').value; var product_string = 'invite-product-name='+ product_name; var product_link = document.getelementbyid('invite_url').value; var link_string = 'invite-url='+ product_link ; $.ajax({ type : "post", url : "legoland.php", data: name_string,mail_string, cache:false, su...

c# - Camera button long press event in windows tablet -

i trying make torch application in windows tablet. ultimate aim "user should have immediate access torch" . managed put application in settings tab of charms bar . requires 2 clicks, first on setings bar torch application. is possible put application in charms bar itself?, user can launch application single click. or there way trigger external keys?. like, "long press on volume key launch application", or "long press on camera button etc..". any highly appreciated :). first, no way launch app in charms bar. you can register event handler hardwarebuttons.camerapressed hardwarebuttons.camerapressed += hardwarebuttons_camerapressed; . note by using hardwarebuttons shold first add reference of mobile extensions if developing uwp apps.

ios - When cell is selected, the backgound color of the button will change and then recorver -

Image
i have customize uitableviewcell , there button within it, when set background color of button color other default color (which [uicolor whitecolor] ), when cell selected, background color of button change , recover when selection highlight of cell disappear. how happen , keep button's background color when cell selected? i recommend inspecting hierarchy of views you've got table view cells. can done: run app on simulator -> click "debug view hierarchy" (see 1st image attached) -> play around inspector (see 2nd image attached). update: after digging while got following (please see 3 screenshots below explaining situation): as can see, there's internal call clears background colors of cell's subviews named _setopaque:forsubview: having said, if want ensure background color of button remains same should implement selection mechanism of cell in following way: - (void)setselected:(bool)selected animated:(bool)animated { [su...

Java String transform to char array -

i want ask how "".value transform char array ,thanks public final class string implements java.io.serializable, comparable<string>, charsequence { /** value used character storage. */ private final char value[]; /** * initializes newly created {@code string} object represents * empty character sequence. note use of constructor * unnecessary since strings immutable. */ public string() { this.value = "".value; } you should tell, jre implementation looking at, when cite source code. however, code quite simple: "" refers string constant initialized jvm since inside string() constructor may called application code, not jvm internal initialization, may safely refer "" constant like other string object, has value field, inside string constructor, no problem access private field , copy reference; equivalent to string tmp = ""; this.value = tmp.value; since both, "" constant , instan...

gtfs - How can I rearrange the table in MySQL? -

Image
there table stop_times.txt format (gtfs) like: +------------------+---------------+ | trip_id | stop_sequence | +------------------+---------------+ | 4503599630773892 | 0 | | 4503599630773892 | 1 | | ... | ... | | 4503599630773892 | 27 | | 4503599630810392 | 0 | | 4503599630810392 | 1 | | ... | ... | | 4503599630810392 | 17 | | 4503599631507892 | 0 | | 4503599631507892 | 1 | | ... | ... | | 4503599631507892 | 29 | | ... | ... | +------------------+---------------+ my expecting result is: +------------------+------------+-----------+ | trip_id | first_stop | last_stop | +------------------+------------+-----------+ | 4503599630773892 | 0 | 27 | | 4503599630810392 | 0 | 17 | | 4503599631507892 | 0 | 19 | | ... ...