Posts

Showing posts from May, 2015

c# - getting Guid from database -

something strange happend, no longer able guid type mysql database .net entity model. a while ago created database used guid's id. created connection database entity framework , worked fine. however lost database while ago , had create again, however, classes created entity framework model have string id, not guid used be. what type need make id's in mysql database can following: image.id = guid.newguid(); entitymodel.image.add(image); entitymodel.savechanges(); this used work fine, (obviously) error: "cannot implicitly convert type 'system.guid' 'string'" i cannot remember how once did , wondering if people here help. did read uuid() that's not how did it. somehow i've got feeling mysql updated , somehow it's no longer possible seems odd me. i did , saw lot of people suggesting making id's binary type in mysql , converting guid it's binary form , storing that. i'm hoping not write conversion class implicitly c...

rust - How do I ensure that a spawned Child process is killed if my app panics? -

i'm writing small test starts daemon process , tests e.g: let server = command::new("target/debug/server").spawn(); // tests server.kill(); the typical way fail test panic. unfortunately means kill() never gets invoked , repeated runs of test suite fail, because port taken old process still running. is there trap function can use ensure child gets killed? you can put possibly-panicking code closure , give closure catch_panic . catch_panic acts same way scoped or spawn ed thread on join ing. returns result either ok(closureretval) or err(box<any>) if closure panicked. let res = std::thread::catch_panic(|| { panic!("blub: {}", 35); }); if let err(err) = res { let msg: string = *err.downcast().unwrap(); println!("{}", msg); } playpen

html5 - SVG with Shadow not displaying on some pages in Firefox -

so here's svg script (i have embedded on page): <svg id="carttab" viewbox="0 0 600 65" preserveaspectratio="xminymin"> <defs> <filter id="tabshadow" x="-10%" y="-10%" width="110%" height="110%"> <feoffset result="offout" in="sourcealpha" dx="0" dy="0" /> <fegaussianblur result="blurout" in="offout" stddeviation="2" /> <fecomponenttransfer> <fefunca type="linear" slope="0.3"/> </fecomponenttransfer> <femerge> <femergenode/> <femergenode in="sourcegraphic"/> </femerge> </filter> </defs> <path fill=...

writing string to file in java -

below 2 classes. have problem writing string file in java. why in file xml.txt null? why can't write string = px.readxml(url) ? in xml.txt i've null package xml; import java.io.filewriter; import java.io.ioexception; import java.io.printwriter; import java.net.*; import java.util.stringtokenizer; import javax.xml.parsers.*; import org.w3c.dom.*; import org.xml.sax.saxexception; public class printxml { public string readxml(url url) throws parserconfigurationexception, malformedurlexception, ioexception, saxexception { //url url = new url("http://www.nbp.pl/kursy/xml/a093z150515.xml"); documentbuilderfactory factory = documentbuilderfactory.newinstance(); documentbuilder builder = factory.newdocumentbuilder(); document doc = builder.parse(url.openstream()); element root = doc.getdocumentelement(); //system.out.println(root.gettagname()); nodelist children = root.getchildnodes(); int liczba...

javascript - Three condition button based on Angular -

i new angular feeling lost in of it's documentation. problem: trying create button has 3 phases: add user - remove request - remove user so if want add user click on add button , sends ajax request server , if successful button should turn pending button . in pending state if click on again, request deleted , again turn add button . the third phase if user has accepted request, seeing remove user button when click on again see add button if click pending button , forth. so familiar button if you've been using social networks. when page loaded user see users , buttons each user based on it's current condition (so server handling part). part angular should handle ajax calls , changing of button per user connection request. what need: have done ajax part sending request. can't manage handle part angular needs change button it's new state (for specific user on list, meaning list has more 1 user can send connection add/pending/delete requests.) ...

javascript - Phonegap media plugin one sound at time -

i tried make image/sound gallery phonegap media plugin, ran 1 problem. when click on picture, sound plays, when click on 1 plays 1 too. idea how can let them play 1 sound @ time? <script type="text/javascript" charset="utf-8"> // audio player // var my_media = null; var mediatimer = null; // play audio // function playaudio(src) { // create media object src my_media = new media(src, onsuccess, onerror); // play audio my_media.play(); // update my_media position every second if (mediatimer == null) { mediatimer = setinterval(function() { // my_media position my_media.getcurrentposition( // success callback function(position) { if (position > -1) { ...

javascript - collapse row on click -

i'm working on code have difficulties implementing properly. wan place arrow in front of question , synchronize click event text. jsfiddle.net/tx8pal7l/5/ can me fix issue? html: <div class="container faq_wrapper"> <div class="row"> <div class="span10 offset1"> <p> &nbsp;</p> <div class="faq-all-actions"> <a class="faq-expand">expand all</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a class="faq-collapse">collapse all</a></div> </div> </div> <div class="row"> <div class="span10 offset1"> <div class="question-wrapper"> <div class="arrows"> &nbsp;</div> <div class="big-q"> ...

rotation - How to rotate a THREE.PlaneBufferGeometry with THREE.WaterShader and MirrorMesh -

in this example have three.planebuffergeometry watershader , water normals texture. if try delete rotation @ line 119, plane rotates expected shader , normals aren't working correct anymore distorted. how can rotate without distortion?is changed @ watershader.js file? i managed solve problem.. thought there changed @ watershader.js file. @ vertexshader (line 24) need change line 34 : worldposition = mirrorcoord.xyz to worldposition = mirrorcoord.xzy and problem solved!

Infotec's Web Builder is not displaying Excel content -

i changed archive content resource archivo.pdf file file archivo 1.xls , iframe shows web builder's 404 default error page. the same page shown when clicking resource administration. when files contain blanks (white spaces, \r etc) , non ascii characters happends, change name of file , accesible.

java - OSGi - should I create service tracker for every bundle? -

i have 10 bundles (a,b,c..). , in bundle want create service tracker track services implement interface. these osgi services can in bundle (a,b,c..). thought should create 1 service tracker , start it. however, confuses me it's necessary pass reference bundlecontext constructor (of bundle???) public class myservicetracker extends servicetracker{ public myservicetracker(bundlecontext context){ super(context, someinterface.class.getname(), null); open(); } .... } and in javadoc says (about constructor) context - bundlecontext against tracking done. the question - why should pass bundlecontext, bundlecontext should pass or should create instance of tracker every bundle (a,b,c..)? each bundle uses service need own servicetracker. servicetracker use bundle's context find , bind services. not want use context of bundle track services bundle since many things not work such service hooks since services appear used 1 bundle context used ...

navigation - MATLAB Calculate time given Aircraft trajectory -

i'm trying calculate cumulative time of aircraft trajectory given following parameters: roll pitch trueheading headingrateofchange xvelocity yvelocity zvelocity latitude longitude altitude the data file contains 10,000 points each of above parameters, representing trajectory @ each of points. so far, have done calculate radial velocity squaring velocity components, summing them, , taking square root of sum i.e: rvelocity = sqrt(vx.^2 + vy.^s + vz.^2) % 9999x1 column vector then use matlab distance function calculate arclength distance: al = distance(pt1,pt2,wgs84ellipsoid) % 9999x1 column vector finally, divide al rvelocity: time = al./rvelocity % 9999x1 column vector after work, seems bogus answer... can recommend better way implement this?

ios8.3 - iOS system libraries leaks normal? -

Image
seems system libs, none app. i using afnetworking , ponydebugger arc way. are these leaks normal? does tool give false positives? http://i.stack.imgur.com/nwyib.png recently had similar question, here's quote apple's instruments guide an instrument such leaks instrument can point out places app not handling memory properly. if graph leaks relatively empty, know app behaving properly well, appkit, uikit , other developed people, there can bugs! far know track them. so, generally, if don't see objects create in code, , sure not yours 100%, ios business , if relatively empty, ok. though difficult tell afnetworking external library.

javascript - Bootstrap Collapse missed event when mousing through quickly -

i have run problem when using bootstraps collapse , hover event. there small delay (not sure if supposed happen) , if mouse out before delay complete mouse out not caught. can same thing mousing out , in before delay. i have created js-fiddle example of happening. https://jsfiddle.net/3g2gdyn4/4/ <body> <div class="box"> <div class="box_area"> </div> <div class="box_dropdown"> <ul> <li>test</li> </ul> </div </div> </body> $(document).ready(function () { $(".box_area").hover(function(e) { $(".box_dropdown").collapse("show") }, function(e) { $(".box_dropdown").collapse("hide") }); }) .box_area { width: 200px; height: 200px; border: solid black 1px; } .box_dropdown { display: none; width: 200px; border...

How can I shorten the command for making a Git commit with author specified, without setting global configuration? -

i working on scripts on shared server, , need commit progress git repository periodically. since server , user logged in both shared, don't want set global user names , e-mails, common solution not entering commit author every time. if don't specify author, git assume name name based on shared system's user , host names, commits won't associated me. have been making commits following command address this: git commit -m "commit message" --author="firstname lastname " how can shorten command don't have type out author every time, without setting global configuration options? here @ least 2 options address this: set repository-specific options have each user uses machine make own clone of repository. then, each user can set local user name , e-mail configuration option in copy of repository: git config user.name "firstname lastname" git config user.email "email@domain.com" simply leaving off ...

android - Appcompat v7 Material checkbox changing color to default black in Lollipop devices -

i using appcompat v7 material checkbox. project theme light blue, assigning light blue checkbox checked color in styles.xml follows <!--checked color--> <item name="coloraccent">@color/light_blue</item> <!--un checked color--> <item name="android:textcolorsecondary">@color/secondary_text</item> in layout file <checkbox android:id="@+id/chk_tick" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@drawable/abc_btn_check_material" android:layout_gravity="center"/> everything works fine versions below kitkat's, problem arises lollipop versions ( default automatically assigning black color ). dont know why happening. kindly please me solutions. in advance remove line: android:button="@drawable/abc_btn_check_material" your checkbox should styled autom...

data.table - R: RunningTotal in the last 365 days window by Name -

this data looks like. rightmost column desired column. name eventtype eventdate salesamount runningtotal runningtotal(prior365days) john email 1/1/2014 0 0 0 john sale 2/1/2014 10 10 10 john sale 7/1/2014 20 30 30 john sale 4/1/2015 30 60 50 john webinar 5/1/2015 0 60 50 tom email 1/1/2014 0 0 0 tom sale 2/1/2014 15 15 15 tom sale 7/1/2014 10 25 25 tom sale 4/1/2015 25 50 35 tom webinar 5/1/2015 0 50 35 i trying running total of salesamount each name in last 365 days window. general "runningtotal" column used: df<- df%>% group_by (name)%>% mutate(runningtotal = cumsum(salesamount)) but dont know how running total in last 365 d...

c# - How to use Selenium to grab nested LinkText? -

i'm using selenium in c# click on link called 'store locator'. current code follows not click on link: iwebelement storelink = driver.findelement(by.linktext("store locator")); here original html, notice there span element nested in tag, not sure if makes difference. <a href="/site/olspage.jsp?id=cat12090&amp;type=page&amp;rdct=n" data-lid="hdr_stl"><span class="header-icon-storefinder" aria-hidden="true"></span>store locator</a> seems link hidden. if selenium finds link not able interact directly. in case javascript option by xpath = by.xpath("//span[contains(text(),'store locator')]"); iwebelement element = driver.findelement(xpath); ((ijavascriptexecutor)driver).executescript(@"arguments[0].click();",element);

automatically remove source files after collectstatic with django-pipeline -

with django-pipeline, possible automatically remove source files after collectstatic ? for example : pipeline_js = { 'stats': { 'source_filenames': ( 'js/jquery.js', 'js/d3.js', 'js/application.js', ), 'output_filename': 'js/stats.js', } } collectstatic : $ python manage.py collectstatic $ ls static/js jquery.js d3.js application.js stats.js (i don't want jquery.js, d3.js, application.js) django-pipeline sends signals whenever compiles package, can read more in docs , , signals in general here . can hook signal this: from pipeline.signals import js_compressed def clear_files(sender, **kwargs): print kwargs if 'package' in kwargs: print kwargs['package'].sources # here remove unwanted files js_compressed.connect(clear_files)

Convert Matlab struct array to cell array -

can matlab struct array converted cell array without iterating through array? i want each struct in struct array become 1 cell in cell array. command struct2cell doesn't seem breaks out each field in struct separate cell. this has been posted to: convert matlab struct array cell array http://groups.google.com/forum/#!topic/comp.soft-sys.matlab/xiotcs5hpeg try num2cell : mystructcell = num2cell(mystruct); for example: >> mystruct(1).name = 'john'; >> mystruct(2).name = 'paul'; >> mystruct mystruct = 1x2 struct array fields: name >> mystructcell = num2cell(mystruct) mystructcell = [1x1 struct] [1x1 struct] >> mystructcell{1} ans = name: 'john' >> mystructcell{2} ans = name: 'paul' >> mystructcell{2}.name ans = paul

java - Missing method call for verify(mock) here -

i have problem mockito. code program public boolean bajacontribuyente(string dni){ contribuyente c = em.find(contribuyente.class, dni); if(c!=null){ em.remove(c); return true; } return false; } and test: @beforeclass public static void setupbeforeclass()throws exception{ contribuyentedao.setem(em);; when(contribuyented.getdni()).thenreturn("4"); when(em.find(contribuyente.class, "4")).thenreturn(contribuyented); } @test public void testbajacontribuyente(){ contribuyentedao.bajacontribuyente("4"); verify(em).find(contribuyente.class, "4"); verify(em).remove(contribuyented); } junit missing method call verify(mock), dont know why you need add static import of mockito's methods (e.g. verify), following: import static org.mockito.mockito.*;

asp.net - stream pdf from MemoryStream -

Image
i'm streaming pdf .ashx file browser using following code: context.response.clear(); context.response.charset = ""; context.response.contenttype = "application/pdf"; context.response.addheader("content-disposition", "inline;filename=test.pdf"); context.response.addheader("content-length", stream.length.tostring()); stream.writeto(context.response.outputstream); context.response.flush(); context.response.end(); where context comes from: public void processrequest(httpcontext context) all works when using chrome or firefox , displays on browser. when use ie 11 blank screen. if go adobe reader->edit->preference->internet , uncheck "display pdf in browser" ie opens adobe reader , shows pdf properly. unchecked "display pdf in browser" shows blank screen: if go ie "manage add-ons" shows adobe enabled: i've seen other post nothing seems work. i'm thinking ie thing since...

How to perform one time action on first login using ASP.NET MVC5 Windows Authentication -

i creating web application using asp.net mvc5 framework 'windows authentication' - i.e. creating intranet application authenticating users against active directory. when new user defined in company's active directory, i'd need catch first login , redirect him onto profile page, user prompted fill info. i able catch user's first login simple database, if user has here own record in table. if not, user here first time , can create him such record. here comes deal - after extensive searching through possibilities seems "reasonable" way how via custom authenticationfilter - put db check logic into onauthenticationchallenge(authenticationchallengecontext filtercontext) method. the reason why put "reasonable" quotes on 1 hand, approach fits mvc philosophy - mean not 'hack' approach. on other hand - since using windows authentication, there no login action in controller. user can type whatever 'www.mysite.com/controller/act...

ios - Weird crash while navigating back -

my app crashes randomly when navigating in navigationcontroller . here know: it happens randomly (sometimes, can come once or twice , if reload viewcontroller , press "back" again crash) it happens empty viewcontroller (i tried comment out code in viewcontroller.h , .m , remove outlets links) nothing shows in debug console, exec_bad_access shown in main.m i spent afternoon on , tried everything. don't include code right because have no idea look. said, happens empty viewcontroller . any thoughts or similar experience ? edit: yes tried add exception breakpoint i tried find observer issues spark debugger. edit 2: actually, viewcontrollers not that empty. import on uiview category problem. check answer below. it's difficult causing without more information, in experience common reason exc_bad_access when tries call selector on deallocated instance. issue can lot easier debug if enable zombie objects. edit scheme -> diagnostics...

android intent - How do I pass two different edit-text by a button, to a new activity with a text-view as a result? -

i'm new @ programming android studio, , i'm trying is, when type first name in edit text , last name in edit text on mainactivity, click button , shows full name textview in secondactivity. as know know, searches i've made, need use intent pass down information between activities, , button work need use "onclick" on layout xml, , setonclicklistener on mainactivity ? don't where. but main thing want know here, how two edit text, intent, show on new activity, click of button. i've tried example found online, crashes on bq aquaris e4,5 (api 19), not sure why. also tried doing myself, using of previous example , video youtube video but got rather confusing, since video ain't want exactly, other example wanted, didn't work, it's 1 tuturial passing data between activities if can me out described in beginning work, grateful. thanks in advance, best regards, sir rudi edit: wrote on android manifest, on example tried: <activity...

java - Executing 'adb logcat' command using Runtime class -

i trying logcat content jtextpane. used following code hoping return content string freeze , also, doesn't produce error. process exec = null; try { exec = runtime.getruntime().exec("adb logcat -d"); inputstream errorstream = exec.geterrorstream(); bufferedreader ebr = new bufferedreader(new inputstreamreader(errorstream)); string errorline; while ((errorline = ebr.readline()) != null) { system.out.println("[error] :- " + errorline); } if (exec.waitfor() == 0) { inputstream infostream = exec.getinputstream(); inputstreamreader isr = new inputstreamreader(infostream); bufferedreader ibr = new bufferedreader(isr); string infoline; while ((infoline = ibr.readline()) != null) { system.out.println("[info] :- " + infoline); } } } catch (ioexception | interruptedexception ex) { ...

JSON Deserialize ( NewtonSoft JSON.NET) to XML Failure -

i have no experience json @ all, unfortunately have webservice returns data me. need format data json xml can import our own system here. i receive data web service in format: { "httpstatuscode": 200, "messages": [], "succesfulresponses": [ { "position": 0, "response": { "dln": "aaapy459037vb9sv", "dvlaserviceversion": "1", "hubserviceversion": "1.0.0.0", "dvlaprocessingdate": "2014-12-22t14:03:43.557z", "hubprocessingdate": "2015-05-29t16:50:51.4364004+01:00", "licence": { "status": "fc", "validfrom": "1986-01-22", "validto": "2017-09-02", "directiveindicator": 0, "entitlements": [ { "code": "a", "validfrom": null, ...

R: rearrange columns of dataframe, based on rank -

i have following dataframe (df1) type ca ar or alpha 2 3 5 beta 1 5 6 gamma 6 2 8 delta 8 1 9 total 17 11 28 i want reorder dataframe such in descending order, based on "total" row. the resulting dataframe should (df2) type or ca ar alpha 5 2 3 beta 6 1 5 gamma 8 6 2 delta 9 8 1 total 28 17 11 notice columns ordered before "ca, ar, or" have become "or, ca, ar" based on total row (ordered in descending order.) in order this, attempted use rank function follows: rank_total <- rank(-df1) this gives me ranks: [1] 2 1 3 however, don't know how reorder, based on these ranks. does know how continue here? or if there way altogether, great! thanks in advance!! try df2 <- df1[,c(1, order(-unlist(df1...

java.lang.NoClassDefFoundError: javax/persistence/Converter Exception using hibernate with tomee and maven -

i have following exception: org.apache.openejb.openejbexception: creating application failed: /home/mmarnc/apache-tomee-webprofile-1.7.1/webapps/name_vorname: javax/persistence/converter @ org.apache.openejb.assembler.classic.assembler.createapplication(assembler.java:896) @ org.apache.openejb.assembler.classic.assembler.createapplication(assembler.java:623) @ org.apache.tomee.catalina.tomcatwebappbuilder.startinternal(tomcatwebappbuilder.java:1248) @ org.apache.tomee.catalina.tomcatwebappbuilder.configurestart(tomcatwebappbuilder.java:1087) @ org.apache.tomee.catalina.globallistenersupport.lifecycleevent(globallistenersupport.java:130) @ org.apache.catalina.util.lifecyclesupport.firelifecycleevent(lifecyclesupport.java:117) @ org.apache.catalina.util.lifecyclebase.firelifecycleevent(lifecyclebase.java:90) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5378) @ org.apache.catalina.util.lifecyclebase.start(lifecycle...

php - symfony amazon S3 database -

i have project in symfony 2.6 i=use amazon s3 service , photo upload in server amazon. dump url photo this: https://s3-eu-west-1.amazonaws.com/aog-db-files-stage//2015/05/29/55688589ecdb4.jpg , question how write url in database , read photo template ? entity photo class photo { /** * @orm\id * @orm\column(type="integer") * @orm\generatedvalue(strategy="auto") */ private $id; /** * @orm\column(type="string") */ private $title; /** * @gedmo\timestampable(on="create") * @orm\column(type="datetime", name="createdat") */ protected $createdat; /** * @orm\column(name="photo_storage") * @assert\file( maxsize="20m") */ private $photo; and have formtype entity public function buildform(formbuilderinterface $builder, array $options) { $builder ->add('title') ->add('photo', 'file', array( 'label' ...

angularjs - Hide div when there are no result due to a filter -

how can know when there no results display due filter? <input type="text" class="form-control" ng-model="search" placeholder="search..."> <div ng-show="contents.length !== 0"> <h2>contents</h2> <div class="panel panel-default" ng-repeat="content in contents | filter:search"> <div class="panel-heading"> <h3 class="panel-title">{{content.title}}</h3> </div> <div class="panel-body">{{content.description}}</div> </div> </div> see solution working in plunker simply using trick. ng-show="(contents | filter:search).length !== 0"

Collapse columns in some rows to the row with least number of columns in R -

i'd know how collapse columns in dataframe row least number of columns without nas. rows 3 columns, , rest of filled na. other rows have columns filled numbers , no nas. have provided sample dataset below , i'd ideal outcome. in ideal data frame below, middle column becomes column 2. instance, row 5 columns collapses columns 1 & 2 1, , 4 & 5 3. a <- c(1, 1, 1, 1, 1, 1) b <- c(2, 2, 2, 2, 2, 2) c <- c(3, 3, 3, 3, 3, 3) d <- c(na, 4, na, 4, 4, na) e <- c(na, 5, na, 5, 5, na) f <- c(na, na, na, 6, 6, na) g <- c(na, na, na, 7, 7, na) df <- data.frame(a, b, c, d, e, f, g) ideal data.drame ai <- c(1, 3, 1, 1, 5, 1) bi <- c(2, 3, 2, 2, 4, 2) ci <- c(3, 9, 3, 3, 18, 3) di <- c(na, na, na, na, na, na) ei <- c(na, na, na, na, na, na) fi <- c(na, na, na, na, na, na) gi <- c(na, na, na, na, na, na) dfi <- data.frame(ai, bi, ci, di, ei, fi, gi) the reason have dataset on politics , demographics need clean analysis. each ro...

ios - Sprite edge cut off on right side -

i'm making game using cocos2d , sprites kept in texturepacker sprite sheet. couple of days ago realized of sprites missing column of 1 2 pixels off right side. sprite png files , texturepacker file display sprites correctly, ingame sliced. looks sprite image offcenter of texturerect. doesn't seem happen sprites, i'm noticing enough of them may be. so far i've tried messing around texturepacker settings nothing fixing it. ideas?

Set an x-axis of a histogram in matlab to get a subset of the histogram -

i have histogram plotted in matlab , want work section of histogram. have found how change x-axis overall, plots entire histogram on new axis instead of pulling subset of histogram. there way work section of histogram selecting x-axis? you can plot of histogram want choosing subsection of matrix, bins = 100 xmin = 40 xmax = 60 [f,x]=hist(randn(1000000,1),bins); bar(x(xmin:xmax),f(xmin:xmax)) alternatively, can plot on specified range of x bin values, xvalues = -1:0.1:0.9; [f,x]=hist(randn(1000000,1),xvalues); bar(x,f,'b') but values outside range collected in bins @ either end if range.

android - Fragment getActivity() -- avoiding NPE -

i have single activity application number of fragments (15 or so). of methods in myactivity required fragments, such displaying dialogs . have in sample call fragment (and extend myfragment ) like: getmyactivity().displaydialog(msg); and getmyactivity defined in myfragment : myactivity getmyactivity() { return (myactivity) getactivity(); } however, getactivity() null npes in case. i'm doing moving methods myfragment such that: protected void displaydialog(string msg) { if (getmyactivity() != null) { getmyactivity().displaydialog(msg); } else { // do here? } } does approach make sense 10 or methods need reference myactivity (and there pitfalls doing so)? also, provide feedback in case getactivity() null? edit: common example of cause nullpointerexception network call being dispatched fragment , on completion of said network call, trying display dialog when activity destroyed in meantime. its better use parentfragment example publi...

Opening Chrome with Python / Mechanize -

i trying program automation tool online game called travian. want login using python browser object (created using mechanise library). once have logged in want open real webbrowser (ie. chrome). #here create mechanize browser object b = mechanize.browser() #usually login game go # site , put in login , password , press submit server = 'http://ts4.travian.com/?lang=en' #i trying here use browser object submit form, #maybe there mistake here b.open(server) b.select_form("login") b.form["name"] = 'myaccount' b.form["password"] = 'mypassword' b.submit() #once mechanise has submitted form want #open page in chrome #opened if submit hand gamepage = ("http://ts4.travian.com/dorf1.php") webbrowser.open_new_tab(gamepage) when run code opens login page, is, code logs in game not seem have worked. have tried: b.addheaders = [('user-agent', mozilla/5.0 (x11; u; linux i686; en-us) applewebkit/53...

table - jquery draggable/droppable div in multiple divs -

i want create table each cell can contain element (div) can dragged , dropped in other cells. seems element can dropped origin div. don't understand why doesn't work. <style> .over { border: solid 4px #acfa58; } .draggable { border: solid 4px red; width:150px; height:75px; } #timetable{ margin-top:50px; width:100%; border-collapse:collapse; border: 1px solid black; } #timetable th{ text-align:center; } #timetable td{ width:150px; height:75px; border: 1px solid black; } </style> <script> $(document).ready(function() { $(".draggable").draggable({ cursor: "crosshair", revert: "invalid" }); $(".drop").droppable({ accept: ".draggable", drop: function(event, ui) { console.log("drop"); $(this).removeclass("border").removeclass("over"); var dropped =...

access vba - How do i protect string in text box? -

i have problem text box named "txtprice". want protect text box string. if input 1 string show message wrote. if input, example "12r", doesn't anything. dim integer dim s long = asc(txtprice) if < 48 or i> 57 'ascii number msgbox "error" end if what looking for? under properties can specify input mask. you can try if not isnumeric(txtprice) if you're looking number. if don't want letters, try this: dim intpos integer intpos = 1 len(txtprice) select case asc(mid(txtprice, intpos, 1)) case 65 90, 97 122 isletter = true case else isletter = false end select if isletter exit next intpos if isletter msgbox "error" end if

SQL to query same columns with name and value in the same table -

i have table 3 columns id name value 1 m1 v1 2 m2 v2 3 m3 v3 4 m4 v4 5 m5 v5 select * table name = m1 , value = v1 , name = m2 , value = v2 but wont return values . can please how write sql handle above situation. you need or name cannot equal m1 , m2. ` try select * table (name=m1 , value=v1) or (name =m2 , value =v2)

classification - how to implement a general image classifier using SIFT and SVM -

Image
i want train svm classifier image categorization scikit-learn. , want use opencv-python's sift algorithm function extract image feature.the situation follow: 1. scikit-learn's input of svm classifier 2-d array, means each row represent 1 image,and feature amount of each image same; here 2. opencv-python's sift algorithm returns list of keypoints numpy array of shape . here question is: how deal sift features fit svm classifier's input? can me ? update1 : thanks pyan's advice, i've adapt proposal follow: 1. sift feature vectors each image 2. perform k-means clustering on vectors 3. create feature dictionary, a.k.a. cookbook, based on cluster center 4. re-represent each image based on feature dictionary, of course dimention amount of each image same 5. train svm classifier , evaluate it update2: i've gathered image sift feature vectors array(x * 128),which large, , need perform clustering on it. problem is: if use k-means , parameter c...

php - Laravel relationship structure -

i have table of fixtures looks this; user_id opponent_id gameweek league_id i have results table stores result of fixture , when come in. user_id gameweek league_id result what struggling relationship between 2 , how call relationship when need it. essentially, each fixture contains 2 results; 1 user_id_result , 1 opponent_id_result (both of refer id in users table) i did in fixture model; public function userresult() { return $this->hasmany('app\models\result', 'league_id', 'league_id') ->where('user_id', $this->user_id) ->where('gameweek', $this->gameweek); } and, although worked, don't think it's quite right , did not work when called through eager loading. thanks guys. this doesn't seem database structure root of problem lies. both tables have 3 columns same thing. not inefficient confusing. at first glance, make more sense drop 3 columns in results ta...

itunesconnect - iOS app transfer - Bundle id not available -

it's first time i'm transferring app, , want release un update app received. i have questions: i tried create bundle id old 1 (com.example.app) developer center said it's not available. should use 1 or one? if use bundle, old users receive update? if should use original app bundle, how can unlock it? you want use old one. if use different bundle id (e.g., com.example.app2), users not receive update expect: itunes connect , app store treats them separate apps. my understanding wouldn't "create" new bundle id either, exist in apple's systems. should able use developer center create development and/or distribution provisioning profiles newly transferred app id, ensure id in use in xcode project. when you're ready distribute, archive product (or use build system sign app store distribution profile), , upload itunes connect using login associated itunes connect account received incoming id. this contingent upon itunes connect login ...

python - Django non-ASCII chars in template tags values -

i'm writing custom django template tag french application. template tag takes parameter string: {% mytag "hello" %} is works perfect, fails when trying put non-ascii chars in value. how thing work: {% mytag "Êtes-vous à paris ?" %} i got error: 'ascii' codec can't encode character u'\xca' in position 0: ordinal not in range(128) unicode error hint the string not encoded/decoded was: Êtes-v thanks in advance! edit: python version 2.7 . here code of tag: @register.simple_tag(takes_context=true) def mytag(context, my_var): return "here is: {my_var}".format(my_var=my_var) try replacing return "here is: {my_var}".format(my_var=my_var) by return u"here is: {my_var}".format(my_var=my_var) in python 2.7, "here is: {my_var}" str object, encoded string, my_var unicode object, decoded string, when formatting, python try encode my_var matches type o...

Update two elements of array on single operation on MongoDB -

i have document one: { name:'name', periods:[ { name:'period 1', active:true }, { name:'period 2', active:false } ] } i want have 1 active period per unit of time, so, activate period 2 , have deactivate period 1 , activate period 2 . how can 1 atomic update operation?

android - How to show arc at the end of page in cordova mobile application? -

when user scrolls down , comes end, , still tries scroll down, arc appears. example, in whatsapp, on message window, can't scroll down if @ end , arc appears. how can in cordova mobile app ( android ) using angular.js , ionic? or name of property ? thanks in advance answer: i found property ionic framework. not want, shows there no more data after last ion-list item bouncing page. if has-bouncing attribute added ion-content, page bounce. attribute's value true default ios, don't need add it, have add android. <ion-content has-bouncing="true"> </ion-content> when scroll down, mean using on-infinite-scroll for exemple, use following function mymodel.maxitemloaded boolean false, except if loaded items. <ion-infinite-scroll ng-if="!mymodel.maxitemloaded" icon="ion-loading-c" on-infinite="loadmoredata()" distance="10" > </ion-infinite-scroll> t...

vb.net - How can I link values in a text file to values in a SQL Server table? -

update 2 essentially, i'd pass datatable sql server, not "create it", temporary thing using: cmd.commandtext = "select * table1 inner join datatable on sample.name = datatable.name" how can pass datatable vb.net (.net 2.0) sql server in similar fashion? update 1 so i'm thinking maybe passing data text file datatable , using compare against sql server table? how go doing if @ possible? original post have table in sql server 2012 (i.e., dbo.sample1) within table there column contains names (i.e., abc01, abc02, abc03, hijk01, hijk02...) i ran vb code extract file names without extension directory on machine (i.e., abc01, abc02...) met conditions, these file names saved on separate lines within text file. is there easier convenient way of linking names on text file ones on table not show rows not on text file? figured can sit , plug in bunch of name = 'abc01'... didn't w...

python - How to fetch foreign key relationships in mongoengine -

i have following 2 models. class url(mongoengine.document): codes = mongoengine.listfield(mongoengine.intfield(required=true), verbose_name='codes') name = mongoengine.stringfield(max_length=255, required=true) class bytesforurl(mongoengine.document): url = mongoengine.referencefield(url) value = mongoengine.floatfield(required=true) timestamp = mongoengine.datetimefield(required=true) i need data of bytesforurl given url name within time range. how query that. bytes = mongo_models.bytesforurl.objects(timestamp__gte=from_time, timestamp__lte=to_time, ) byte in bytes: print byte.value, byte.timestamp but how pass value url. help? you can use this urls = mongo_models.url.objects.filter(name=name) bytes = mongo_models.bytesforurl.objects.filter( timestamp__gte=from_time, timestamp__lte=to_time, url__in=urls)

.net - Making unsafe code safe in C# -

i reading through article on image processing in c# there bit of code in there don't because it's unsafe, , know if can made safe: public static bool invert(bitmap b) { // gdi+ still lies - return format bgr, not rgb. bitmapdata bmdata = b.lockbits(new rectangle(0, 0, b.width, b.height), imagelockmode.readwrite, pixelformat.format24bpprgb); int stride = bmdata.stride; system.intptr scan0 = bmdata.scan0; unsafe { byte * p = (byte *)(void *)scan0; int noffset = stride - b.width*3; int nwidth = b.width * 3; for(int y=0;y < b.height;++y) { for(int x=0; x < nwidth; ++x ) { p[0] = (byte)(255-p[0]); ++p; } p += noffset; } } b.unlockbits(bmdata); return true; } the line byte* p = (byte*)(void*)scan0; looks culprit, have don't understand it's doing, or how made safe. can shed light...