Posts

Showing posts from February, 2014

html - Javascript not showing in browser -

i new javascript. reading book following code. somehow, not showing date expect in browser regardless of whether use safari, or chrome or explorer. can what's wrong it? have tried moving javascript body etc... still same problem. thanks <html> <head> <title>my first web testing</title> </head> <body> testing <script type="text/javascript> var today = new date(); var dd = today.getdate(); var mm = today.getmonth()+ 1; var yyyy = today.getfullyear(); if(dd<10) dd = '0' + dd; if(mm<10) mm = '0' + mm; today = dd + '-' + mm + '-' + yyyy; document.write("<b>" + today + "</b>"); </script> </body> </html> you forgot end quotation mark in script declaration. should be <script type="text/javascript">

osx - Cocoa: initWithFrame from a custom view proxy is not being called -

according apple's document creating custom view method should called if you're using custom view proxy in interface builder. if have not created interface builder palette custom view, there 2 techniques can use create instances of subclass within interface builder. first using custom view proxy item in interface builder containers palette. view stand-in custom view, allowing position , size view relative other views. specify subclass of nsview view represents using inspector. when nib file loaded application, custom view proxy creates new instance of specified view subclass , initializes using initwithframe: method, passing along autoresizing flags necessary. view instance receives awakefromnib message. unfortunately, it's not been called in case. has had deal issue? there's new behavior in recent versions of xcode when deploying recent versions of os. in file inspector of nib, see if runtime behavior — instantiation: prefer coder checked. if is, unch...

c# - Linq to SQL query to find partial duplicates -

i have looked @ lots of questions regarding linq sql , duplicates couldn't find leads me in right direction situation. i have view want query return rows have same columna different columnb. myview id columna columnb i can values of columna following t-sql query... select a.columna, count(*) ( select b.columna, b.columnb myview b group b.columna, b.columnb ) group a.columna having count(*) > 1 ..but translate linq sql , return id column well, if possible. any appreciated. nb. asp.net 4.0, c#, linq sql, sql server in use. updated sample data: id, columna, columnb 1, aaa, a100 2, aaa, a100 3, aaa, b200 4, bbb, c300 5, bbb, c300 desired result: id, columna, columnb 1, aaa, a100 2, aaa, a100 3, aaa, b200 (as column same, columnb different. id 4 , 5 not returned columnb values same.) updated 2 somehow created following query part of wanted return columna value. improvements or suggestions on getting id appreciated. list<st...

haskell - Generalizing the functions of a key/value database for both on disk (IO) and pure cases? -

the basic functions of key value database store , fetch , , delete . i'm attempting write typeclass allows return types of these functions either pure or in io can write single engine works both in-memory data.map backed implementation , on-disk implementation. the pure typeclass might this: class purequeryable d fetch :: d -> key -> maybe value insert :: d -> key -> value -> d delete :: d -> key -> maybe d ...whereas io typeclass might this: class ioqueryable d fetch :: d -> key -> io (maybe value) insert :: d -> key -> value -> io d delete :: d -> key -> io (maybe d) i'm attempting combine these two, , suggested (vektorweg1) on #haskell wrote this: class queryable d r fetch :: d -> key -> ??? insert :: d -> key -> value -> ??? delete :: d -> key -> ??? i unsure of write in place of ??? work. ideas? like carl, have doubts utility of well, here goes nothing (n...

sql - Linking integer id with text in Postgres -

i can connect database in postgres. it has table called country 201 rows. consists of 2 fields: country_id (integer) , country_name (text). it has table called school 2233 rows. consists of field called country (integer). field lists integers each represent 1 of 201 country_id country table. if command like: select country school limit 10; i can first 10 country_id 's. possible me translate these 10 country_id 's country_name 's using country table? you can use join achieve this.. i wrote query mysql create table country (id numeric, c_name varchar(20)); insert country values(1,'america'); insert country values(2,'india'); insert country values(3,'britain'); insert country values(4,'greece'); insert country values(5,'china'); create table school (school_name varchar(20), country_id numeric); insert school values ('a',2); insert school values ('b',4); insert school values ...

lambda - Java 8 extract first key from matching value in a Map -

suppose have map of given name, surname pairs , want find given name of first entry in map has surname matching value. how in java 8 fashion. in test case example below put 2 ways it. however first 1 (looking given name of first person surname of "donkey") throw java.util.nosuchelementexception: no value present not safe. the second 1 works not harder read it bit not quite functional. just wondering if here suggest me easier clearer way of achieving using either stream() or foreach() or both. @test public void shouldbeabletoreturnthekeyofthefirstmatchingvalue() throws exception { map<string, string> names = new linkedhashmap<>(); names.put("john", "doe"); names.put("fred", "flintstone"); names.put("jane", "doe"); string keyofthefirst = names.entryset().stream().filter(e -> e.getvalue().equals("doe")).findfirst().get().getkey(); assertequals("john...

android - Strange error when build Phonegap showing Manifest merger failed -

i use phonegap version 5.0.0-0.28.1 , android 5.1.1 api 22 (sdk platform), use latest android sdk build-tools (22.0.1). i configure path android_home set in works path, isn't issue anymore. after create , add platform in android, problem show when build source: $ phonegap build android --release show error: execution failed task ':processdebugmanifest'. manifest merger failed : uses-sdk:minsdkversion 7 cannot smaller version 10 declared in library /users/myname/lalaland/platforms/android/build/intermediates/exploded-aar/android/cordovalib/unspecified/debug/androidmanifest.xml i assume androidmanifest.xml in android must set in * android:minsdkversion="10" * because default xml put min sdk version in 7. edited androidmanifest.xml turn 7 10, still showing error. when use build monitoring script using textwrangler, xml script turn default when min sdk version set in 7. please help, kindly share if have same experience me. in advance ...

ssrs 2012 - MDX with IIF parameter -

i'm tyring discern amount based on parameter. have @clienttype defaulted 'c'. with member [measures].[amount] iif( @clienttype ='c', [measures].[total client amount] , -[measures].[total client amount] ) regardless of changing @clienttype i'm still returning false. try adding in these 2 measures inspect values: with member [measures].[clnttypparam] @clienttype member [measures].[clnttypparamc] iif ( @clienttype = "c" ,"equaltoc" ,"notc" )

sql server - Update/Set ordering? -

i'm curious why following update statement not setting expected: declare @int int set @int = 0; update #jc_temp set num = @int, @int = @int + 1 i expect set first row 0 , update. local variables set first, before fields? the process of doing update on table variable gets assigned repeatedly in same statement referred "quirky update". it's undocumented feature of sql server which, if controlled correctly update rows in order of primary key. i've used on few occasions things running totals in pre-2012. there quite few gotchas, undocumented procedure, intro article ssc http://www.sqlservercentral.com/articles/t-sql/68467/ to answer first question, yes. variables evaluated first. know trial , error, can't point specific article documenting behavior. be warned mentioned above unless right, can't guaranteed of order in updates occur. if you're doing in production system, i'd recommend joining table , using row_number() window f...

What if I need to differentiate 0 from NULL in C++? -

** please don't criticize purpose of code itself. it's pat morin's open data structures book. not first choice, assigned reading/practice. wanted know if there way differentiate, or better way go this. textbook--> http://opendatastructures.org/ods-cpp/ ** ** note: i'm coming java, allowed. code still compiles, "fixes" it** i'm surprised nothing has come before because seems such simple question. perhaps it's buried or i'm not using correct terminology. i have loop goes through data in vector. need return value being searched if it's found. if it's not found? here code. int find(int x) { for(int i=0;i<bag.size();i++){ // if x equal data, return data if (bag[i]==x){ return bag[i]; // ends loop 1 instance found } } // if made far, no match found. return null; } pretty simple. let's 0 1 of valid values might need record , search for. is, returns 0, not "null"...

salt stack - What's wrong with this simple file.managed saltstack configuration? -

from fresh salt stack installation on server , client, goal serve file number inside: server $vim /etc/salt/master ... file_roots: base: - /srv/salt ... $echo 1 > /srv/salt/tmp/salt.config.version $cat /srv/salt/top.sls base: '*': - tmpversion $cat /srv/salt/tmpversion/init.sls /tmp/salt.config.version: file.managed: - source: salt://tmp/salt.config.version - user: root - group: root - mode: 644 client (minion) $vim /etc/salt/minion ... master: <masterhostnamehere> ... i'm using salt '*' state.sls tmpversion apply configuration. don't know how changes applied automatically.. salt doesn't until tell to. means have run salt command on cli when want state applied, or can use salt's internal scheduler or system's cron run job regularly.

How to split array into two arrays in C -

say have array in c int array[6] = {1,2,3,4,5,6} how split {1,2,3} and {4,5,6} would possible using memcpy? thank you, nonono sure. straightforward solution allocate 2 new arrays using malloc , using memcpy copy data 2 arrays. int array[6] = {1,2,3,4,5,6} int *firsthalf = malloc(3 * sizeof(int)); if (!firsthalf) { /* handle error */ } int *secondhalf = malloc(3 * sizeof(int)); if (!secondhalf) { /* handle error */ } memcpy(firsthalf, array, 3 * sizeof(int)); memcpy(secondhalf, array + 3, 3 * sizeof(int)); however, in case original array exists long enough, might not need that. 'split' array 2 new arrays using pointers original array: int array[6] = {1,2,3,4,5,6} int *firsthalf = array; int *secondhalf = array + 3;

watchkit - Apple Watch notification center -

what notification's in notification center called? notifications? how view it: after notification shows up: ignore notification, go watch home screen, go clock app screen, drag top bottom of screen see notification center. we see notification title , alertbody of notification. when click on notification take (static) long notification. what notification called int center? i don't believe have special name, it's notifications. if talking dragging bottom top , you'll see list of glances . however, these have nothing notifications directly (the developer might have these display latest information, might same in notification, they're not directly related)

Xcode auto layout buttons not resizing -

Image
i have looked @ many tutorials , can't seem buttons resize , layout using xcode 6 auto layout. tutorials make sense use views examples. trying build universal soundboard app buttons arranged in attached picture. tried putting buttons in 1 view container still no luck. missing? much select button want constraint on, , command click it's parent view . next, select add new constraint (at bottom of xcode), click "equal widths", click add constraint. select object. double-click on constraint rectangle (not obvious! "edit" takes somewhere else) then @ right hand side of xcode attribute inspector should come up: at multiplier property can make ratio or decimal of percentage value want. if want button 1 fourth of it's parent view , set multiplier 1:4. this might not ideal answer, it's best can offer. hope helps!! luck!

Nose tests for django app in pycharm -

i'm working on django package created using cookiecutter this repository . uses nose tests, script ( runtests.py ) generates settings on fly. works brilliantly. i'd integrate these tests pycharm's test runner. can point nose test plugin @ script, , executes , gets correct test feedback, in way can't usefully identify tests failing when test fails. project on github here . any hints on how integrate 2 nicely?

html5 - How does various iOS versions differ in terms of webapp cache size limit & its response? -

Image
since don't have devices & ios versions available @ hand, it's difficult understand of issues client experiencing on older devices (namely ipad 1 , 2, both running ios 5 [unsure of minor version]). is there documentation on how each of ioses respond webapp reaching it's cache size limit? ( 5mb supposedly? or wrong, might apply web sql database size ) also cache size limit same across devices & ios versions? note: issue client having right @ beginning, it's showing page as if javascript disabled (i've sent message ask if that's case). in event haven't manually disabled it, javascript automatically disabled on webapp because limit exceeded? as far limits goes, there long list of tests conducted suburbia.org.uk using browserstack.com tool. it covers more ios devices (android, windows phones, desktop oses, chrome, firefox, opera, etc.) http://suburbia.org.uk/appcache_limit_tests/html5_application_cache_device_storage_limits...

php - mysqli_fetch_array()/mysqli_fetch_assoc()/mysqli_fetch_row() expects parameter 1 to be resource or mysqli_result, boolean given -

i trying select data mysql table, 1 of following error messages: mysql_fetch_array() expects parameter 1 resource, boolean given or mysqli_fetch_array() expects parameter 1 mysqli_result, boolean given this code: $username = $_post['username']; $password = $_post['password']; $result = mysql_query('select * users username $username'); while($row = mysql_fetch_array($result)) { echo $row['firstname']; } the same applies code $result = mysqli_query($mysqli, 'slect ...'); // mysqli_fetch_array() expects parameter 1 mysqli_result, boolean given while( $row=mysqli_fetch_array($result) ) { ... and $result = $mysqli->query($mysqli, 'selct ...'); // call member function fetch_assoc() on non-object while( $row=$result->fetch_assoc($result) ) { ... and $result = $pdo->query('slect ...', pdo::fetch_assoc); // invalid argument supplied foreach() foreach( $result $row ) { ... and ...

string - C's strtod() returns wrong values -

i'm working on banking terminal program laboratory exercises @ university. what puts me off stride function supposed take user's input of amount transfered, check if fits requirements , if so, returns value provided program. our tutor mad means of securing input, , have call error on kind of inconsistency. value high? error. negative or 0 value? error. number more precise 0.01? error. non-digit-non-dot characters in input? error. due that, function definately overcomplicated, yet i'm fine that. drives me wall fact, both atof() , strtod() functions reads numbers in somehow wrong way. long double take_amount() { char input[21]; bool success, correct; unsigned long int control1; long double amount, control, control2, control3; { success = true, correct = true; printf("\t\tamount:\t\t"); success = scanf("%20[^ \t\n]c", input); __fpurge(stdin); correct = check(input, 'b'); ...

javascript - sailsjs "Error: There was an error turning the model into an object." -

sailsjs 0.11, node 0.12.4. passport 0.2.1 , passport-local 1.0 using sailsjs blueprint routes see what's going on. project simple blog, , tried looking @ user profile in blueprint route /user/4 show me userid 4. message result. any ideas caused this? note: haven't been anywhere near sails/waterline source. full error message /home/vagrant/nodeprojs/<project>/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/defaultmethods/toobject.js:59 throw err; ^ error: there error turning model object. @ new module.exports (/home/vagrant/nodeprojs/<project>/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/defaultmethods/toobject.js:56:15) @ prototypefns.toobject (/home/vagrant/nodeprojs/<project>/node_modules/sails/node_modules/waterline/lib/waterline/model/index.js:30:14) @ prototypefns.tojson (/home/vagrant/nodeprojs/<project>/node_modules/sails/node_modules/waterline/lib/waterline/model/in...

remap ctrl-k in atom doesn't work -

i have following entries in keymap.cson: '.workspace': 'ctrl-k': 'core:move-up' 'ctrl-j': 'core:move-down the ctrl-j mapping works, ctrl-k doesn't. isn't possible remap ctrl-k ? the following works: 'atom-text-editor': 'ctrl-k': 'core:move-up'

html - wordpress slider not working -

i have html page in there slider. here's html code <div data-src="images/page1_slide01.jpg"> <div class="camera_caption fadein"> <div class="container"> <div class="camera-text bg01"> <div class="camera-text_inner"> <h2>“black horse”</h2> <h5>by mark oswald</h5> <p>ret iusto odio dignissim qui blandit praesent luptaum zzelenit augue duis dolore te feugait nulla facilisi. typi non habent claritatem insita</p> <a class="btn" href="#">more</a> </div> </div> </div> </div> </div> i trying convert page wordpress. <div data-src="<?php bloginfo('template_url'); ?>/images/page1_slide01.jpg"> <div class="ca...

javascript - Add two extra options to a select list with ngOptions on it -

i have bunch of select lists , i'm trying add "none" , title option them. code looks so: <select ng-options="value.name value in values" ng-model="selection"> <option value="" disabled>{{title}}</option> <option value="">none</option> </select> for right now, cannot add them data trying find way working. when load them first time, "none" option not there. title there , works intended, seems cannot add 2 blank entries select list. the easiest way have "none" option added data it's not possibility me. there proper way achieve want? that's correct, can have 1 hard-coded element. <option ng-repeat> can technically done, method cleanly supports binding strings, kludgey bind objects, you're doing. you can't add "none" data, can next best thing: prepend array ng-options iterating across, using filter: app.filter('add...

java - Add horizontal scroll to JFreeChart -

this question has answer here: jfreechart candlestick chart weird behaviour on drag 1 answer as title says: how can add horizontal scrollbar candlestick chart created jfreechart? want user able scroll horizontally through chart when zoomed in. right zooming in works can't move left or right. tried putting chartpanel jscrollpane that's chartpanel, not chart itself. custom chartpanel constructor: public mychartpanel(jfreechart chart) { super(chart); linedrawingcontrollers =new eventlistenerlist(); this.setmousezoomable(false); this.addmouselistener(mousehandler); this.addmousemotionlistener(mousehandler); this.setpopupmenu(null); this.linepopupmenu=new jpopupmenu(); linepopupmenulistener=new linepopupmenulistener(); } my custom jpanel create chart , chartpanel , put chartpanel inside jscrollpane: public mycandlestickchart()...

AngularJs (ngResource ) : Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/ -

i want use ngresource http have error : error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/ $injector/modulerr?p0=myapp&p1=%5b%24injector%3anomod%5d%20 here code : <!doctype html> <html> <head> <meta charset="iso-8859-1"> <title>angular ngresource</title> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-resource.min.js"></script> <script> var myapp = angular.module('myapp', ['ngresource']); myapp.factory('userservice',['$resource', function ($resource) { return $resource('http://jsonplaceholder.typicode.com/users/:user',{user: "@user"}); }]); myapp.controller('produitsctrl', function($scope, $http,userservice) { $scope.users = userservice.query(); ...

javascript - jQuery show/hide based on select dropdown not working as expected -

i'm attempting show/hide <div> 's based on values chosen select drop-down menu. html <select id="selreport"> <option value="report one">report one</option> <option value="report two">report two</option> <option value="report three">report three</option> <option value="report four">report four</option> </select <div id="report one" class="description"> <p>...</p> </div> <div id="report two" class="description"> <p>...</p> </div> i'm using following jquery snippet hide <div> 's , show them based on selected in drop-down menu: jquery $('.description').hide(); $('#selreport').change(function () { $('description').hide() $("[id='" + this.value + "'").show(); }); when new option selec...

java - Local changes due to svn switch -

this question has answer here: how restore last saved code in eclipse? 2 answers i had local changes in workspace , 3 weeks of work , last tryed switch "svn switch". i dont know happens workspace project old version of project 1 in trunk tryed switch to. again switched tag , same thing happened. issue did multiple svn switches , still hope can undo these changes , project local changes. the ide eclipse project java/flex , svn you should able restore changes local history right clicking on project , selecting restore local history. team plugin lets view history. open team view --> history --> local revisions. also, check out, how restore eclipse history: https://wiki.eclipse.org/faq_where_is_the_workspace_local_history_stored%3f your eclipse history should available in workspace @ folder: .metadata/.plugins/org.eclipse.core.resource...

c++ - Using System::AnsiString class -

i trying import code following answer: get full running process list ( visual c++ ) bool findrunningprocess(ansistring process) { /* function takes in string value process looking st3monitor.exe loops through of processes running on windows. if process found running, therefore function returns true. */ ansistring compare; bool procrunning = false; handle hprocesssnap; processentry32 pe32; hprocesssnap = createtoolhelp32snapshot(th32cs_snapprocess, 0); if (hprocesssnap == invalid_handle_value) { procrunning = false; } else { pe32.dwsize = sizeof(processentry32); if (process32first(hprocesssnap, &pe32)) { // gets first running process if (pe32.szexefile == process) { procrunning = true; } else { // loop through running processes looking process while (process32next(hprocesssnap, &pe32)) { // set ansistring instead of char[] make compare easier compare = pe32.szexefile; ...

scala - Akka Actor restarts after exception during Unit test -

my actor looks import akka.actor.status.failure import akka.actor.{actor, actorlogging, props} import akka.event.loggingreceive object runner { def props(race: race) = props(classof[runner], race) } class runner(race: race) extends actor actorlogging { override def receive: receive = loggingreceive { case start => sender ! "ok" log.debug("running...") thread.sleep(10) throw new runtimeexception("marathonrunner tired") case failure(throwable) => throw throwable case stop => log.debug("stopping runner") context.stop(self) } } and test looks import akka.actor.{terminated, actorsystem} import akka.testkit.{implicitsender, testactorref, testkit} import org.scalatest._ import scala.concurrent.duration._ class runnerspec extends testkit(actorsystem("testsystem")) wordspeclike mustmatchers implicitsender { "must fail exception" in { val runner...

java - Why any class marked final won't allow compiler to devirtualise method call -

in this article , surprised read: i imagined having final method meant compiler compile calls using invokespecial instead of invokevirtual , "devirtualize" method calls since knows sure @ compile-time transfer execution. doing @ compile time seems trivial optimization, while leaving jit far more complex. no, compiler doesn't this. it's not legal it! doing @ compile time seems trivial optimization, since knows sure @ compile-time transfer execution. what's reason doesn't happen? posting the answer ejp pointed out in comments : java has separate compilation model, forbids cross-file optimization (with notable exception, compile-time constant inlining). if change method non-final, , not recompile clients? if runtime bytecode replacement (search "instrumentation")? side note: engineer, expectations should function of tool. not c++. can afford interpreter, bytecode optimization premature optimization. keep mind obj...

.net - Solution for common async pattern: Start many, await first, cancel the rest -

i'm looking pattern: let startmanyawaitfirstcancelrest (n:async<'t> list) : async<'t> = // start n asyncs, // return result of first finish , // cancel rest. something this? open system open system.threading open system.threading.tasks let run (asyncs: list<async<'t>>): async<'t> = let cts = new cancellationtokensource() let tasks = asyncs |> list.map (fun -> async.startastask(a, cancellationtoken = cts.token)) async { let! t = async.awaittask ((task.whenany tasks).unwrap()) cts.cancel() return t }

java - what is Object... in method arguments and how can I use it? -

this question has answer here: java, 3 dots in parameters 8 answers i want use method in java. prototype defined below: public void fragmentrequestaction(fragment fragment, int requestid, object... objects) i not know object... how can pass such items method , how can use them? the object... takes non-primitive type , @ number. in java called variable length argument. it means may call fragmentrequestaction() method - fragmentrequestaction(fragment, 345); //no object here fragmentrequestaction(fragment, 345, someobj); fragmentrequestaction(fragment, 345, someobj1, someobj2); fragmentrequestaction(fragment, 345, someobj1, someobj2, someobj3); variable length argument intruded java 5. there rules remember while constructing function variable length arguments. see code snippet - public void meth ( int... a) // valid public void meth (doubl...

c# - How do I check if one of the lines already exist in the text file? -

string filename = ""; private void opentoolstripmenuitem1_click(object sender, eventargs e) { openfiledialog thedialog = new openfiledialog(); thedialog.title = "open text file"; thedialog.filter = "txt files|*.txt"; thedialog.initialdirectory = @"c:\"; if (thedialog.showdialog() == dialogresult.ok) { lines = file.readalllines(recentfiles); filename = thedialog.filename; (int = 0; < lines.length; i++) { recentfiles = new streamwriter(recentfiles, true); recentfiles.writeline(thedialog.filename); recentfiles.close(); items = file .readlines(recentfiles) .select(line => new toolstripmenuitem() { text = line ...

java - SimpleDateFormat API displays wrong Date -

tried formatting few dates using simpledateformat api string[] dates={"18-01-2015","9-02-2015","21-03-2015"}; for(string s:dates){ simpledateformat format=new simpledateformat("dd-mm-yyyy"); date date=format.parse(s); system.out.println(date); } output: sun jan 18 00:00:00 ist 2015 fri jan 09 00:00:00 ist 2015 wed jan 21 00:00:00 ist 2015 you notice dates displays jan instead of feb/mar. you want dd instead of dd when construct simpledateformat . dd means "day of year", not "day of month". every time simpledateformat looks it's doing wrong thing, should consult documentation , check pattern text really, - particularly capitalization. (there other things can go wrong of course - i've got blog post common ones.)

Use both JavaFx + Acitivity on Android -

so, in project, i'm merging few pieces of code, written earlier, 1 application. have : some android activities (i.e. maps activity, login activity) some javafx controls / forms (used before on windows client). now, reuse javafx forms on android application, still able load previous android activities on button click or sth. is there way, achieved ? greetings if want merge javafx , android projects, should have @ javafxports project. you developing javafx project deployed both in desktop , on mobile platforms. for that, need include 1 single plugin on build.gradle: apply plugin: 'org.javafxports.jfxmobile' for starters, may consider using gluon's plugin netbeans, create javafx project can add sources: add existing javafx sources main folder, , add android activities android folder. you have adapt android activities run on javafx thread fxactivity.getinstance() . have @ post sample of that. you may have @ gluon charm down library, c...

Check string null in any better way C# -

a method accepts 7 string parameters, , need checked null basic way of them !string.isnullorwhitespace(param1) , likewise there better or smarter way ? also, may wrap parameters in object if helps ! you can pass string list , check this: if(list.all(x=>string.isnullorwhitespace(x))) { }

c# - Change List externally while being iterated -

i have following code: private static list<string> mylist; static void main() { mylist = new list<string>(); var websocketclient = new websocket("wss://ws.mysite.com"); websocketclient.messagereceived += iteratemylist; var updatelisttimer = new timer(); updatelisttimer.elapsed += updatemylist; console.readline(); } public static void iteratemylist(object sender, eventargs e) { foreach (var item in mylist) { //do item } } public static void updatemylist(object sender, eventargs e) { // add new items , remove items mylist. } what happens when timer tick , new websocket message events collide? iteratemylist() iterating mylist , updatemylist() updating @ same time. will exception? when attempt insert during iteration, raise exception , error saying attempting "read or write protected memory". to sol...

ios - Retain Cycles for Blocks Inside of Blocks -

do have continuously declare weak references break retain cycles blocks inside of blocks? __weak typeof(self) weakself = self; [self setmyblock:^(id obj, nsuinteger idx, bool *stop) { typeof(self) strongself = weakself; [strongself dosomething]; [strongself setmyblock:^(id obj, nsuinteger idx, bool *stop) { //do need create weak reference strongself block? [strongself dosomething]; }]; }]; i'm afraid so. [strongself setmyblock:<inner block>] cause self retain inner block. if inner block has strong reference self , that's cycle. fact strongself variable assigned from __weak qualified variable not make difference. as other users mentioned, can use original weakself rather creating new one. reason create strongself reference in block otherwise self might deallocated while block running. strongself either end nil (if self deallocated before strongself assigned, causes no harm) or else self not deallocated w...

javascript - Why does the NVD3.js line plus bar chart example render two charts instead of one? -

i put following test code based on example code provided nvd3 team @ library's official website. reason, see 2 charts drawn on page: 1 has proper labels on 2 y-axes , proper labels on x-axis while second more compressed vertically, not have labels on y-axes , has appears data array indices on x-axis. the code below assumes latest versions of both d3 , nvd3 although behavior still manifests when using older version of d3 website links to. thanks in advance , insight problem. <!doctype html> <html lang="en"> <head> <meta charset="utf-8"/> <title>line + bar chart | nvd3.js</title> <link rel="stylesheet" href="nv.d3.css"/> <style> #chart svg { height: 400px; } </style> </head> <body> <div id="chart"> <svg></svg> </div> <script src="d3.js"></script> ...

php - Cakephp not redirecting after sending email through CakeEmail -

in cakephp 2.x, 1 of controller actions, trying send email user's every time new record created. updated drmonkeyninja's suggestions: // newsletterscontoller.php public function add() { if($this->request->is('post')) { $this->newsletter->create(); if($this->newsletter->save($this->request->data)) { $this->session->setflash(__('your newsletter has been submited.')); $this->redirect(array('action' => 'view', $this->newsletter->id)); } else { $this->session->setflash(__('unable add post.')); return $this->redirect(array('action' => 'add')); } } } // newsletter.php public function aftersave($created, $options = []) { parent::aftersave($created, $options); if ($created === true) { $newsletter = $this->findbyid($this->id); // users email address. $emails = classregistry::init('user')->find( ...

javascript - Strip off the path of the href after the file is loaded into the browser -

when load web page , view source, can see <link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap.min.css"/> if type in www.example.com/css/bootstrap/bootstrap.min.css in address bar of browser, can see whole css file. is there way can strip off path of href after file loaded browser, css/bootstrap/bootstrap.min.css becomes bootstrap.min.css ? any appreciated. thanks is there way can strip off path of href after file loaded browser, css/bootstrap/bootstrap.min.css becomes bootstrap.min.css ? no. browsers implement "view source" re-requesting page server (which may or may not come cache) , showing text, exactly; don't have opportunity run client-side code remove link or style elements (and have client-side code, because naturally can't server-side , still have page render correctly normal requests). even if run client-side code before "view source" shown, can't css anyway...

Better sorting technique for almost sorted list -

which best sorting technique sorted list , why? list of many elements found quick sort helpful.but sort have better running time when sorted? insertion sort has linear performance when list sorted. check : http://www.sorting-algorithms.com/nearly-sorted-initial-order insertion places element @ correct position considering relative ordering hence need n - 1 iterations. other sorts quick sort again tries sort sorted segment again unaware of relative ordering (ie if segment sorted).

linq - Count string appears in list and copy along with number of time it appear into strongly type list- c# -

i have list of string containing different words , of words repeating. want copy string list , save type list string , no of times appears in list. need use linq. model class public class wordcount { public wordcount() { } public int id { get; set; } public string word { get; set; } public int counter { get; set; } } my current list private list<string> _wordcontent = new list<string>(); new type list ????????? public void countwordinwebsitecontent() { var counts = _wordcontent .groupby(w => w) .select(g => new { word = g.key, count = g.count() }) .tolist(); list<wordcount> mywordlist = new list<wordcount>(); var = "d"; } you can create objects of wordcount while projecting grouped result: here using lambda expression syntax: .select((g,index) => new wordcount { ...

code analysis - Using an AdHocWorkspace results in "The language 'C#' is not supported." -

using rc2 of microsoft.codeanalysis.csharp.workspaces in vs2015, code throws exception: var tree = csharpsyntaxtree.parsetext(...); var workspace = new adhocworkspace(); var newroot = simplifier.expand(tree.getroot(), compilation.getsemanticmodel(tree, false), workspace, n => true, true, cancellationtoken.none); the exception message "the language 'c#' not supported." what missing make work? you need add reference c# workspaces nuget package . this copy c# dlls output, , let roslyn's mef scanner see language services.

java - Making Distinctions Between Different Kinds of JSF Managed-Beans -

i read article neil griffin making distinctions between different kinds of jsf managed-beans , got me thinking distinction between different beans in own application. summarise gist: model managed-bean: type of managed-bean participates in "model" concern of mvc design pattern. when see word "model" -- think data. jsf model-bean should pojo follows javabean design pattern getters/setters encapsulating properties. backing managed-bean: type of managed-bean participates in "view" concern of mvc design pattern. purpose of backing-bean support ui logic, , has 1::1 relationship jsf view, or jsf form in facelet composition. although typically has javabean-style properties associated getters/setters, these properties of view -- not of underlying application data model. jsf backing-beans may have jsf actionlistener , valuechangelistener methods. controller managed-bean: type of managed-bean participates in "controlle...