Posts

Showing posts from August, 2012

ios - Objective-C: conditionally call different properties -

say there's class contains 2 different properties such as: @interface myclass : nsobject @property id valuewhenno; @property id valuewhenyes; @end while using class boolean value called 'state', know can property according 'state' by: myclass *myclass; id value = state ? myclass.valuewhenyes : myclass.valuewhenno; but found using lot of conditional statement in complex code can make readability of hard. since intend give no information 'state' 'myclass', there cannot additional boolean property in 'myclass'. is there way in objective-c class can used property conditionally short line of code such following? id value = myclass.valuebystate; have 2 instances of class 1 property instead of 1 instance 2 properties. then, when state changes switch instance instead of having code everywhere check state.

python - NLTK: Package Errors? punkt and pickle? -

Image
basically, have no idea why i'm getting error. perform following: >>> import nltk >>> nltk.download() then when receive window popup, select punkt under identifier column locatedin module tab.

java - Not able to get back to original activity using uri.parse method -

i beginner.i trying using uri.parse returning result. main java file. package com.example.returnresult; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.edittext; import android.widget.textview; import android.widget.toast; public class mainactivity extends activity { int request_code=1; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } public void sendmessage(view v){ intent = new intent(this,second.class); startactivityforresult(i,request_code); } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { if(requestcode == request_code) { if(resultcode == result_ok) { toast.maketext(this,data.getdata().tostring(), toast....

objective c - UICollectionViewCell hidden though I never set it hidden -

i'm quite amazed result lines: [cell sethidden:no]; nslog(@"cell = %@", cell); nslog(@"hidden = %hhd", cell.hidden); output: 2015-06-13 19:35:53.923 cell = <detailedsqeedcollectionviewcell: 0x145660b0; baseclass = uicollectionviewcell; frame = (-20 -49; 0 0); clipstobounds = yes; hidden = yes; opaque = no; layer = <calayer: 0x1582cd90>> 2015-06-13 19:35:53.923 hidden = 1 how possible, have clue? thanks in advance. i had problem. ios smart enough hide cells if underlying subviews, in case imageview's frame outside bounds , not showing. make sure if subviews have set. you find if set background cell color not match uicollectionview, not shown hidden anymore.

Swift assignments inside conditions -

i wondering code does: var something: string = "hi" if = "hello world!" { // executed? } will assign something variable , if body? or set value of variable if body , outside not change? or has nil ? this pattern works assignments can fail — is, if you're assigning result of expression returns optional value. , in case, use if let , not if .

dataframe - R remove row that are not duplicated from a data frame -

i have data looks like: > data<-data.frame(x=c(1,1,2,3,4,2,2), y=c(1,2,3,4,5,6,8)) x y 1 1 1 2 1 2 3 2 3 4 3 4 5 4 5 6 2 6 7 2 8 i'm using duplicate in next way: data[duplicated(data[,1]), ] and i'm getting: x y 2 1 2 6 2 6 7 2 8 i like: x y 1 1 1 2 1 2 3 2 3 6 2 6 7 2 8 if value duplicated m times in vector, first incidence not marked duplicate duplicated , subsequent m-1 values marked duplicates. m duplicates, use duplicated(...) | duplicated(..., fromlast=true) : data[duplicated(data[,1]) | duplicated(data[,1], fromlast=true),] # x y # 1 1 1 # 2 1 2 # 3 2 3 # 6 2 6 # 7 2 8

git - Run Jenkins job on Github Push -

i know question asked several times , gone through answers too, still none of them working me. i following setting github webhook in jenkins , tried run jenkins job build on github push. but after adding jenkins hook url in services / manage jenkins (github plugin) , marking active on update service when clicked on test service button, message: okay, test payload on way. i tried pushing change in github repository job didn't run, went services section there red warning symbol message "last delivery not successful. service timeout" . can please me in fixing issue? any appreciated. thanks. it's because jenkins configured localhost , referring http://127.0.0.1:9999/github-webhook/ in jenkins hook url not work github servers not able reach jenkins server trigger build. more can read here: jenkins build trigger on github push

dns - SQL authentication for different domain user -

this question regarding sql authentication different domain user. i have 2 servers on cloud. on server1 have iis , on server2 have sql. both on different domain, server1 & server2. can access sql database using ip address , vice versa. i have "customuser" on "server1", want connect sql using user details. from "server2" can't "server1" in domain name or in user list. , vice versa. i want add "server1\customuser" on "server2" sql. edit: using sql server 2012

javascript - NodeJS / ExpressJS Multiple environments simulatenously -

my nodejs project requires multiple environments. e.g. sit/qa/prod. have set config files (e.g. qa.js) specify port use , db etc. start script sets node_env according environment, , launch doing "npm start". this works fine single environment, starts on port should , fine. however, when start environment, first stops working. assume either fact node_env has changed, or else? node_env matter when first run npm start or after too? can please advise how have multiple environments simultaneously running? an environment (almost) nothing special express. can use selection mechanism set configuration based on value of node_env , you're doing now. conceptually, should think of this: if (node_env === 'qa') { // set configuration qa } else if (node_env === 'production') { // set configuration production } else // set configuration development/testing/... } as can see, implies can use 1 environment @ time. if set production environment, ...

css - How to properly apply styles to Child theme -

i have situation. child style.css file contain following line : @import url("../notio-wp/style.css"); the main theme style.css file, contain following message: /* * please not edit file! * * file in themefolder wordpress recognize basic theme data name , version * css rules in file not used theme. * instead use app.css file located in themes /assets/css/ folder add styles. * if want add small css snippets might want consider add designated * css option field in themes backend at: appearance -> theme options */ i've made modifications in custom css main theme field , in app.css file. what best way include child theme, new css styles, should copy app.css file child theme structure, or app.css modified lines, child style.css file, next css lines custom css main theme field? thank you,

android - error loadind data from sqlite to spinner -

while loading data sqlite spinner data repeated several times, values "traditionnel" , "fast food" repeated several times @override protected void oncreate(bundle savedinstancestate) { contentvalues values = new contentvalues(); values.put(column_categoriename , "fast food"); db.insert(table_categorie, null, values); values.put(column_categoriename , "traditionnel"); db.insert(table_categorie, null, values); db.insert(table_categorie, null, values); cursor c = db.query(table_categorie, new string[] { column_idcategorie, column_categoriename} , null,null,null,null,null); int col=c.getcount(); if (col == 0) { toast.maketext(mainactivity.this, "pas de donnees ", toast.length_long).show(); // effacer le contenue champ login e...

java - AbstractTabelModel won't show the JTable column names -

Image
for reason jtable not displaying it's column names?! i'm i've done correctly. i've literally copied demonstration don't understand why won't work. here code: public class memtablemodel extends abstracttablemodel{ private arraylist<member> members = new arraylist<member>(); private string[] columnnames = {"id", "name", "email", "country", "genre", "gender", "description", "type", "limit", "card no", "expiry date"}; public memtablemodel(){ loadtablefromdb(); } public int getrowcount(){ return members.size(); } public int getcolumncount(){ return columnnames.length; } public object getvalueat(int row, int col){ //get row method member f = members.get(row); switch(col){ case 0: return f.getmembid(); case 1: return f.ge...

php - execute cron job every 2 hour with 30 min duration -

i have searched so, can't seem find topic covering little problem. i'm quite new cron jobs. i have ip based alarm. alarm can control wireless power outlets, turning them on , off within web based control panel. can control power outlets simple http command, making them turn on , off. i have made php script taking care of this. right 2 separate scripts, 1 turning on , 1 turning off. script controlling 1 specific power outlet. my problem need time based switching scheme. first thought of making php script sleep, @ sleep time 1 hour, not first choice. so here go. is possible set cron job to: 1: run on script 1 sec, trigger http command in script. 2: wait 1 hour. 3: run off script 1 sec trigger http command. 4: wait 2 hours. 5: start on again. there no problem alarm system, sending off http command if power outlet off, , vice versa. you can combine commands single , run every 3 hours. 0 */3 * * * /path/to/1st_script; sleep 3600; /path/to/2nd_s...

Does pow() work for int data type in C? -

this question has answer here: strange behaviour of pow function 5 answers i writing program calculate power of integer. output not expected. worked integer numbers except power of 5. my code is: #include <stdio.h> #include <math.h> int main(void) { int a,b; printf("enter number."); scanf("\n%d",&a); b=pow(a,2); printf("\n%d",b); } the output this: "enter number. 2 4 "enter number. 5 24 "enter number. 4 16 "enter number. 10 99 can't use pow() function int data type?? floating point precision doing job here. actual working of pow using log pow(a, 2) ==> exp(log(a) * 2) look @ math.h library says: <math.h> /* excess precision when using 64-bit mantissa fpu math ops can cause unexpected results of msvcrt math functions. example, unless f...

linux - Add NOPASSWD for a specific command -

i know, there're lots of other posts related question. but, that's not secure way proceed with. i've added defaults:apache !requiretty , set script.sh file path run web user, script.sh invokes command should run root user. added nopasswd this apache = (all) nopasswd:/home/app/admin/tomcat.sh start it gave following error sudo: >>> /etc/sudoers: syntax error near line 120 <<< sudo: parse error in /etc/sudoers near line 120 sudo: no valid sudoers sources found, quitting sudo: unable initialize policy plugin then, directly added command should run root user. , becomes apache = (all) nopasswd:/bin/su root -c /usr/share/apache-tomcat-7.0.61/bin/startup.sh i tried change command e.g: apache = (all) nopasswd:/usr/share/apache-tomcat-7.0.61/bin/shutdown.sh still same(above) error. although apache all=(all) nopasswd: all works well. there security issue. so, how can grant user access run specific command root user? you'r f...

git - Jenkins continuous deployment error -

i learning jenkins ci test & deploy stated in excellent tutorial http://code.tutsplus.com/tutorials/setting-up-continuous-integration-continuous-deployment-with-jenkins--cms-21511 at end of tutorial, should handle deployment of app... per deploy script , jenkins project config w ./script/deploy #!/bin/sh ssh app@my.server.ip <<eof cd ~/hello-jenkins git pull npm install --production forever restartall exit eof the testing ok, deployment raises error on git pull . should git commit -f before git pull ? error: local changes following files overwritten merge: app.js which listed in jenkins console output. don't understand why... ./script/test / ✓ respond hello jenkins (41ms) 1 passing (56ms) + ./script/deploy pseudo-terminal not allocated because stdin not terminal. welcome ubuntu 14.04.2 lts (gnu/linux 3.13.0-52-generic x86_64) * documentation: https://help.ubuntu.com/ system information of sat jun 13 06:32:35 ed...

html - absolute ignoring parent padding -

i using bootstrap , trying create own dropdown menu on right side. i tried below css.but ignoring parents padding.but when use position : relative working fine pushing text contents down.so want absolute overlay preserve parent padding. .menu { background:#ccc; top: 50px; right: 0px; position: absolute; clear: both; } here fiddle html - http://jsfiddle.net/97bqun6s/ p.s: parent bootstrap .container class padding varies screen sizes. when use position: absolute on element element positioned within closest 'non static' parent container's content area , padding box. can refer box model reference. a simple solution right: 15px . offset side-nav right align rest of container. see jsfiddle edit: since padding of container variable may not viable solution. you instead add wrapper div inside container <div class="container"> <div class="content-wrap"> ... </div> </div> and p...

C# generics, cross referencing classes for state pattern -

i trying c# generics , have created state machine state pattern , try refactor. i have state, has reference object it's working on. public abstract class abstractstate<t> t : statefulobject { protected t statefulobject; public abstractstate(t statefulobject) { this.statefulobject = statefulobject; } } and have object has states, should have reference current state. public abstract class statefulobject<t> : monobehaviour t : abstractstate<statefulobject<t>> { public t state; } but not work ("the type cannot used type parameter 't' in generic type or method"). what want achieve : public class monster : statefulobject<monsterstate> { } public abstract class monsterstate : abstractstate<monster> { } is possible? if it's not way, there another? thx. you can abuse interfaces , variance achieve that: public interface istate<out tobject, in tstate> tobject : i...

migration - Add comment to SQL table -

how can add comment specific sql-table in yii2 migration? sql code: alter table my_table comment 'hello world' i wand in within migration in orm way in yii2 format addcommentoncolumn($table, $column, $comment) dropcommentfromcolumn($table, $column) addcommentontable($table, $comment) dropcommentfromtable($table) example: in migration file $this->addcommentoncolumn('user','role_id','relation table of role');

javascript - how to implement mousemove while mouseDown pressed js -

i have implement mouse move event when mouse down pressed. i need execute "ok moved" when mouse down , mouse move. i used code $(".floor").mousedown(function() { $(".floor").bind('mouseover',function(){ alert("ok moved!"); }); }) .mouseup(function() { $(".floor").unbind('mouseover'); }); use mosemove event. from mousemove , mouseover jquery docs: the mousemove event sent element when mouse pointer moves inside element. the mouseover event sent element when mouse pointer enters element. example: (check console output) $(".floor").mousedown(function () { $(this).mousemove(function () { console.log("ok moved!"); }); }).mouseup(function () { $(this).unbind('mousemove'); }).mouseout(function () { $(this).unbind('mousemove'); }); https://jsfiddle.net/n4820hsh/

regex - Redirect non-www to www except subdomains by .htaccess -

there few questions this, question little different redirect non-www www in .htaccess force non www www in htaccess redirect non-www www urls i want redirect non-www version of website www, should not in way effect subdomains, so www.example.com => www.example.com example.com => www.example.com sub1.example.com => sub1.example.com sub2.example.com => sub2.example.com this not work, cause not behave in case of subdomains rewritecond %{http_host} !^www\. rewriterule ^(.*)$ https://www.%{http_host}/$1 [r=301,l] this solution works fine rewritecond %{http_host} ^example.com$ rewriterule (.*) https://www.example.com/$1 [r=301,l] however, important thing not want hardcode domain name in htacess. how (if possible) have above mentioned redirections general case - without mentioned exact domain name ? thanks you can use rule: rewritecond %{http_host} ^[^.]+\.com(\.au)?$ [nc] rewriterule ^(.*)$ https://www.%{http_host}/$1 [r=301,l]

node.js - Http2 not working with express -

i have server.js file code var express = require('express') var app = express() var fs = require('fs'); app.get('/', function (req, res) { res.send('hello, http2!') }) var options = { key: fs.readfilesync('./localhost.key'), cert: fs.readfilesync('./localhost.crt') }; require('http2').createserver(options, app).listen(8080); after run in shell $ node server.js and server waiting, can't open it. tried http://localhost:8080 , https://localhost:8080 (i know 1 right one.). nothing going on, no errors no response in browser, doing wrong? .key , .crt files not generated me, copied it, can problem? at time of writing this, there known issues using node-http2 express, see here: https://github.com/molnarg/node-http2/issues/100

vhdl - No feasible entries for infix operator "+" -

i designing 2s complement code showing error can 1 me that. library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; entity comp port(a : in std_logic_vector(7 downto 0); y : out std_logic_vector(7 downto 0)); end comp; architecture dataflow of comp signal temp: std_logic; begin y<= not(a) + "00000001"; end dataflow; error: d:/modelsim_projects/2scmpliment.vhd(13): no feasible entries infix operator "+". when using synopsys packages, need add use of std_logic_unsigned package after std_logic_1164 , like: use ieee.std_logic_unsigned.all; with can use integer notation addition like: y <= not(a) + 1; alternative use ieee vhdl standard numeric_std package, changes like: library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; ... y <= std_logic_vector(unsigned(not(a)) + 1);

scala - ReduceLeft with Vector of pairs? -

i have vector of pairs vector((9,1), (16,2), (21,3), (24,4), (25,5), (24,6), (21,7), (16,8), (9,9), (0,10)) and want return pair maximum first element in pair. i've tried this: data reduceleft[(int, int)]((y:(int, int),z:(int,int))=>y._1 max z._1) and data reduceleft((y:(int, int),z:(int,int))=>y._1 max z._1) but there type mismatch error , can't understand wrong code. why using reduceleft ? default max method works well scala> val v = vector((9,1), (16,2), (21,3), (24,4), (25,5), (24,6), (21,7), (16,8), (9,9), (0,10)) v: scala.collection.immutable.vector[(int, int)] = vector((9,1), (16,2), (21,3), (24,4), (25,5), (24,6), (21,7), (16,8), (9,9), (0,10)) scala> v.max res1: (int, int) = (25,5) if want reduceleft instead : v.reduceleft( (x, y) => if (x._1 >= y._1) x else y ) your error have return tuple, not int y._1 max z._1 the max function here on 2 int return int.

node.js - cannot pm2 list in docker containers -

Image
i build docker image node.js , pm2. started container with: docker run -d --name test -p 22 myimage then go inside container with: docker exec -it test /bin/bash in container, exec command: pm2 list and stuck here: p.s.: application works in docker container, if add cmd pm2 start app.js in dockerfile . if dockerfile cmd pm2 command, have include --no-daemon arg option pm2 runs in foreground , docker container continues run. an example dockerfile cmd: cmd ["pm2", "start", "app.js", "--no-daemon"] otherwise, without --no-daemon, pm2 launches background process , docker thinks execution of pm2 command done running , stops. see https://github.com/unitech/pm2/issues/259

google api - GCM: cannot send message from python script -

Image
i'm following this tutorial send gcm message server via python script. i've downloaded gcmdemo can send messages using project num , server api key , reg id . but no way python. i've registered client: 06-13 09:47:45.682 2272-32480/com.google.android.gcm.demo i/gcmdemo﹕ registration succeeded. senderid: 11xxxxxxx07 token: fxq...xxxx..r5 my server api key: the python script on server: from gcm import * gcm = gcm("aiza...xxx...xq") data = {'ciao ciao': 'test message', 'param2': 'value2'} reg_id = 'fxq...xxxx..r5' gcm.plaintext_request(registration_id=reg_id, data=data) no error messages no messages received. is there way log , see problem ? the client doesn't react (log on android studio set verbose, no log @ all). any idea ? the google project console shows logs till 30 may. i'm not using python anymore switched php had same problem there , solved adding icon field ...

In ubuntu unable to write file in specified directory using java -

while trying write file in specified directory getting exception. java code :- public void jsontoyaml(jsonobject json, string studioname) throws jsonexception, org.codehaus.jettison.json.jsonexception, ioexception { yaml.dump(yaml.dump(jsontomap.jsontomap(json)), new file("config.yml")); bufferedreader br = new bufferedreader(new filereader("config.yml")); string line; studioname = studioname.tolowercase(); file writefile = new file("sudo /var/iprotecs/idns2.0","" + studioname + ".yaml"); fileoutputstream fos = new fileoutputstream(writefile); bufferedwriter bw = new bufferedwriter(new outputstreamwriter(fos)); try { while ((line = br.readline()) != null) { string line1 = line.replace("\"", ""); string line2 = line1.replaceall("!java.util.hashmap", ""); string line3 = line2.replaceall("---...

osx - SOLVED: QT: Escape slash / in saving location on a mac -

i have html input supposed extract 2 strings of, build document title string of type <string 1> / <string 2 , create pdf source on users mac desktop , name described. i know slash in document name not such brilliant idea asked do. problem is: forward slash interpreted folder on mac , not part of documents name means qpainter fails print pdf because interpretes string1 / being folder doesn't exist. btw when omitting / code working fine. how supposed escape / ? here's string building logic: qstring doctitle; doctitle.append(string1); doctitle.append(" / "); doctitle.append(string2); on os x, name of file @ level of apis different display name shown user in finder, open , save panels, etc. at level of apis, file names can't contain slashes. reserved separating names within path. there's no form of escaping or quoting allow it. however, can create file name displayed slash in ui. basically, slash ( / ) , colon ( : ) char...

multiprocessing - Local variable not updated in a loop in the same way as shared memory objects in Python -

in following python code, multiprocessing module starts 3 processes print out values of 1 local variable , 2 multiprocessing shared memory objects. import multiprocessing mp import os,time # local variable count = 0 # shared memory objects (int , array) scalar = mp.value('i', 0) vector = mp.array('d', 3) def showdata(label, val, arr): print(label, "==> pid:", os.getpid(), ", count:", count, ", int:", val.value, ", arr:", list(arr)) ps = [] in range(3): count += 1 scalar.value += 1 vector[i] += 1 p=mp.process(target=showdata, args=(('process %s' % i), scalar, vector)) p.start() ps.append(p) # time.sleep(.1) # block main thread until processes have finished... p in ps: p.join() the output code following... process 0 ==> pid: 35499 , count: 1 , int: 3 , arr: [1.0, 1.0, 1.0] process 1 ==> pid: 35500 , count: 2 , int: 3 , arr: [1.0, 1.0, 1.0] process 2 ==> pid: 3550...

facebook php sdk - Get reach estimate with PHP API -

i spent hours trying reach estimate using php sdk. problem having not knowing how use function "getreachestimate(.., ..)" not explained anywhere in way able understand. if give me code example of using function great, or other way of geting reach estimate using php. the same request through sdk $response = $api->call( "/".$ad_account_id."/reachestimate", requestinterface::method_get, array( 'targeting_spec' => json_encode($targeting), 'currency' => 'usd' ) ); return $response->getcontent(); where $ad_account_id looks act_xxxxxxx

Could not see graphics on Windows Server 2003 -

i installed windows server 2003 on 1 of machines. long machine , os installed long back. ram 4gb. until 4 days machine fine , providing services. graphics got problem. command prompt working. if open windows explorer through "explorer.exe" through command prompt, window gets opened no graphics displayed. showing black desktop. the machine running development server. please suggest , me in making machine run perfectly? somehow found answer. killed process explorer.exe of below commands > tasklist > taskkill /f /im explorer.exe and started process below command > explorer.exe it should resolve issue @ point. if not, logoff machine , login back. should show result.

html - Center DIV Horizontally and Vertically -

i have html structure: <div class="metaboxdet"> <div class="metd"> <h1>hello world!</h1> </div> </div> http://jsfiddle.net/fvuel00n/2/ the problem here cant center div "metd" horizontally , vertically. have tried adjusting top, bottom, left , right return not accurate results. there way can center horizontally , vertically dynamically. please check fiddle here see in action. thanks! as discussed in answer , can add helper element height:100% , display:inline-block vertical-align:middle , , change container display:inline-block vertical-align:middle .helper{ display:inline-block; height:100%; vertical-align:middle; } /*container*/ .metd{ vertical-align:middle; display:inline-block; } here's code in action

How to redirect user to a returned URL python -

so im testing out paypal rest sdk , im using python cgi language(i know 2007), anyway i've hit roadblock,in cant redirect returned url page. i tried print location method. , did not work me. # create payment using paypal sample # sample code demonstrates how can process # paypal account based payment. # api used: /v1/payments/payment paypalrestsdk import payment import logging logging.basicconfig(level=logging.info) # payment # payment resource; create 1 using # above types , intent 'sale' payment = payment({ "intent": "sale", # payer # resource representing payer funds payment # payment method 'paypal' "payer": { "payment_method": "paypal"}, # redirect urls "redirect_urls": { "return_url": "http://localhost:3000/payment/execute", "cancel_url": "http://localhost:3000/"}, # transaction # transaction defines contract of # payment - payment , # f...

c++ - Linker errors for OpenBlas (+Armadillo) -

i using armadillo blas , lapack have decided use openblas speed computations. have followed steps given in link , compiled openblas in mingw generate libopenblas.dll , libopenblas.dll.a. have tried use these in example application in vs 2012 , found linker errors related openblas. doing wrong? the example given below: #include <iostream> #include <armadillo> using namespace std; using namespace arma; int main(int argc, char** argv) { cout << "armadillo version: " << arma_version::as_string() << endl; mat a(2,3); // directly specify matrix size (elements uninitialised) cout << "a.n_rows: " << a.n_rows << endl; // .n_rows , .n_cols read cout << "a.n_cols: " << a.n_cols << endl; a(1,2) = 456.0; // directly access element (indexing starts @ 0) a.print("a:"); = 5.0; // scalars treated 1x1 matrix a.print("a:"); a.set_size(4,5); //...

javascript - Getting the index of a parent element of an event target -

with code provided: $("#mylist").on("click", "span", function (event) { alert($(this).index()); }); and html: <ul id="mylist"> <li>item 0 <span>span 0</span></li> <li>item 1 <span>span 1</span></li> <li>item 2 <span>span 2</span></li> <li>item 3 <span>span 3</span></li> </ul> if click on of <span> elements, "0" alerted. think because there 1 <span> within each <li> , given index of 0. what want do, return index of <span> 's parent - in case, index of parent <li> within <ul id="mylist"> . example, clicking on <span>span 2</span> alert "2". jsfiddle either use $(this).parent().index() or $(this).closest('li').index() . the latter alert index of li if decide put new element spans , bind event that. ...

c++ - Error with openmp for Nested for-loop -

i have used eigen library in object oriented cpp code. defined main object, 2dgf, , in methods of it, have used openmp. want use openmp in method following: #pragma omp parallel num_threads(non) #pragma omp for(unsigned int ie=0;ie<ne;ie++){ for(unsigned int ik=0;ik<nk;ik++){ for(unsigned int ii=0; ii<nl ;ii++){ for(unsigned int jj=0; jj<nl ;jj++){ if(abs(coorx[ii]-coorx[jj])<dioglim){ g.insert(ie*nl+ii,ik*nl+jj)=0; gr.insert(ie*nl+ii,ik*nl+jj)=0; s.insert(ie*nl+ii,ik*nl+jj)=0; sr.insert(ie*nl+ii,ik*nl+jj)=0; } } } } } where g, gr, s , sr sparse matrices. without using openmp works no problem. when use openmp, receive following error: 2dgf : malloc.c:2372: sysmalloc: assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_siz...

dictionary - I am attempting a hash map that stores vector of objects. in C++ -

i attempting hash map stores vector of objects. explanation / goal in words. if no key not found, create new entry. if key found, push new object vector of objects in pseudo code attempting map<string,vector<object>> data object{ int data vector<keywords> keywords } function(object arg) { local_key_var = object->keywords; ( key_element : local_key_var) { if(key_element not exist in vector<object> ) { create entry map<key_element,vector<object> } else { local_vector_var = current vectorobject; local_vetor_var.push(arg); erase current vector object; insert new_vector_var int map<key_element,vector<objects>>; } } } in c++ code at. void library::additembykeyword(item* item) { vector<string> localkeyvector = item->getkeywords(); (aut...

android - ClassNotFoundException: Didn't find class on path: DexPathList -

i trying implement facebook login functionality on app . implementing code step step , testing on device . till havenot put provide or activity got error after implementing code in manifest file , activity_main.xml 06-13 10:52:21.240 13451-13451/com.example.administrator.facebooklogin e/androidruntime﹕ fatal exception: main process: com.example.administrator.facebooklogin, pid: 13451 java.lang.runtimeexception: unable start activity componentinfo{com.example.administrator.facebooklogin/com.example.administrator.facebooklogin.mainactivity}: android.view.inflateexception: binary xml file line #12: error inflating class provider @ android.app.activitythread.performlaunchactivity(activitythread.java:2429) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2493) @ android.app.activitythread.access$800(activitythread.java:166) @ android.app.activitythread$h.handlemessage(activitythread.java:1283) ...

python - How to connect to Flask-WebSocket server? -

i following tutorial try , use flask-websockets in app. http://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent my problem don't know how connect server. when make calls flask app, in form: http://localhost:80/myapp/<route_goes_here> my app structured follows: couponmonk/venv/couponmonk __init__.py views.py templates/ index.html __init__.py from flask import flask flask.ext.sqlalchemy import sqlalchemy sqlalchemy.orm import sessionmaker sqlalchemy import * flask.ext.socketio import socketio, emit app = flask(__name__) socketio = socketio(app) engine = create_engine('mysql://root:my_password@localhost/my_db_name') dbsession = sessionmaker(bind=engine) import couponmonk.views views.py from couponmonk import app, dbsession, socketio @socketio.on('my event', names...

c++ - Is there a better way to do this than writing a wrapper allocator that stores a reference to a stateful allocator object? -

for example: struct foo { mypoolalloc<char> pool; std::vector<int , mypoolalloc<char>> vec_int; // wrapper allocator replace mypoolalloc<> here. std::vector<std::function<void()> , mypoolalloc<char>> vec_funcs; // wrapper allocator replace mypoolalloc<> here. foo() : vec_int(pool) , vec_funcs(pool) {} // want store lambdas captured variables using custom allocator well: template<typename func> void emplace_back(const func& func) { vec_funcs.emplace_back(std::allocator_arg , pool , func); } }; in above code, want allocations (besides pool itself) pull same pool object. best way writing wrapper allocator stores reference actual stateful allocator object? , pass following constructors (example): : vec_int ((mywrapperalloc<char>(pool))); is there cleaner way writing whole wrapper class mypoolalloc<> ? the standard "allocator" concept have been bett...

c++ - How to improve speed for time limit exceeded -

is there way improve running time program? time limit exceed error online judge, , seems program running slow? so, question program: http://www.spoj.com/problems/prime1/ my code (language c): #include <stdio.h> void findprime (int m, int n) { int i, prime = 1; if (m <= n) { (i = m - 1; > 1; i--) { if (m % == 0) { prime = 0; break; } } if (prime == 1 && m != 1) printf ("%d\n", m); findprime (m + 1, n); } } int main () { int num1, num2, i, cases; scanf ("%d", &cases); while (cases != 0) { scanf ("%d %d", &num1, &num2); findprime (num1, num2); printf ("\n"); cases--; } return 0; } to solve question need learn "sieve of eratosthenes" . first, idea of how works here . but, not enough solve questio...

spark-1.4 with zeppelin installation -

after install spark 1.4, tried install apache zeppelin note-book utility. from other online resources, download , unzip zeppelin source , started compile maven via $ mvn clean install -pspark-1.4 -dskiptests (spark home exported in environment) i got nice info output 4 minutes things stopped error when: downloading: https://repo.maven.apache.org/maven2/org/sonatype/oss/oss-parent/7/oss-parent-7.pom and here error message: [error] [error] problems encountered while processing poms: [fatal] non-resolvable parent pom com.nflabs.zeppelin:zeppelin:0.5.0-snapshot: not transfer artifact org.sonatype.oss:oss-parent:pom:7 from/to nflabs public repository (https://raw.github.com/nflabs/mvn-repo/master/releases): connect raw.github.com:443 [raw.github.com/199.27.76.133] failed: connection timed out , 'parent.relativepath' points @ wrong local pom @ line 26, column 10 is there forgot or should modify beforehand? appreciate help. it looks cannot connect connec...

pattern matching - Agda: Simulate Coq's rewrite tactic -

i have experience using coq , in process of learning agda. i'm working on correctness proof of insertion sort , have reached point perform similar coq's rewrite tactic. currently, have: open import data.nat open import relation.binary.propositionalequality open import data.sum data list : set nil : list cons : â„• -> list -> list data sorted (n : â„•) : list -> set nilsorted : sorted n nil conssorted : ∀ hd tl -> hd ≥ n -> sorted hd tl -> sorted n (cons hd tl) lemin : ∀ x y -> x ≤ y -> (x ⊓ y) ≡ x lemin 0 zero p = refl lemin 0 (suc y) p = refl lemin (suc x) 0 () lemin (suc x) (suc y) (s≤s p) = cong suc (lemin x y p) insert : â„• → list → list insert x l = {!!} intdec : ∀ x y → x ≤ y ⊎ x > y intdec x y = {!!} insertcorrect : ∀ {n} -> ∀ x l -> sorted n l -> sorted (n ⊓ x) (insert x l) insertcorrect {n} x nil p intdec n x insertcorrect {n} x nil p | inj₁ x₁ (lemin n x x₁) ... | c = {c }0 my proof context looks like: goal: so...

Java Swing Displaying Large Amounts of Data from ArrayLists -

i cannot provide code because abstract problem facing. i working on program allows user track players games. program stores players profile information in arraylist. 1 feature of program let user able browse through entire arraylist of players. let's have arraylist of player objects , size large, 1000 . possible in java allow user scroll through arraylist? thought creating 10 jlabels , each time user clicked button iterate through arraylist next 10 player objects. not seem practical. are there swing features can utilize problem? try using jtable, in each table row contains information each player. can extend class abstracttablemodel define fields per player, , player gets displayed on table row. i've written java app uses jtables more 2000 rows, , 15 20 columns, , had no performance issues. limit displayed rows, can use rowfilter, , can customise sorting using rowsorter.

html5 email field validation issue with .at domain -

so we've been using html5 required field attributes , have changed our email field type 'text' 'email'. visitors .at(austria) domain names being prompted 'did mean...' raised complaint. i'm new html5 , believe browser based. can contacted .at domains on whitelist? functionality implemented makers of browser used.

javascript - Wait until the Ajax function is done -

i have searched on site how wait until ajax function done , found solution: function next() { $.when(checksign()).done(function () { if (uf == 1) { $("#usrdiv").css("display", "none"); $("#pswdiv").css("display", "inline"); } }); } function checksign() { $.ajax({ url: "checkuser.php", data: { user: u }, method: "post" }).done(...); } but still not working, doesn't wait ajax done direcly executes function inside done() that's because checksign doesn't return promise need chain on done function. you don't need $.when wrapper 1 single promise either function next() { checksign().done(function(data) { if (uf == 1) { $("#usrdiv").css("display", "none"); $("#pswdiv").css("display", "in...

linux - Autostart processes and services -

i want control every single process system use. (and learn 1 one) use openbox, i'm confused how control startup programs , services. i have need (minimum system) in single place. executed ? in order ? "/etc/xdg/autostart/" "/usr/lib/x86_64-linux-gnu/openbox-autostart" ".config/openbox/autostart.sh" "/etc/init.d/" "/etc/rc3.d/" ... ??? you can check using below mentioned commands. ps - list processes running on system kill - send signal 1 or more processes (usually "kill" process) jobs - alternate way of listing own processes bg - put process in background fg - put process in forground

Multiple entry in one mysql cell and Json data -

i have lots folder named series name. , every series folder has own chapter folder. in chapter folder images in it. website manga(comic) site. gonna record folder's , image's path mysql , return json data using angularjs. how should save these folders path or names mysql proper json data , using angularjs. my table this: can change, id series_name folder path 1 dragon ball 788 01.jpg02.jpg03.jpg04.jpg05.jpg06.jpg.......... 2 1 piece 332 01.jpg................... 3 1 pÄ°ece 333 01.jpg02.jpg........... my current website: link reader part of website i'm assuming you're using php on lamp stack. first need grab sql fields , change them json keys. create json-object correct way then can create json object , pass angular when ajax request. make sure create array before placing json object (for path). { id: number, series_name: string, folder: number, pa...