Posts

Showing posts from September, 2011

java.lang.NullPointerException in the Deck class -

public class deck { public static final int cardsofdeck = 112; private card[] cards = new card[cardsofdeck]; public static void main(string[] args){ deck deck = new deck(); deck.load(); deck.show(); } public void show(){ for(card c: cards) system.out.println(c.tostring()); } public void load(){ int j = 0; (j = 0; j < 2; j++) { int = 0; (color c : color.values()) { (value v : value.values()) cards[i++] = new card(c, v); } } } } public class card { private color color; private value value; public card(color c, value v) { color = c; value = v; } public string tostring() { return color + " " + value

javascript - Backbone js router - better way to orginize views -

here way orginize 4 views , 4 links backbone router var linksrouter = backbone.router.extend({ routes:{ "classes" : "classes", "profile" : "profile", "reportcard" : "reportcard", "newclasses" : "newclasses", }, classes : function(){ $(".viewable").hide(); $(".clickable").removeclass("active"); $("#classes-view").show(); $("#classes-link").addclass("active"); }, profile : function(){ $(".viewable").hide(); $(".clickable").removeclass("active"); $("#profile-view").show(); $("#profile-link").addclass("active"); }, reportcard : function(){ $(".viewable").hide();

how to get AABB Bounding Box from MatrixTransform Node in OpenSceneGraph -

the structure here is osg::matrixtransform | osg::geode | several drawables how can aabb bounding box osg::matrixtransform ? there's not direct method, matrixtransform exposes getter bounding sphere, boundingbox available on drawable class , derivatives. with scene graph structure collect drawables , expand bounding box include every drawable's bb this method . give bb includes of others in drawables coordinates. if need world coords, you'll have apply matrixtransform (and other transformation might have along nodepath root of graph)

python - Connecting Django web app database to postgresql on Pythonanywhere -

i want connect django web app database postgresql database have on pythonanywhere paid account. before coding anything, wanted talking each other. settings.py database section django app. i'm running python 3.5 , django 1.9. databases = { 'default': { 'engine': 'django.db.backends.postgresql', 'name': '[mydatabasename]', 'user': '[myusername]', 'password': '[mypassword]', 'host': 'xxxxxxxx-xxx.postgres.pythonanywhere-services.com', 'port': '10130', } } the host , port we're both provided pythonanywhere.com site under tab database , postgres. did create database, username, , password on postgres console. i created checkedb.py script found check if connection postgres database works. from django.db import connections db_conn = connections['default'] try: c = db_conn.cursor() except operationalerror: connected = false else:

regex - Invalid regular expression HTML Pattern -

this regex: pattern="[^\!\#\$\%\^\&\*\'\|\"]{8}" pattern="[^!#$%^&*'|"]{8}" how invalid in html input tag? want symbols restricted in textbox <input placeholder="something" type="text" required autofocus ng-model="somedata" pattern="[^\!\#\$\%\^\&\*\'\|\"]{8}"> i think should pattern=\"[^!#$%^&*'|"]{8}\" you should escape literal double quote outside [] instead of inside. demo: https://regex101.com/r/up5pc6/1

linux - How to make a loop with multiple columns in shell? -

i have file 3 columns (id number, x, y) ifile.txt 1 32.2 21.4 4 33.2 43.5 5 21.3 45.6 12 22.3 32.5 32 21.5 56.3 43 33.4 23.4 44 23.3 22.3 55 22.5 32.4 i make loop on column 2 , 3 read for x=32.2 , y=21.4; execute fortran program x=33.2 , y=43.5; execute same program , on though following script working, need in efficient way. s1=1 #serial number s2=$(wc -l < ifile.txt) #total number loop while [ $s1 -le $s2 ] x=$(awk 'nr=='$s1' {print $2}' ifile.txt) y=$(awk 'nr=='$s1' {print $3}' ifile.txt) cat << eof > myprog.f ... take value of x , y ... eof ifort myprog.f ./a.out (( s1++ )) done kindly note: myprog.f written within cat program. example, cat << eof > myprog.f .... .... take value of x , y .... .... eof simple way read file in bash while read -r _ x y; echo "x $x, y $y" # fortran code execution done < ifile.txt x 32.2, y

MobileFirst 7.1 OSX Eclipse server url setting -

Image
i using eclipse juno mfp 7.1 in mac. i put server address in configure build , deploy target http://example.com:80 , use run > run on mobilefirst development server . in windows, updates worklight.plist , wlclient.properties files new values server url , port number, in mac values remains mymacbookpro.local server url , port number 10080 . migrated eclipse mars problem remains same: this working me using eclipse mars.2 , ibm mobilefirst platform studio 7.1.0.00-20160419-1518, on mac. created new "test" project "test" application , added iphone environment. selected run > run on mobilefirst development server this shows "mbp-idan.local" selected run > build settings , deploy target, , changed values follows: selected run > run on mobilefirst development server opened test\iphone\native\worklight.plist , see following: <dict> <key>protocol</key> <string>http</string> <key

c# - httppost to asp net handler -

i wish pass object data asp.net handler aspx.cs , cross on project. comment appreciated. //project (abc.aspx.cs) try { string ltq_str = new javascriptserializer().serialize(ltq); int t = -1; string result = gnuse.httpsend("http://localhost/is/tqueuedtcscontroller/integrationservice?tqueuedtcslist", httputility.urlencode(ltq_str), ref t, "get"); if (!result.equals("success")) { grn.delete(convert.toint32(hfid.value), false); lblerror.text = "inventory integration failed: " + result; } } for project b (tqueuedtcscontroller.cs) public actionresult integrationservice(string tqueuedtcslist) { try { list<tqueuedtcintegration> listoftqueuedtc = jsonconvert.deserializeobject<list<tqueuedtcintegration>>(tqueuedtcslist); // string[] value_arr = tqueuedtc.productname.split(new cha

javascript - How do I return the response from an asynchronous call? -

i have function foo makes ajax request. how can return response foo ? i tried return value success callback assigning response local variable inside function , return one, none of ways return response. function foo() { var result; $.ajax({ url: '...', success: function(response) { result = response; // return response; // <- tried 1 } }); return result; } var result = foo(); // ends being `undefined`. -> more general explanation of async behavior different examples, please see why variable unaltered after modify inside of function? - asynchronous code reference -> if understand problem, skip possible solutions below. the problem the a in ajax stands asynchronous . means sending request (or rather receiving response) taken out of normal execution flow. in example, $.ajax returns , next statement, return result; , executed before function passed success callback

asp.net mvc - Angular 2: how to get params from URL without using Routing? -

i'm trying url parameters component search using externsre service. read can use angular2 routes , params using routeparams don't think that's need because first page of angular application razor view. i'll try explain better. url looks like: http://dev.local/listing/?city=melbourne i'm loading root component in razor view like: <house-list city = "@request.params["city"]"></house-list> then on root component have: export class appcomponent implements oninit { constructor(private _cityservice: cityservice) { } response: any; @input() city: any; ngoninit() { this.gethouses(); } gethouses() { this.__cityservice.gethousesbycity(this.city) .subscribe(data => this.response = data); } } so expecting 'city' in component gets string passed razor view it's undefined. what doing wrong? there way of getting params without using routing? if not, rig

php - data not save to mySQL Hosted DB -

i want save data android app mysql database in server. make code php.. when run php file data saved db.. run form android application. data not save db. save code in android public void loadsave() { string mydataurl = "http://xxxxxxxxxx/savedata.php"; //string type = params[0]; try { string longi = "aaa"; // double.tostring(location.getlongitude()); string lati = "aare";//double.tostring(location.getlatitude()); string user = "a"; string lisence = "b"; string date = "c"; url url = new url(mydataurl); httpurlconnection httpurlconnection = (httpurlconnection) url.openconnection(); httpurlconnection.setrequestmethod("post"); httpurlconnection.setdooutput(true); httpurlconnection.setdoinput(true); outputstream outputstream = httpurlconnection.getoutputstream(); bufferedwriter buffere

Executing Arc Program in Python -

i have wrote arc program use turtleworld execute. result right. in serious issue, can reduce code & can explain me code have wrote. didn't concept. program in exercise session of book from swampy.turtleworld import * world = turtleworld() bob = turtle() def arc(t=bob, r=50, angle=360): arc_length = 2 * 3.14 * r * angle / 360 n = int(arc_length / 3) + 1 step_length = arc_length / n step_angle = float(angle) / n in range(n): fd(t, step_length) lt(t, step_angle) arc() wait_for_user()

laravel - ubuntu terminal: showing blank -

i run following command set path while installing laravel source ~/.bashrc after command nothing shown on ubuntu terminal. cursor blinking. do? the purpose of ~/.bashrc file provide place can set variables, functions , aliases, define prompt , define other settings want use every start open new terminal window. depending on contains inside .bashrc file, may give output or nothing @ all. if want check whether bin directory of laravel added path variable or not, can check running echo $path .

xml - PHP return specific number of nodes? -

if have large xml file format: <person> <attribute>value</attribue> </person> <person> <attribute>value</attribue> </person> <person> <attribute>value</attribue> </person> goes on hundreds of thousands of <person> records.... how can i, using php, echo out file/return 'person' 1-10, 11-20, etc.. i have found ton of examples (xpath, etc..) returning nodes or node subsets, no examples of returning specific range of nodes. my specific file has hundreds of thousands of <person> nodes. want output in xml format <person> s 1-50,000, 50,001-100,000, etc... turned out simple. couldn't find specific example online, managed piece few different examples needed: <?php $xml = simplexml_load_file('somexmlfile.xml'); $result = $xml->xpath('/enterprise/person[position()>=1 , position()<=10000]') ; while(list( , $node) = each($result)

how to get String by spliting url in android? -

i have google play store url " https://play.google.com/store/apps/details?id=com.apusapps.launcher&hl=en " url have store"com.example.launcher" in seperate variable , compare package name "com.example.launc" if compare have send json request .how can try this: string s = "https://play.google.com/store/apps/details?id=com.apusapps.launcher&hl=en"; string s2 = s.substring(s.indexof("=")+1, s.indexof("&")); toast.maketext(this,"milad: "+s2,toast.length_long).show();

c++ - The #if elif directives not working as desired -

i trying test condition using if elif not getting desired results. please me in identifying doing wrong? #include <iostream> using namespace std; #define a(t1)(t1+50) #define b(t2)(t2+100) int main() { union gm { int t1; int t2; }; gm c; cout <<"enter tokens earned in game 1: "<<endl; cin>>c.t1; int x=c.t1; cout <<"enter tokens earned in game 2: "<<endl; cin>>c.t2; int y=c.t2; int m= a(x)+100; int n= b(y)+50; int p; p=m+n; cout <<p<<endl; #if(p<500) cout <<"points earned less"<<endl; #elif (p>500 && p<1500) cout<<"you can play game 1 free"<<endl; #elif (p>1500 && p<2500) cout<<"you can play game 1 free"<<endl; #elif p>3000 cout<<"you can play game 1 , game free"<<endl; #endif return 0; } w

Using globs in Perl replace one liner in TCL script -

i want run 1 perl 1 liner in tcl script below: exec perl -i -pe {s/substring/replacing_string/g} testfile; this works fine. but, if want modify files below: exec perl -i -pe {s/substring/replacing_string/g} *; it gives me error message: can't open '*': no such file or directory. while executing exec perl -i -pe {s/substring/replacing_string/g} *; i tried bracing '*', did not solve problem. requesting help... assuming files a , b , , c present in current working directory, executing echo * in shell prints a b c . because shell command evaluator recognizes wildcard characters , splices in list of 0 or more file names wildcard expression found. tcl's command evaluator not recognize wildcard characters, passes them unsubstituted command invoked. if command can work wildcards so. exec command doesn't, means pass wildcard expression shell command named command string. testing this, get % exec echo * * because asked shell exe

ios - why should .pbxproj file be treated as binary in version control systems? -

in few places been mentioned .pbxproj file should committed/imported binary in cvs or git. looks script file in text format. reasons behind suggestion should treated binary? as mentioned here , pbxproj not mergeable, being complex property list managed json. the usual setting in .gitattributes : *.pbxproj -crlf -diff -merge as explained here : this prevents git trying fix newlines, show in diffs, , excludes merges. the other approach is: *.pbxproj binary merge=union as documented her e, didn't work well. the problem braces become out of place on regular basis, made files unreadable. true tho work of time - fails maybe 1 out of 4 times.

nhibernate - Component referencing an Entity. not being loaded -

i have following mapping, issue emailtemplate not being loaded eagerly , being set null when retreiving user. can guide me or perhaps refer me material. spent long hours searching , nothing yeilded. usermap public usermap() { id(x => x.id); component(x => x.state, y => { y.map(x => x.name); y.map(x => x.surname); y.references(x => x.emailtemplate).not.lazyload(); }); } edit: emailtemplate public class emailtemplate:entity { public virtual string subject { get; set; } public virtual string body { get; set; } public virtual icollection<user> users { get; set; } } emailtemplatemap public emailtemplatemap() { id(x => x.id); map(x => x.subject); map(x => x.body); hasmany(x => x.users).inverse(); } state public class state : valueobject<state> {

android - Setting background color of a button changes the size of button -

i creating alert dialog on clicking imageview .code given below: imgeditstatus.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { alertdialog.builder builder = new alertdialog.builder(profileactivity.this); inflater = (layoutinflater) getapplicationcontext().getsystemservice(context.layout_inflater_service); view dialogview = inflater.inflate(r.layout.dialog_edit_status, null); builder.setview(dialogview); dialog = builder.create(); dialog.show(); final edittext edtstatus = (edittext) dialogview.findviewbyid(r.id.editstatus); button btnok = (button) dialogview.findviewbyid(r.id.btnok); // btnok.getbackground().setcolorfilter(getresources().getcolor(r.color.orange_color)), porterduff.mode.src_atop); btnok.setonclicklistener(new view.onclicklistener() {

android - Combine json and make arraylist<object> -

i have json want combine data 1st object 2nd object { "viewid": { "56": { "viewid": "56", "name": "hi", "param": "value" }, "88": { "viewid": "88", "name": "hi2", "param": "value2" } }, "que": [ { "rid": "123", "viewid": "88", "count": 0 }, { "rid": "456", "viewid": "56", "count": 0 } ] } basically making arraylist, how can add viewid data in que. want merge json in following way: { "que": [ { "rid": "123", "viewid": "88

amazon web services - Installing JavaScript AWS SDK for NativeScript -

i'm trying use aws-sns in nativescript. aws sdk available javascript.can know how install aws sdk nativescript. i tried installing aws-sdk javascript on node.js. reference link " https://www.npmjs.com/package/aws-sdk ". because of below code require("aws-sdk") in nativescript error saying failed find module: "crypto" coming.with bit of search in internet, found crypto module support not added in nativescript. now i'm wondering there other ways. thanks in advance. as nativescript not (yet) "polyfill" crypto module hard thing. searching code references crypto , you'll find there's not many uses , uses not advanced. means should able substitute node module crypto crypto-js works in nativescript environment. you might need fork aws sdk codebase , substitute calls node crypto module calls corresponding methods in crypto-js. unfortunately not share same api. if you're running webpack (or it) should a

TFS 2015 on-prem licensing issue on REST API -

we have upgraded our tfs 2012 tfs 2015 update 1 , use new tfs rest api retrieve tests cases/plans instance. so made quick test browser using following url , went : http://.../defaultcollection/_apis/projects?api-version=1.0 but when tried test plans in particular using url : http://.../defaultcollection/projectxyz/_apis/test/plans?api-version=1.0 i obtained following error : {"$id":"1","innerexception":null,"message":"tf400409: not have licensing rights access feature: web-based test case management","typename":"microsoft.teamfoundation.server.core.missinglicenseexception, microsoft.teamfoundation.server.core, version=14.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a","typekey":"missinglicenseexception","errorcode":0,"eventid":3000} so how activate "license" ? ok problem solved following following instructions : http://www.alexanderva

playframework 2.0 - Play Stage command in windows -

i trying deploy play! application on openshift windows machine. however play "stage" command meant linux based systems, not sure how proceed staging. able connect ssh since play not present there, play command doesnt work there. there way manually "stage" command does. any idea how should proceed? i don't know openshift's deployment cycle, however, can use play dist command prepare standalone version of application stage command, generate zip file, instead writing code target directory.

javascript - I am converting a Bootstrap theme into Wordpress but I cannot get my scripts to load in and run -

here repos on github theme: https://github.com/ryanchrist4/ryanstrap what have done removed script tags head , put them functions.php file using wp_register_script function , wp_enqueue_script function. have looked @ answers other peoples similair questions , tried formatting them still cant scripts run. new web development , new wordpress. also, in header, there script tag calling multiple function error in console says "uncaught reference error. here code in functions.php file: <?php //jquery insert google if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue"); function my_jquery_enqueue() { wp_deregister_script('jquery'); wp_register_script('jquery', "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null); wp_enqueue_script('jquery'); } //launches of scripts below add_action("wp_enqueue_scripts", "launch_scripts"); function launch_scripts()

image - How to make word wrap limited by stringlength in pixels (PHP) -

im trying sign image gd. i have line of text, may this: "this long line of text" if use 60th font, wont fit in image, need how wordwrap now i'm using loop doing word wrap limited number of symbols , adding text image line line.. $words = explode(" ", $text); if (strlen($words[0]) > 20) $output = substr($words[0], 0, 20); else { $output = array_shift($words); while (strlen($output . " " . $words[0]) <= 20) { $output .= " " . array_shift($words); } } $text = $str2 = substr($text, strlen($output)); list($left,, $right) = imageftbbox($font_sizet, 0, $font_path, $output); $width = $right - $left; $leftx = (740 - $width) / 2; $topy = (560 + $i * 30); imagettftext($img, $font_sizet, 0, $leftx, $topy, $white, $font_path, $output); the problem script if first letters going "wwwwwwwwwww", image fit 10 symbols... , if first letters going "llllllllllll" text short. the width of text cant

javascript - Blur event triggered when child gets focus -

i need perform action when , item looses focus basically have this <div tabindex="1"> <h1>title 1</h1> </div> <div tabindex="2"> <h1>title 2</h1> <textarea></textarea> </div> js: $('div').blur((e) => { console.log('blur');}); demo now, when switch between div s works charm, when second div has focus, , click child-textarea blur event triggered. not want, because we're still inside same div. how can fix such blur event triggered when click outside div ? a element has been focus last element focused trigger event 'blur'. may have design hack it...something like: $('div').blur((e) => { settimeout(function() { if(!$('textarea').is(':focus')){ console.log('blur'); } }, 100); }); settimeout important because blur event being trigged in first focus event.

arrays - Malloc doesn't allocate memory in C -

i trying build function gets (**group, *count) count amount of items in array , group pointer array. i must use **group instead of easier *group . edit: requested ive included main() func: int *group1, **pgroup1, count1 = 0, *pcount1; pgroup1 = &group1; printf("please enter size want array be..\n"); scanf("%d", &count1); pcount1 = &count1; buildgroup(pgroup1, pcount1); void buildgroup(int** group, int* count) { int = 0, j = 0, c = *count; group = (int**)malloc(c*sizeof(int**)); if (group == null) { printf("error: out of memory\n"); return 1; } printf("please enter %d items in array...\n", *count); (i = 0; < *count; i++) //going through array items filled. { scanf("%d", &group[i]); (j = 0; j < i; j++) { while (group[i] == group[j]) //checking every item if in group,if in group prompting user re-entering.

C# programmatically form to image -

there 2 forms in program, form a , form b . there button in form a can take screen shot of form b (without start form b ). however, components of form b created in form_load function. i use below code take screen shot of form b generate empty form b image without component of its. bitmap b = new bitmap(1280, 720); formb.manualload(); formb.drawtobitmap(b, new rectangle(0, 0, 1280, 720)); b.save("d:\\test.bmp"); the manuaload() function in below. public void manualload() { formb_load(null, null); formb_resize(null, null); invalidate(); } how can fix problem? i think formb_load(null, null); , formb_resize(null, null); ints hanler load , resize event's next code work bitmap b = new bitmap(1280, 720); var form = new formb(); form.visible = false; form.show(); form.drawtobitmap(b, new rectangle(0, 0, 1280, 720)); form.close(); b.save("d:\\test.bmp");

logical difference between pointers and references in Go and C++? -

regardless of provided convenience of references on pointers such needleless of dereferencing , rules specific use of each , is there logical reason provide 2 language constructs pointers , references or syntactic sugar? (i guess ultimate underlying implementation compiler use same steps references pointers implying/checking rules defined references language.) note : question not rules have defined languages on references such "references not allowed assign null in c++ pointers" etc. you asking 2 questions, if understand correctly what difference between pointers , references why support both data types here goes: a pointer refers location in memory datatype resides. size of pointer fixed, given underlying hardware, 4 or 8 bytes - totally regardless of in fact pointing to. furthermore, pointer can passed function using invalid value - foo(reintepret_cast<int *>(0xdeadbeef) ); . in contrast, reference ensures underlying data valid

Coldfusion number format -

i have code : <cfset n = '222222222222222'> <cfset sum=0> <cfset sum += n> <cfoutput>#sum#</cfoutput> the output : 2.22222222222e+014 is there way can output in normal form '222222222222222' ? the value of n 222222222222222. it's big integer. perform arithmatic operation on big integer, need precision evaluate function . code should below: <cfset n = '222222222222222'> <cfset sum=0> <cfset sum = precisionevaluate(sum + n)> <cfoutput>#sum#</cfoutput>

Passing an ArrayList of address into MapActivity to Display Multiple location into map (android) -

i have list of address(not lat,lng) on other activity. want pass address mapactivity via intent extras , geocode it. how can this? below address data in listview activity viewholder.address.settext(row[4]);//read csv file pass data activity using list or map , use following code lat long address public void getlocationfromaddress(string straddress){ geocoder coder = new geocoder(this); list<address> address; geopoint p1 = null; try { address = coder.getfromlocationname(straddress,5); if (address==null) { return null; } address location=address.get(0); location.getlatitude(); location.getlongitude(); log.i("tag","lat = "+location.getlatitude()) log.i("tag","long = "+location.getlongitude()) } } also check geocoding example

matlab - How to avoid repetition of value in genetic algorithm output? -

i did genetic algorithm code below... lb = [1 1 1 1 1 1 1 1 1 1]; ub = [10 10 10 10 10 10 10 10 10 10]; intcon = 1:10; [x,fval] = ga(fitnessfunction,10,[],[],[],[],lb,ub,[],intcon,options) i output "x" vector of size [1 10] example follows... (my output eg:) x = 4 3 3 2 9 4 4 6 1 1 but need output example, (what want eg:) x = 2 10 3 8 1 6 4 9 5 7 that should not repeated values , outputx should if size [1 10] .... in output repeated values... please can tell me how remove repetition... should set options that,.... please reply.... if output based on minimizing fitness function genetic algorithm have fastest version of fitness function: min(sum(x)-a)^2 with "a" equal sum of n different numbers(ie 1 10 a=55) means every time sum of output different "a", cost of solution increase quadratically. thanks experience can tell crossover between elite members can create large amount of poor solutions

r - ggnetwork scale edge and node (vertex) size independently (different geoms different scales) -

Image
problem: i want use different size scale edges , nodes in network created ggnetwork package. if @ image below may think did since have different sizes in fact edge , node size not scaled independently in plot. both scaled scale_size_area() function towards same maximum (30). if larger nodes edges shrink. guess problem boils down scaling size of different geoms different functions. example how can scale size of nodes scale_size_area(max_size = 30) , size of edges scale_size_continuous(range = c(1,6)) ? example code: #load packages library(network) library(sna) library(ggplot2) library(ggnetwork) #create data #data edges edge_df<-data.frame(group1=c("a","a","b"), group2=c("b","c","c"), connection_strength=c(1,2,3)) #data nodes/vertexes vertex_df<-data.frame(group=c("a","b","c"), groupsize=c(2,3,4)) #create network my_network<-netwo

c# - What to do with a worker thread in the OnStop method in a basic Windows service? -

i have basic windows service performs tasks, executed periodically in endless loop: "executeserviceworkermethods()". starting endless loop via worker thread onstart() method below: onstart(string[] args) { workerthread = new thread(executeserviceworkermethods); workerthread.name = "serviceworkerthread"; workerthread.isbackground = false; workerthread.start(); } now wondering worker thread in onstop() method? my endless loop looks this: private void executeserviceworkermethods() { while (!servicestopped) { work.... while (servicepaused) { thread.sleep(sleeptimemillisecondswhileservicepaused); } thread.sleep(sleeptimemillisecondswhileservicenotstopped); } } remember basic. want able start , stop windows service. it appears code follows code found here pretty closely. you should able use this: protected override void onstop() { // flag

url - Editing using Javascript -

i trying put youtube video iframe, when realized have put "embed" between youtube.com , video id. problem extracting these urls api urls in 1 array , direct url video. is there way me edit url can add embed in between? you can use string.replace var url = "http://www.youtube.com/watch?v=xgsy3_czz8k"; var embedurl = url.replace("watch?v=","embed/"); so if wanted replace in array for (var = 0; < thefeeds.length; i++) { thefeeds[i].link = thefeeds[i].link.replace("watch?v=","embed/"); }

Sql server Distinct Rows -

i have table contains data use sql server 2008 r2 +-----+------+--------+-------+------+-------+ | id | kind | date | price | type | amount| +-----+------+--------+-------+------+-------+ | 525 | 32 |1/1/2016| 240 | 0 | 3000 | | 525 | 32 |1/1/2016| 380 | 1 | 3000 | | 525 | 32 |1/1/2016| 240 | 0 | 4000 | | 525 | 32 |1/1/2016| 380 | 1 | 4000 | +-----+------+--------+-------+------+-------+ how can result? +-----+------+--------+-------+------+-------+ | id | kind | date | price | type | amount| +-----+------+--------+-------+------+-------+ | 525 | 32 |1/1/2016| 240 | 0 | 3000 | | 525 | 32 |1/1/2016| 380 | 1 | 4000 | +-----+------+--------+-------+------+-------+ will not do? select distnct id, kind, date, price, type, amount dbo.yourtable

javascript - Ember.JS do an operation every time the JSON is loaded -

i new ember , in app need add operations depending on json server. this logic: in component.js var foo = []; didinsertelement() { var data = this.get('content'); //then transformations data obtain want , assign foo data.foreach(function(option) { list.push( json.parse(json.stringify(option))) }) for(i = 0; < list.length; i++) { //some logic code list } this.set('foo', sometransformationfromlist); (i = 0; < count; i++) { this.get('content').push(jquery.extend(true, {}, this.get('content')[0])); } for(i = 0; < foo.length; i++) { this.get('content')[i].set('string1', foo[i].text); this.get('content')[i].set('id', foo[i].value); } } so question is, need move logic didinsertelement somewhere else gets executed every time json no first time when component rendered. have tried use serializer or transform don't know if can use of them. can plea

css selectors - Hide all text except for the first letter with CSS? -

is possible hide letters after first letter css? dt:not(::first-letter) { display: none; } you can, css wrong. version below works (at least in chrome). makes dt invisible, , defines overrule first letter make visible again. i tried same display too, doesn't work, expected. visibility: hidden hides content, keeps element in place, while display: none removes flow, , makes impossible sub-elements (the first letter in case) become visible again. i added hover too, can hover letter see rest of dt. dt { visibility: hidden; } dt::first-letter { visibility: visible; } /* hover first letter see rest */ dt:hover { visibility: visible; } hover see rest: <dt>lorum ipsum weird text</dt> <dt>foo bar</dt> a side effect area covered text still claimed. maybe not issue, if need other solution. 1 possibility make font-size of dt 0 too. way, text small claims no space. won't if contains images, of course. si

java - How to hide an SWT composite so that it takes no space? -

Image
i need hide composite (and children inside). setting setvisible(false) keep space of composite. composite outer = new composite(parent, swt.none); outer.setlayout(new gridlayout(1,false)); outer.setlayoutdata(new griddata(griddata.fill_both) ); composite comptohide = new mycomposite(outer, swt.none); comptohide.setlayout(new gridlayout()); comptohide.setvisible(false); here code want. use griddata#exclude in combination control#setvisible(boolean) hide/unhide composite : public static void main(string[] args) { display display = new display(); final shell shell = new shell(display); shell.settext("stackoverflow"); shell.setlayout(new gridlayout(1, true)); button hidebutton = new button(shell, swt.push); hidebutton.settext("toggle"); final composite content = new composite(shell, swt.none); content.setlayout(new gridlayout(3, false)); final griddata data = new griddata(swt.fill, swt.fill, true,

ruby on rails - Create two navigation link for single table in rails_admin gem -

i have 1 table named user . in have 2 type of record : 1) corporation 2) agency field name is_agency?(boolean). if agency true , if corporation false. i want display user table 2 different table corporation , agency in admin side. used rails_admin gem. how can differentiate using "is_agency?" field ? i check rails_admin gem documentation did't find thing this. please me find out solution, save hours. you can crate custom action described here: https://github.com/sferik/rails_admin/wiki/custom-action for example # in lib/rails_admin/agency.rb require 'rails_admin/config/actions' require 'rails_admin/config/actions/base' module railsadmin module config module actions class agency < railsadmin::config::actions::base railsadmin::config::actions.register(self) register_instance_option :controller proc.new @objects = project.where(is_agency: true)

java - android:onclick method doesn't work -

xml code: <button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="invia" android:clickable="true" android:onclick="onclick1" android:id="@+id/invia" /> java code: import android.app.activity; import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.toast; import com.android.volley.request; import com.android.volley.requestqueue; import com.android.volley.response; import com.android.volley.volleyerror; import com.android.volley.toolbox.stringrequest; import com.android.volley.toolbox.volley; import java.util.hashmap; import java.util.locale; import java.util.map; public class creazionesondaggio extends appcompatactivity { string url;

html - How to hover child nodes separately in ul element? -

html ul element hovers child parent ul li:hover { background-color: pink; } <ul> <li>1 <ul> <li>1</li> <li>1</li> <li>1</li> <li>1</li> <li>1</li> </ul> </li> <li>1</li> <li>1</li> <li>1</li> <li>1</li> </ul> fiddle i understood trying achieve this: when having children li hovered parent still remains child's same style. so here snippet li { /* demo */ list-style: none; } li:hover { color: red; font-weight: 700 } li:hover li { color: none; font-weight: 400 } li:hover li:hover { color: red; font-weight: 700 } <ul> <li>1 - text <ul> <li>1 - text</li> <li>1 - text</li> <li>1 - text</li> <li>1 - text</li&g

Java client aborts on SNI unrecognized_name warning -

i trying connect domain platform.modsolar.net using socket. getting javax.net.ssl.sslprotocolexception: handshake alert: unrecognized_name i using java 7. the host name(platform.modsolar.net) correctly listed in sans what missing here ?

android - Unable to add Window, Token is not valid error when clicked on a Spinner -

i have android application when clicked on option side bar goes fragment, , fragment has clickable radio buttons. when clicked on these create popup window text fields in it. basically how flow goes, activity --> fragment 1 --> fragment 2 --> popupwindow and have spinner on popupwindow, when click on select value throws following exception. don't understand why happen. process: com.informaticsint.claimassistant, pid: 5045 android.view.windowmanager$badtokenexception: unable add window -- token android.view.viewrootimpl$w@945936c not valid; activity running? @ android.view.viewrootimpl.setview(viewrootimpl.java:849) @ android.view.windowmanagerglobal.addview(windowmanagerglobal.java:337) @ android.view.windowmanagerimpl.addview(windowmanagerimpl.java:91) @ android.widget.popupwindow.invokepopup(popupwindow.java:1329) @ android.widget.popupwindow.showasdropdown(popupwindow.java:1155) @ android.widget.listpopupwindow.show(listpopupwindow.ja