Posts

Showing posts from March, 2013

Dataflow zombie jobs - stuck in "Not Started" state -

Image
all of our dataflow jobs have stopped working. show "not started". when kicked off 1 job appears have spawned numerous other jobs, hanging. is service broken? the list of job id's: 2015-05-12_04_15_09-9449594780471772631 2015-05-12_04_11_43-2832089474782567234 2015-05-12_04_11_10-7703117482304158028 2015-05-12_04_06_52-8133922783285731870 2015-05-12_04_06_09-14187812688860505584 2015-05-12_04_05_32-10296794562342944020 2015-05-12_04_04_58-17815218306022481742 2015-05-12_04_04_26-1948202417139012084 2015-05-12_04_03_55-5718237782405777885 2015-05-12_04_03_23-8040675812721773662 44227 [main] info com.google.cloud.dataflow.sdk.util.packageutil - uploading pipelineoptions.filestostage complete: 1 files newly uploaded, 77 files cached dataflow sdk version: 0.4.150414 446168 [main] warn com.google.cloud.dataflow.sdk.util.retryhttprequestinitializer - request failed code 429, not retry: https://dataflow.googleapis.com/v1b3/projects/gdfp-xxx/jobs

Android: OpenGraph Stories sharing in Facebook with SDK 4.0 -

i trying implement achievements sharing facebook when player unlocks badge. have made object using object browser in facebook developer console. made action-types , object-types , made custom story. stuck trying share story facebook. documentation given facebook inadequate. sample code given facebook uses v3.x sample code given facebook given below. couldnt find documentation. code object bundle params = new bundle(); request request = new request( session.getactivesession(), "me/objects/enguru_app:badge", params, httpmethod.post ); response response = request.executeandwait(); // handle response code action bundle params = new bundle(); params.putstring("badge", "http://samples.ogp.me/1114467558579559"); request request = new request( session.getactivesession(), "me/enguru_app:unlocked", params, httpmethod.post ); response response = request.executeandwait(); // handle response at last figur

vba - What is the best structure to store grouped rows of data in VB -

i have data structure: category product group requiredamount stockamount sample data a 1 10 5 b 1 10 10 c 2 20 10 d 3 30 40 b e 1 10 15 b f 2 20 20 i want store in collection of sort, while being able to: access category , product . keep items order entered, not sorted alphabetically. change amounts . it handle around 100 items. i used dictionary categories, holding collection of 1-dimensional arrays, product key. the main problem changing amounts, changing items in collection requires adding , removing them, changes items order. any thoughts? this creates 2 field recordset (you can save disk). make yours' 6 fields , include line number field can use sort original order. can sort , filter how want. set rs = createobject("adodb.recordset") rs .fields.append "sortkey", 4 .fields.append "txt", 201, 5000 .open until inp.atendofstream lne = inp.read

django raw_id_field javascript callback -

consider example: models.py class foo(models.model): = models.foreignkey(something) class bar(models.model): foo = models.foreignkey(foo) option = models.foreignkey(option) admin.py class barinline(admin.tabularinline): model = bar raw_id_fields = ('option',) class fooadmin(admin.modeladmin): raw_id_fields = ('something',) so when create fresh foo object , no barinlines have been defined yet. without saving foo object first limit barinline option field's options adding parameter (e.g. &option__id=<something> ) javascript trigger. how hook javascript callback? i cannot seem find documentation regarding raw_id_field javascript callbacks, seems unlikely there aren't hooks, missing?

python - Connecting to MySQL database via SSH -

i trying connect python program remote mysql database via ssh. i using paramiko ssh , sqlalchemy. here have far: import paramiko sqlalchemy import create_engine ssh = paramiko.sshclient() ssh.set_missing_host_key_policy(paramiko.autoaddpolicy()) ssh.connect('host', port=port, username='user', password='pass') engine = create_engine('mysql+mysqldb://user:pass@host/db') i getting error: sqlalchemy.exc.operationalerror: (_mysql_exceptions.operationalerror) (2003, "can't connect mysql server on 'mcsdev.croft-it.com' (60)") sorry posted duplicated answer before. here more elaborated answer tailored question ;) if still in need of connecting remote mysql db via ssh have used library named sshtunnel, wraps ands simplifies use of paramiko (a dependency of sshtunnel). with code think go: from sshtunnel import sshtunnelforwarder sqlalchemy import create_engine server = sshtunnelforwarder( ('host',

java - Can't connect to MySQL server at 127.0.0.1 using c3p0 -

trying connect mysql server using following code in java c3p0: combopooleddatasource = new combopooleddatasource(); combopooleddatasource.setjdbcurl("jdbc:mysql://127.0.0.1:3306/" + dbname); combopooleddatasource.setuser(username); combopooleddatasource.setpassword(password); combopooleddatasource.setinitialpoolsize(15); combopooleddatasource.setmaxpoolsize(20); combopooleddatasource.setminpoolsize(10); connection = combopooleddatasource.getconnection(); although have checked db , running , can connect using python keeps throwing me following error: info: initializing c3p0 pool...com.mchange.v2.c3p0.combopooleddatasource@b4c966a[ acquireincrement -> 3, acquireretryattempts -> 30, acquireretrydelay -> 1000, autocommitonclose -> false, automatictesttable -> null, breakafteracquirefailure -> false, checkouttimeout -> 0, connectiontesterclassname -> com.mchange.v2.c3p0.impl.defaultconnectiontester, description -> null, driverclas

How to combine timeout and eval commands in bash -

for executing command stored in variable eval command used: └──> a="echo -e 'a\nb' | wc -l" └──> eval $a 2 but how can combined timeout command? i've tried following gives me wrong output: └──> timeout 10 $a 'a b' | wc -l and following gives me errors: └──> timeout 10 "$a" timeout: failed run command `echo -e \'a\\nb\' | wc -l': no such file or directory └──> timeout 10 $(eval $a) timeout: failed run command `2': no such file or directory └──> timeout 10 $(eval "$a") timeout: failed run command `2': no such file or directory the question can stand: how can sure following command executed properly? timeout 10 "$program" "$opt1" "$opt2" ... this work if timeout "$program" "$opt1" "$opt2" ... ; echo program ran else echo program terminated due timeout fi

android - Intent is not working in fragment -

i have below code : public class homefragment extends fragment { private list<rowitem> rowitems; private static integer[] images = { r.drawable.red, r.drawable.spidy, r.drawable.prisoners, r.drawable.red, r.drawable.spidy }; public homefragment() { } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.fragment_home, container, false); listview lv = (listview) rootview.findviewbyid(r.id.mylist); rowitems = new arraylist<rowitem>(); string[] titles = { "movie1", "movie2", "movie3", "movie4", "movie5" }; string[] descriptions = { "first movie", "second movie", "third movie&qu

android - How do I create a new activity for each city? -

forgive me being new android app building. my plan build app take city , open new activity it. problem don't know how go that. plan similar how app yik yak go put marker in area , brings activity location. believe yik yak shows ones close plan take activity location. possible way or should take yik yak's route on , show things within radius of you? where can started on learning how that? first, need choose provider maps. i google map start suggested in tag, beware, might not available on chinese devices without play services. can follow documentation here quick start https://developers.google.com/maps/documentation/android/ regarding number of pins want put on map, see no problem display lot of them, have group markers user zooms out, don't have 10 pins overlapping themselves. if in quite zoomed state, user clicks group of markers, can display dialog choose city. if user zooms in lot , clicks particular pin, can start activity. your main concern list

php - RewriteRule : How can i handle my url -

i need rewrite code .httaccess file can froward url specific folder default page. like if following url not found: www.domain.com/abc/23/121/ >>> www.domain.com/abc/default.php or www.domain.com/xyz/23/121/ >>> www.domain.com/xyz/default.php what ever first folder, redirect folder default file. how can forward url .httaccess error handler file? www.domain.com/xyz/23/121/ when url not found.. take compeler url query string 404.php like : 404.php?url=www.domain.com/xyz/23/121/ try in root/.htaccess : rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^(.*)/?$ /404.php?url=$1 [r,qsa,l]

groovy - How to add new line to description in Jenkins -

how add new line description in jenkins, when change programmatically? i have tried this: job.builds[0].description = "hello" << '\n' << "world" and console scripts prints well: hello world but in description on jenkins, job has "hello world" without newline beetwen hello , world is there way this? ok, found answer. description raw html. to create new line, must write: job.builds[0].description = "hello<br> world" console print hello<br> world , in description newline.

eclipse - Unable to load server class 'com.google.appengine.tools.development.gwt.AppEngineLauncher' -

i using google plugin eclipse develop website using gwt. every thing work before. today installed theme plugin eclipse , uninstall theme plugin after that. when run gwt project error unable load server class 'com.google.appengine.tools.development.gwt.appenginelauncher' java.lang.classnotfoundexception: com.google.appengine.tools.development.gwt.appenginelauncher i have tried reinstall google plugin eclipse , still error. how solve error ? thank help. i have tried reinstall eclipse , google plugin. work ok.

json - Java + jackson parsing error Unrecognized character escape -

i need post json string , using httpclient. following code have. other end json mapped object. httpclient client = httpclientbuilder.create().build(); httppost post = new httppost(url); string jsondata = "{ \"provider\" : null , \"password\" : \"a\", \"userid\" : \"mlpdemo\\mlpdemoins\" }"; post.setentity(new bytearrayentity( jsondata.tostring().getbytes("utf8"))); httpresponse response = client.execute(post); here others correctly mapping expect userid. here problem backward slash( mlpdemo\mlpdemins ). guess. if send single string user id mapped without issues. eg:- string jsondata = "{ \"provider\" : null , \"password\" : \"a\", \"userid\" : \"mlpdemoins\" }"; this works . but need ( mlpdemo\mlpdemins )to sent through post. please me out. string jsondata = "{ \"provider\" : null , \"password\" : \"a\&qu

image processing - Delaunay triangulation : Matlab -

Image
i trying write code using delaunay triangulation method , got plot bunch of triangles. how can verify whether plotted correct or not? or whether triangles desired points or not? = bwmorph(i,'skel',inf); [i1,j1] = ind2sub(size(i),find(bwmorph(bwmorph(i,'thin',inf),'branchpoint') == 1)); tri1 = delaunaytriangulation(i1,j1) figure triplot(tri1) this part of code dt implemented. input dt to have visual check can overlay result of delaunay triangulation onto points hold on . instance: figure hold on scatter(i1,j1, 'r'); triplot(tri1) best,

jquery - How can I pull my popup content from an external file? -

i'm using magnific popup create popup form. works fine long leave inline, if try move form external file, can't seem load in popup. as example - taking code "popup form" demo here , create following file, works expected. here working fiddle (courtesy of @anpsmn in response different question ). however, realized use same form in multiple places, tried move form external file. called magnificform.cfm (i working coldfusion code in real form) , contains form element: <form id="test-form" class="white-popup-block mfp-hide"> <h1>form</h1> <fieldset style="border:0;"> <p>lightbox has option automatically focus on first input. it's recommended use <code>inline</code> popup type lightboxes form instead of <code>ajax</code> (to keep entered data if user accidentally refreshed page).</p> <ol> <li> <labe

ios - CALayer draw outside of rect -

Image
i'm using code add layer custom uiview , works charm: cgrect newrect = cgrectmake(0, 0, self.bounds.size.width, self.bounds.size.height); calayer* heartbackground = [calayer layer]; heartbackground.contents = (__bridge id)([uiimage imagenamed:@"5heartsgray"].cgimage); heartbackground.frame = newrect; [self.layer addsublayer:heartbackground]; but when tried use in draw method using quartz using new rect(like this) cgcontextsavegstate(context); cgrect ratingrect = cgrectmake(250, 100, 150, 20); calayer* heartbackground = [calayer layer]; heartbackground.contents = (__bridge id)([uiimage imagenamed:@"5heartsgray"].cgimage); heartbackground.frame = ratingrect; [heartbackground renderincontext:context]; cgcontextrestoregstate(context); it renders in beginning of frame , not inside of ratingrect. if call [heartbackground setneedsdisplay] disappear. same thing heartbackground.maskstobounds = yes what i

wix - Package the .Net redistributable in my burn bootstrapper -

i'm trying package .net 4.5.2 redistributable burn application, following instructions on page . but fails find file in temp burn location. according log burn tries find file here: [0a14:09c4][2015-05-12t16:48:52]w343: prompt source of package: netfx452redist, payload: netfx452redist, path: `c:\users\simon\desktop\redist\ndp452-kb2901907-x86-x64-allos-enu.exe` but file ends in temporary folder eg. c:\users\simon\appdata\local\temp\{f5207472-d2a0-4b00-b9ee-c535385bde58}\redist\ndp452-kb2901907-x86-x64-allos-enu.exe the instructions this: <payloadgroup id="netfx452redistpayload"> <payload name="redist\ndp452-kb2901907-x86-x64-allos-enu.exe" sourcefile="..\..\binaries\microsoft\netframework\4.5.2\ndp452-kb2901907-x86-x64-allos-enu.exe"/> </payloadgroup> how can make burn in correct location .net installer? rather reference netfxextension gain more control directly referencing .net install pack

javascript - Sigma.js. Directed graph. Arrows don't render -

i have problem rendering arrows of directed graph sigma.js. my gexf graph: <?xml version="1.0" encoding="utf-8"?> <gexf xmlns="http://www.gexf.net/1.2draft" version="1.2" xmlns:viz="http://www.gexf.net/1.2draft/viz" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd"> <meta lastmodifieddate="2015-05-11"> <creator>gephi 0.8.1</creator> <description></description> </meta> <graph defaultedgetype="directed" mode="static"> <nodes> <node id="startnode" label="initial resources"> <attvalues></attvalues> <viz:size value="1.0"></viz:size> <viz:position x="1.0" y="1.0" z="0.0"></viz:position>

playframework - jQuery can't work with play framework -

i searched same problem , found this. jquery not detected in play framework application can't make sense solution problem. made same kind of questions. develop environment - play 2.3.8 - sbt 0.13.8 - java 1.8 - scala 2.11 - mac osx 10.9 - jquery 1.11.3 i'm new on play framework. tried use jquery in *.scala.html, can't work. checked browser can js file livehttp httpheader(304 status) code follwoing. <body> @content <script src="@routes.assets.at("javascripts/jquery.min.js")"></script> <script src="@routes.assets.at("bootstrap/js/bootstrap.min.js")"></script> </body> i know vague, jquery can use always. don't know tell , say. if need more information, please tell me. thank kindness. add want use jquery. <div id="c1" class="carousel slide" data-ride="carousel"> <div class="carousel-inner"> <div class=&

correct declaration of variables in swift -

hi i'm new swift language, first of don't know if permitable topic i'm creating need understand , couldn't find information on web this in swift realized there's couple of ways declaring variable , it's type. don't know differences , don't know use which.. correct me if wrong.. begin with: when var = "when variable becomes type of string" but if type var = 12 //it's type int and on.. apart declare these variables var anything:int or var anything:string so far i'm difference of declaring global variable as var anything:string or var anything:string = string() how decide use , where? thank you i'll start backwards. difference between var anything:string , var anything:string = string() the first 1 declares variable called anything of type string , second initializes calling string's constructor. in first case have tell swift's compiler expect variable - have value or nil. bes

algorithm - Partially coloring a graph with 1 color -

i started reading graph theory , reading graph coloring. problem popped in mind: we have color our undirected graph(not completely) 1 color number of colored nodes maximized. need find maximum number. able formulate approach non cyclic graphs : my approach : first divide graph isolated components , each component. make dfs tree , make 2 dp arrays while traversing root comes last : dp[0][u]=sum(dp[1][visited children]) dp[1][u]=sum(dp[0][visited children]) ans=max(dp[1][root],dp[0][root]) dp[0][i] , dp[1][i] initialized 0,1 respectively. here 0 signifies uncolored , 1 signifies colored. but not work cyclic graphs have assumed no visited children connected. can guide me in right direction on how solve problem cyclic graphs(not brute force)? possible modify approach or need come different approach? greedy approach coloring nodes least edges work? this problem np-hard well, , known maximum independent set problem . a set s<=v said independent set in

e commerce - Yarn shop with related patterns and multiple color buying -

hello tasked creating online yarn shop http://www.redheart.com . them important features want, features able buy multiple different colors of 1 kind of yarn , want there related free pattern can knit it. find myself @ loss @ proper way it. best cms use features bit experienced prestashop , have done few shops it, think build in add cart doesn't support buy multiple colors @ same time , not sure how go related patterns. ideas , suggestions more experienced appreciated. i'm not sure there's out of box that's going without modification. can try woocommerce think you're going need modify of 'out of box' cmses or themes want. should able modify end add second item cart first. possible alternative solution using magento , wordpress bridge, magento supports feature.

java - Put join on Main thread unexpected behaviour -

i wrote following code : public class threaddemo implements runnable { private thread t ; private string threadname; threaddemo(string threadname) { this.t = new thread(this,threadname); t.start(); } public void run() { system.out.println("new thread has been started!!!" + t.getname()); } public static void main(string args[]) { new threaddemo("thread-1"); thread t = thread.currentthread(); try { t.join(); } catch (interruptedexception e) { e.printstacktrace(); } new threaddemo("thread-2"); } } so have putted join method on main thread . when run ,its execution never end. why ? why main thread doesn't end ? why it's running infinite time. the join() method waits thread call on finish. in code, calling join() on current thread - same thread calling from. main thread going wait finish. never happens, because it's waiting on itself... you should not join main thread, thread started instead.

r - Update subset of data.table based on join -

i have 2 data tables, dt1 , dt2: set.seed(1) dt1<-data.table(id1=rep(1:3,2),id2=sample(letters,6), v1=rnorm(6), key="id2") dt1 ## id1 id2 v1 ## 1: 2 e 0.7383247 ## 2: 1 g 1.5952808 ## 3: 2 j 0.3295078 ## 4: 3 n -0.8204684 ## 5: 3 s 0.5757814 ## 6: 1 u 0.4874291 dt2<-data.table(id2=c("n","u"), v1=0, key="id2") dt2 ## id2 v1 ## 1: n 0 ## 2: u 0 i update dt1 based on join dt2, subset of dt1. example, dt1[id1==3] , expect value of v1 in row 4 updated in following result: dt1 ## id1 id2 v1 ## 1: 2 e 0.7383247 ## 2: 1 g 1.5952808 ## 3: 2 j 0.3295078 ## 4: 3 n 0 ## 5: 3 s 0.5757814 ## 6: 1 u 0.4874291 i know how update table (using := assignment operator), how join tables ( dt1[dt2] ), , how subset table ( dt1[id1==3] ). i'm not sure how 3 @ once. edit: note original example attempts update 1 column, actual data requires updatin

Latex on your website -

i trying build new website scratch. as, have write mathematical , chemical expressions in content, , avid user of physics, math , chem stack exchange websites. end product behave similar/if possible same stack exchange thing. i have no idea go implement this. so, how implement same type of latex editor features writing mathematical , chemical expressions in content editor on website. coding , including website might complicated can use called mathurl, check latex in webpage

javascript - OpenTok UI elemnts are not positioned in my HTML DOM elements -

i using opentok add video broadcusting app. app using menu on left side, , tabs on right side. added 2 div elements right side: <div id="mypublisherdiv1"></div> <div id="mypublisherdiv2"></div> //replace first parameter replacement element id: var publisher = ot.initpublisher("mypublisher1", {width:400, height:300}); //replace api key , replacement element id: var subscriber = session.subscribe(tokobj['apikey'], "mypublisher2", {width:400, height:300}) session.publish(publisher); ui displayed on top of menu in left side. did typo ot.initpublisher("mypublisher1" instead of ot.initpublisher("mypublisherdiv1" ? same subscribe block.

testing - Selenium: Select value from a drop down which is dependent on value selected in another drop down -

selenium: have select value drop down dependent on value selected in drop down. ex: have 2 drop downs 1 , 2. value populated in 2 dependent on 1. when select value in dropdown 1 page gets refreshed , value in 2 populated. have select value in drop down 2. i receive error element no longer attached dom . i tried using wait.until((expectedcondition<boolean>) new expectedcondition<boolean>() not me. same issue occurs. i tried using webelement , select neither helped. can me figure out solution? javascriptexecutor executor2 = (javascriptexecutor)driver; executor2.executescript("arguments[0].click();", <elementname>); waitfor(3000); select <objectname1>= new select(driver.findelement(by.id("<id_for_drop_down_1>"))); selectcourse.selectbyvisibletext("<valuetobeselected>"); waitfor(2000); select <objectname2>= new select(driver.findelement(by.id("id_for_drop_down_2"))); selectcourse.selectbyv

javascript - Add css to tooltip in fullcalendar -

everyone! i'm trying change default tooltip red 1 in fullcalendar. i'm using bootstrap, far understand, tooltip see windows one(white rectangle). how can change that? how call tooltip: eventmouseover: function (calevent, jsevent, view) { $(this).find(".fc-content").attr({ "data-toggle": "tooltip", "title": calevent.title, "data-content": calevent.title, "data-container": "body" }).addclass("red-tooltip"); $(this).find(".fc-content").mouseover(function () { $(this).tooltip('show'); }, function () { $(this).tooltip('hide'); }); } this css .red-tooltip + .tooltip > .tooltip-inner { background-color: #f00; } .red-tooltip + .tooltip > .tooltip-arrow { border-bottom-color:#f00; } any appreciated.

express - API return data in CSV format -

i'm creating api should return data in csv format. set content-type header text/csv forces download of contents csv file. i'm using nodejs , express framework. standard behaviour. know how guys solved issue. this sample of code i'm using: res.set('content-type', 'text/csv'); var tocsv = require('to-csv'); // obj standard javascript object. res.send(tocsv(obj)); i person using api can retrieve data in csv format without downloading file maybe have @ question: how browser determine whether download or show it's browser decides content of type " text/csv " should downloaded. you should consider using content-type, if want csv show in browser plain text. try instead: res.set('content-type', 'text/plain');

c# - Why does this generic method call not match? -

i have address class: public class address { //some stuff } and there's corresponding *wrapper class enforce rules on how use address class: public class addresswrapper : iwrapped<address> { private address _wrapped; public address getwrapped() { return _wrapped; } //and more } where iwrapped defined as: public interface iwrapped<t> { t getwrapped(); } i have following generic class saving these entities (there other entities follow pattern of entity , entitywrapper ): public class genericrepository { private genericrepository() { } public static void add<t>(iwrapped<t> entity) { //do } public static void addlist<t>(ilist<iwrapped<t>> entities) { //do } } and have test code: [test] public void usegenericrepository() { addresswrapper addrw = new addresswrapper(); addrw.addrline1 = "x"; addrw.addrline2 = "y

java - Determine whether onPause() was fired by user navigation or by my activity launching another one -

how can determine whether onpause() fired because activity launched new 1 (e.g. photo picker intent) or because user navigated away activity (e.g. pressing home)? a simple solution have state variable in activity fixed values: final static int running = 0; final static int called_something = 1; int state = running: then, whenever launch activity: state = called_something; and when returns: state = running; and in onpause() : switch(state) { case running: // stuff if home etc pressed break; case called_something: // other stuff break; } obviously, can extend further scenarios. may wish catch onbackpressed() make sure handle situation understanding possible.

javascript - Iframe sandboxing with 'allow-same-origin' flag error -

can please provide me more information on error , how 'allow-same-origin' flag works? getting following error in chrome iframe sandboxing: uncaught securityerror: failed read 'contentdocument' property 'htmliframeelement': sandbox access violation: blocked frame @ " http://192.168.0.169 " accessing frame @ " http://192.168.0.169 ". frame being accessed sandboxed , lacks "allow-same-origin" flag. i little confused why need 'allow-same-origin' flag when frame 192.168.0.169 accessing frame same ip address. thank much. you have sandbox attribute in iframe: the sandbox attribute enables set of restrictions content in iframe, , whitelist of enabled permissions, so either remove attribute, or edit fit permissions need. optional permissions found here: https://developer.mozilla.org/en-us/docs/web/html/element/iframe and more info here: http://www.html5rocks.com/en/tutorials/security/sandboxed-iframes

java - Spring MVC not resolving image path stored outside webroot -

i uploading images , videos , creating respective tags video , audio display on view page somehow image , video path not getting resolved. here controller. @requestmapping(value = "/contentupload", headers = "content-type=multipart/*", method = requestmethod.post) public @responsebody string uploadimage(@requestparam("filedata") multipartfile multipartfile, httpservletrequest request ) { string jsonresponse = null; boolean isimage = false; boolean isvideo = false; try { string path = request.getservletcontext().getrealpath("/"); file directory = null; if (multipartfile.getcontenttype().contains("image")) { directory = new file(path + "/uploads/images/"); isimage = true; } else { directory = new file(path + "/uploads/videos/"); isvideo = true; } byte[] bytes = null;

jquery - css overflow:hidden with display:inline-block -

i want use text-overflow: ellipsis cut text when long,but have problems when use overflow:hidden display:inline-block. html: <span class="text"> <span class="inner left">click add overflow</span> <span class="inner right"> long text here</span> </span> <div class="bottom"></div> css: .text { line-height: 50px; font-size: 20px; display: inline-block; } .right { display:inline-block; text-overflow: ellipsis; width: 100px; white-space: nowrap; } .overflow { overflow: hidden; } javascript: $('.text').on('click', function() { $(this).toggleclass('overflow'); $('.right').toggleclass('overflow'); }) jsfiddle: http://jsfiddle.net/zhouxiaoping/knw7m5k2/2/ my question : why there 2px blank between .text element , .bottom element when .text has overflow:hidden attribute why .right elment not align l

java - Swiching window in HtmlUnit -

when using selenium on firefoxdriver switching windows using following code final set<string> allwindowid = driver.getwindowhandles(); final iterator<string> itr = allwindowid.iterator(); while (itr.hasnext()) { if (parentid == itr.next()) { parentid = itr.next(); } else { childid = itr.next(); } } driver.switchto().window(childid); but same code not working when using htmlunitdriver. can ? you comparing string references , not string values, use equals() instead of == . while (itr.hasnext()) { if (parentid.equals(itr.next())) { parentid = itr.next(); } else { childid = itr.next(); } } driver.switchto().window(childid); for details: how compare strings in java? also can re-write same method while (itr.hasnext()) { if (!parentid.equals(itr.next())) { // no need reassign same value parentid

c++ - Skip first iteration over unordered_map -

in for loop auto , iterator iterates on unordered_map . this: using ruleindex = std::unordered_map<uint, symbol*>; ruleindex rule_index; for(const auto & rule_pair : rule_index ) { std::cout << rule_pair.first << ": "; printlist(rule_pair.second, 0); std::cout << std::endl; } assume variables defined properly, since code works fine. question, how can exclude first iteration? example, map contains 3 rows , current loop iterates 0, 1, 2. want iterate on 1 , 2 only. bool is_first_iteration = true; for(const auto & rule_pair : rule_index) { if (std::exchange(is_first_iteration, false)) continue; std::cout << rule_pair.first << ": "; printlist(rule_pair.second, 0); std::cout << std::endl; } the std::exchange call assigns false is_first_iteration , returns previous value. 1 of use cases discussed in the paper proposing std::exchange c++14 . paper shows reference implementation c

Zip Python Array? -

i have big array: [['i love these vitamins far', 'and doctor recommended 5000iu dosage', 'love product! power vitamin power drink!', 'great product - works great!', 'love goes vitamin d!', 'great product', 'best vitamin d3', 'great product! not disappointed.', 'doctor prescribed', 'made in usa'], ['musiclova', 'mg', 'rosie', 'stacey chillemi "author stacey chillemi"', 'denise', 'jim easley', 'betterlife', 'martin a. leddy', 'angela wright', 'bob jama'], ['http://www.amazon.com/gp/pdp/profile/a3hjlbnjmsqbq5', etc .. reviews/r2aq19w7l9d2sp', 'www.amazon.com/gp/customer-reviews/r28ofzc87a7xim', 'www.amazon.com/gp/customer-reviews/r33amkshd88b0q'], 1, 'naturewise'] i have 2 elements @ end want applied every array. want create array of arrays inner array being 1 element

html - How can I add a cover image that sits on top of my bootstrap carousel? -

i have 3 images rotating in full page carousel. i'm trying add "cover" image, speak, sits on top of 3 rotating. image have cutout allows see 3 rotating behind it. i'm not sure place image in html or css like. <header id="mycarousel" class="carousel"> <!-- indicators --> <ol class="carousel-indicators"> <li data-target="#mycarousel" data-slide-to="0" class="active"></li> <li data-target="#mycarousel" data-slide-to="1"></li> <li data-target="#mycarousel" data-slide-to="2"></li> </ol> <!-- wrapper slides --> <div class="carousel-inner"> <div class="item active"> <!-- set first background image using inline css below. --> <div class="fill" style="background-image:url('

visual studio 2010 - How change project name with conditions in c++ -

how can change change name of project executable in c++? i know can in project properties under "configuration properties", want in code, example using conditions #ifdef *something define* //project name a.exe #else //project name b.exe #endif i'm afraid, not possible change executable name code. nearest thing possible define 2 build configurations (like release-a , release-b) different executable names in properties , different defines. can change executable name , defines @ same time chosing configuration.

Reading two columns in CSV file in c++ -

i have csv file in form of 2 columns: name, age to read , store info, did this struct person { string name; int age; } person record[10]; ifstream read("....file.csv"); however, when did read >> record[0].name; read.get(); read >> record[0].age; read>>name gave me whole line instead of name. how possibly avoid problem can read integer age? thank you! you can first read whole line std:getline , parse via std::istringstream (must #include <sstream> ), like std::string line; while (std::getline(read, line)) // read whole line line { std::istringstream iss(line); // string stream std::getline(iss, record[0].name, ','); // read first part comma, ignore comma iss >> record[0].age; // read second part } below working general example tokenizes csv file live on ideone #include <iostream> #include <fstream> #include <sstream> #include <string> #include <vector> int m

web api - Stop Multiple WebAPI requests from Azure Scheduler -

i have web api task , takes couple of minutes based on data. can increases on time. i have azure scheduler job calls web api every 10 minutes. want avoid case second call after 10 minutes overlaps first call because of increase in time execution. how can put smarts in web api detect , avoid second call if first call running. can use autoresetevent or lock statements? or keeping storage flag indicate busy/free better option? persistent state best managed via storage. can long-running activity persist through role reset (after all, role may reset @ time long availability constraints met). ensure think through scenarios long running job terminates halfway through.

c# - Persist Dynamically Added Controls w/ DataTriggers WPF -

i working on wpf project uses caliburn.micro , have hit snag hoping with. have form allows user add new fields separate form intention these new fields persist. able create these controls dynamically following code: grid tmpoutergrid = new grid(); rowdefinition rowdefinition1 = new rowdefinition(); rowdefinition rowdefinition2 = new rowdefinition(); rowdefinition1.height = new gridlength(45, gridunittype.star); rowdefinition2.height = new gridlength(55, gridunittype.star); tmpoutergrid.rowdefinitions.add(rowdefinition1); tmpoutergrid.rowdefinitions.add(rowdefinition2); tmpoutergrid.margin = new thickness(0,0,0,10); grid tmpinnergrid = new grid(); grid.setrow(tmpinnergrid, 0); tmpinnergrid.margin = new thickness(10,0,0,5); tmpinnergrid.opacity = 0; datatrigger d = new datatrigger(); binding b = new binding("displayfieldname"); b.source = _fieldnames[p

screeps - Why won't my Creep stay still? -

i've commanded bunch of creeps positions when command particular 1 keeps spazzing out. i've done nothing different how controlled other creeps doesn't work same. other ones stay still. if(creep == game.creeps["transport1"]) { creep.moveto(harvesterloc.x, harvesterloc.y - 2); creep.transferenergy(game.creeps["transport2"]); } if(creep == game.creeps["transport2"]) { creep.moveto(harvesterloc.x, harvesterloc.y - 3); creep.transferenergy(game.spawns.spawn1); } the first 1 works, 2nd 1 doesn't? location 2nd 1 within ramparts, cause issue? you have typo in line: if(creep = game.creeps["transport1"]) replace = == this: if(creep == game.creeps["transport1"]) = assignment operator, == equality operator. more operators in js in mdn reference .

.net - How can I have a single column on a column chart using MSCharts (within an Asp.Net application)? -

Image
i'm using following code generate chart: public actionresult generatechart() { var chart = new chart(); chart.antialiasing = antialiasingstyles.all; chart.textantialiasingquality = textantialiasingquality.high; chart.width = 500; chart.height = 400; chartarea area = new chartarea(); area.axisy.labelstyle.format = "{0:c}"; chart.chartareas.add(area); series serie = new series(); serie.charttype = seriescharttype.column; serie.points.databindxy(data, "year", data, "amount"); chart.series.add(serie); using (var stream = new memorystream()) { chart.saveimage(stream, chartimageformat.jpeg); return file(stream.toarray(), "image/jpeg"); } } it's simple column chart data sum of amount (y-axis) per year (x-axis). the data variable supplied while testing code has 1 item. item represents year 2015 amount of little bit on 9.000 (no pun intended). as can see i

java - Intellij IDEA - how to find package usage in a project -

i looking @ project's maven pom file lot of dependencies , trying find out if particular dependency used or not. there way in intellij idea find import statements import class particular package? i'm working intellij idea 14 ue. switch view "project" in tree view, go node "external libraries" search particular library (=dependency) , open node select package within library in popup menu of package, click "find usages". alternatively, press alt+f7 (windows)

YII2 Kartik gridview disable pdf export -

how disable pdf export property in kartik gridview? i have installed kartik gridview , gave me following error. the class '\kartik\mpdf\pdf' not found , required pdf export functionality. include pdf export, follow install steps below. if not need pdf export functionality, not include 'pdf' format in 'export' property. can otherwise set 'export' false disable export functionality. please ensure have installed 'yii2-mpdf' extension. install, can run console command application root: php composer.phar require kartik-v/yii2-mpdf: "@dev" i not want installe mpdf. want disable it. can edit it? you should set export property false , it's mentioned in error text. use kartik\grid\gridview; ... <?= gridview::widget([ ... 'export' => false, ]) ?> read more in official docs . update: another way exclude pdf format exportconfig . <?= gridview::widget([ 

ios - CallState is never CTCallStateDisconnected? -

i using corelocation framework , trying see whether user in phone call or not. placed code within function in corelocation called every second or so, , finds if user has changed locations. when run application, able detect if call coming in , when call connected, when call hangs up, nothing ever prints. below code: func locationmanager(manager: cllocationmanager!, didupdatetolocation newlocation: cllocation!, fromlocation oldlocation: cllocation!) { if let calls = currcall.currentcalls as? set<ctcall> { call in calls { if call.callstate == ctcallstatedisconnected{ println("disconnected") } else if call.callstate == ctcallstateconnected{ println("connected") } else if call.callstate == ctcallstateincoming{ println("incoming") } } } } the print statement "connected" , "incoming

c# - ServiceStack LoadReferences when using SQL Query -

is possible load references when instead of using code below: sqlexpression<customer> q = db.from<customer>(); q.join<customer,customeraddress>((cust,address) => cust.id == address.customerid); list<customer> dbcustomers = db.loadselect(q); using this: public class kpitotal : ikpitotal { public datetime date { get; set; } public int teamid { get; set; } public team team { get; set; } public int accountid { get; set; } public account account { get; set; } public double total { get; set; } } var result = dbcon.selectfmt<kpitotal>(@"select convert(date, t.transactiondate) [date], tm.teamid,a.accountnumber, count(distinct(t.requisitionnumber)) total task.tbltransactions t inner join task.tblrequisitions r on r.requisitionnumber = t.requisitionnumber inner join task.tblaccounts on a.accountnumber = r.accountn

ruby on rails - who changed the value of "params[:tab]"? -

in 1 erb file called x.html.erb , confused following little snippet code: <% params[:tab] |= "excursion" %> <% availablemodels.each |modelname| %> <% if modelname == "excursion" %> <li class="<%= params[:tab]=='excursions' ? 'active':''%>"> <a id="excursions_tab" href="#tabexcursions" data-toggle="tab"> excursions </a> </li> <% elsif modelname == "workshop" %> <li class="<%= params[:tab]=='workshops' ? 'active':''%>"> <a id="workshops_tab" href="#tabworkshops" data-toggle="tab">workshop </a> </li> <% end %> i found can not figure out how params[:tab] changed such params[:tab] = 'excursions' to params[:tab] = 'workshops' , or vice versa, or said