Posts

Showing posts from April, 2011

animation - Splitting a long subtitle line into 1s ones? -

i need split on 2-minute line in subtitle multiple smaller 1 second long ones (retaining text). reason is, when soft-coded mkv, video players don't load line when seeking past starting time. subtitle edit seems allow splitting line 2 parts @ time.

Resize instance types on Container Engine cluster -

some of our containers run better memory above instance type deployed in our container engine cluster. there recommended practice rebuild container engine template larger instances after container engine cluster has been created? for example, go gce instances n1-standard-2 n1-highmem-8 running containers above 8gb ram? container engine doesn't have api doing this, since uses compute engine instance group nodes in cluster, can update without needing gke's help. in developers console, copy instance template looks "gke--" , modify machine type in it, edit named instance group use new template. can find these options under compute > compute engine > instance templates , compute > compute engine > instance groups , respectively.

python - Detect which figure was closed with Matplotlib -

im using matplotlib embedded in gui application using qt4 backend. i need store list of figures user plots , keeps open ie multiple figures able plotted separately different clicks of plot button. however when user closes figure need remove list of figures. how tell figure closed? i using event handler detect figure has been closed cannot tell one. here trivial example code: from __future__ import print_function import matplotlib.pyplot plt import numpy np figs = [] fignum = len(figs) def handle_close(evt): evt.canvas.figure.axes[0].has_been_closed = true print ('closed figure') fig = plt.figure() figs.append(fig) ax = figs[fignum].add_subplot(1, 1, 1) ax.has_been_closed = false # fig2 = plt.figure() # ax2 = fig2.add_axes([0.15, 0.1, 0.7, 0.3]) t = np.arange(0.0, 1.0, 0.01) s = np.sin(2*np.pi*t) line, = ax.plot(t, s, color='blue', lw=2) # fig2 = plt.figure() # figs.append(fig2) # fig2.canvas.mpl_connect('close_event', handle_close...

python - How to fully develop Django projects in the cloud? -

i have been working django on linux sublime text while, switch windows graphics design , gaming. wonder what's effective way develop django in cloud without having setup new django environment every os touch. fantastic if can sync project files digitalocean , edit them on sublime text, since online ides/terminal pythonanywhere, cloud9, etc. quite slow , unresponsive. developing directly in production environment highly discouraged. should develop locally using version control systems (git) , test suites check works before deploy. once you've checked works, can pull changes remote repository apply modifications or use jenkins continuous integration. but, if still want modify code directly in cloud. pycharm nice ide allows work remove projects. don't know if possible sublime.

javascript - How to get back initial height value of div after if condition in Jquery -

$(document).ready(function() { var h = $(this).parent("ul").height(); $(".tile_nav ul li").mouseover(function() { var hh = $(this).children("ul").height(); var h = $(this).parent("ul").height(); var mainbottm = $(this).parent("ul").position().top + $(this).parent("ul").outerheight(true); var bottom = $(this).children("ul").position().top + $(this).children("ul").outerheight(true); var diff = bottom - mainbottm; var toppossub = $(".cm_rhs").offset().top; $(".cm_lhs h1").html("sub ul" + bottom + "main ul bottom " + mainbottm + " diff " + diff); var newulheight = h + diff; if (diff > 0) { $(".tile_nav ul").css("height", newulheight); s } }); $(".tile_nav ul li").mouseleave(function() { $("....

python - Getting post parameters with characters that are not allowed to be used in a variable with web.py -

i trying integrate google recaptcha site, when realized post parameter required submitted had character isn't legal "e.g. minus operator sign. here code projects: class apply: def post(self): = web.input() print recaptcha2.verify("mysecretkey",i.g-recaptcha-response, "end user's ip") the problem having relates g-recaptcha-response post parameter , how variable characters not legal use in variables python. is there work-around this? update: here example of error facing traceback (most recent call last): file "c:\python27\lib\site-packages\web\application.py", line 236, in process return self.handle() file "c:\python27\lib\site-packages\web\application.py", line 227, in handle return self._delegate(fn, self.fvars, args) file "c:\python27\lib\site-packages\web\application.py", line 409, in _delegat e return handle_class(cls) file "c:\python27\lib\site-packag...

Java Generic Method basics (reflection) -

i trying correctly understand how use generics. have been searching on morning confused when tutorials start adding multiple generic values, or using abstract terms still wrestling with. i still learning general advice welcome, figure out syntax method returning generic class. for example consider: public class genericsexample4 { public static void main(string args[]) { car car; truck truck; car = buy(car.class, 95); truck = buy(truck.class, 45); } // here! public static <t extends vehicle> t buy(class<t> type, int topspeed) { // create new dynamic class t . . . lost on syntax return null; // return new class t. lost on syntax here :( } } interface vehicle { public void floorit(); } class car implements vehicle { int topspeed; public car(int topspeed) { this.topspeed = topspeed; } @override public void floorit() { system.out.println("vroom! g...

asp.net mvc - Best practises for a Web Api -

i have movies table basic information , reviews table revies movies. in app want show list name , avg score of movie. best practise? do store avg field in movies table , use api/movies? do have api return movies including reviews reviews , calculating in app (i guess not). or necessary calcs on server , return view model needed? have calcs done on server/database. assuming have back-end db store sql server, write query, stored procedure, or view calc on demand. don't need calculate on client (this slow , cause need transfer data) , don't need store average anywhere.

jsf - How to serve different page request from same button dynamically? -

i have fix top navigation bar this . , have several links pages(e.g. foods.xhtml, cars.xhtml, planes.xhtml) in side bar navigation(like: "similar questions" side bar in stackoverflow, inverted 'l'). goal: click on sidebar link(from home page) , should take me next page(let's "foods.xhtml", has list of foods) , when click on food take me next page(let's sandwich.xhtml) , button created on fixed top navigation bar navigate tolist of foods(foods.xhtml). questions: when click on 1 sidebar link(->foods.xhtml), how can store foods.xhtml in backing bean when go sandwich.xhtml , want navigate back, "back" button on fixed navigation bar point foods.xhtml? note: want work cars, planes. "back" button in top fixed navigation bar has different "page redirection" @ different page served.

android - GAE Reading from Datastore -

i want return myhighscores datastore: i.e.: paul,1200 tom,1000 kevin,800 private void returnhighscores(httpservletresponse resp, string game, int max) throws ioexception { datastoreservice datastore = datastoreservicefactory.getdatastoreservice(); key gamekey = keyfactory.createkey("game", game); query query = new query("highscore", gamekey); query.addsort("points", query.sortdirection.descending); list<entity> highscores = datastore.prepare(query).aslist(fetchoptions.builder.withlimit(max)); for(entity e : highscores) { resp.getwriter().println(e.getproperty("name") + "," + e.getproperty("points")); } } and working :) ! when want read returned highscores , add string textview with: androidhttpclient client = androidhttpclient.newinstance("mueckenfang"); httppost request = new httppost(highscore_server_base_url + "?game=" + highscorese...

android - How do I add a new tab with fragments -

so want create 3 tabs, different each other. xml have covered. not how create tabs without crashing app. i have implemented swipe tab viewpage. http://developer.android.com/training/implementing-navigation/lateral.html http://www.androidhive.info/2013/10/android-tab-layout-with-swipeable-views-1/ and part of http://www.java2s.com/code/android/ui/demonstrateshowfragmentscanparticipateintheoptionsmenu.htm when try go next tab(swipe work no problem) error: 07-08 22:07:57.414: e/androidruntime(6865): fatal exception: main 07-08 22:07:57.414: e/androidruntime(6865): process: com.cyberdog.magiceasydraft, pid: 6865 07-08 22:07:57.414: e/androidruntime(6865): java.lang.nullpointerexception: attempt invoke virtual method 'void android.support.v4.view.viewpager.setcurrentitem(int)' on null object reference 07-08 22:07:57.414: e/androidruntime(6865): @ com.cyberdog.magiceasydraft.addplayersfragmenttab.dopositiveclick(addplayersfragmenttab.java:113) 07-08 22:07:57.4...

Connection to http://localhost:8080 refused in Android -

i trying consume rest service in android , getting following error: org.apache.http.conn.httphostconnectexception: connection http://localhost:8080 refused i have introduced permission: uses-permission android:name="android.permission.internet" running code in emulator , works when try run in smartphone fails. pd: when run in emulator use http://10.0.2.2:8080 . public boolean checkconnection(){ string res = ""; boolean serverup = false; try { httpclient client = new defaulthttpclient(); //httpget request = new httpget("http://10.0.2.2:8080/prueba_conexion"); httpget request = new httpget("http://localhost:8080/prueba_conexion"); httpresponse response = client.execute(request); bufferedreader rd = new bufferedreader(new inputstreamreader( response.getentity().getcontent())); string linea = ""; while ((linea = rd.readline()) != null) { ...

Tomcat Apache server restart required too frequently -

it troublesome restart server every time content gets changed. there utility detects if content edited not affect working of code eg. changing variable value? i curious type of change you're making. when make change in javascript, there no need restart tomcat server. if modify thing needs compile need restart after recompilation. can configure tomcat reload automatically servlets, configure attribute re-loadable true of context. take @ context.xml.

php - Page Redirection not working after hosting -

this question has answer here: how fix “headers sent” error in php 11 answers i trying redirect page according text value using switch , button click, working fine in localhost not working after hosting. please overcome problem.. looking forward it. thanks. form coding <form id="accounform" class="form-horizontal" method="post" action="redirect.php" > <input type="hidden" value ="<?php echo( htmlspecialchars( $row['jewellery_name'] ) ); ?>" name="textboxdata" > <input type = "submit" class="btn btn-blue" name = "submit" value = "add another"> </form> redirect.php <?php session_start(); ob_start(); $textboxdata = $_post['textboxdata']; if (isset($textboxdata)) { switch ($textboxdata) { cas...

Scala: accessing shadowed parameter/variable -

i have following code, , 2 situations inside the if in method hidevariablefromouterblock declaring variable k shadows 1 defined in outer block. inside second method hideparametername declaring variable k shadows parameter same name. object test extends app { def hidevariablefromouterblock() = { var k = 2457 if (k % 2 != 0) { var k = 47 println(k) // prints 47 //println(outer k) } println(k) // - prints 2457 expected } def hideparametername(k: int) = { var k = 47 println(k) // prints 47 //println(parameter k) } hidevariablefromouterblock() hideparametername(2457) } is there way in blocks have shadowed variable or parameter k access shadowed value (the variable outer block)? i aware not practice, , never that. asking question educational purposes. i did bit of research , failed find clear explanation. find/see shadowing occurs, found no clear explanation variable outer block can't accessed anymore. i...

servlets - java.io.IOException An established connection was aborted by the software in your host machine -

i getting error when 1 servlet call remote server. running java application1, invoke servlet call application2 few data. application 2 has return data. getting below error in application2 while return response objectoutputstream, works fine. using tomcat 8. org.apache.catalina.connector.clientabortexception: java.io.ioexception: established connection aborted software in host machine 15:45:44:776 pm @ org.apache.catalina.connector.outputbuffer.realwritebytes(outputbuffer.java:393) 15:45:44:776 pm @ org.apache.tomcat.util.buf.bytechunk.flushbuffer(bytechunk.java:426) 15:45:44:776 pm @ org.apache.tomcat.util.buf.bytechunk.append(bytechunk.java:339) 15:45:44:776 pm @ org.apache.catalina.connector.outputbuffer.writebytes(outputbuffer.java:418) 15:45:44:776 pm @ org.apache.catalina.connector.outputbuffer.write(outputbuffer.java:406) 15:45:44:776 pm @ org.apache.catalina.connector.coyoteoutputstream.write(coyoteoutputstream.java:97) 15:45:44:776 pm @ java....

.net - How can I get a WebJob's logs programmatically? -

we have created azure webjob scheduled database cleanup our webapi project. want display latest job runs in our own management web app monitor how cleanup going every day. how can latest 50 function calls including corresponding output logs , durations given webjob? some background requirement: the cleanup process came simple suspect start bottleneck in near future, wanted monitor how long takes run each day proactively redesign using more scalable approach when needed. ideally i'd last 50 or runs , generate graph showing time took execute on period of time. the first thing thought create our own database , wrap each execution stopwatch save duration our database. query database , build graph way. but since first time used webjobs, found out of stuff wanted log logged automatically webjobs sdk. things start times, duration, function name, etc, exist in logs , enough build our own display around. the problem how query logs our mvc project in suitable format. of course...

char - Why is my C function returning the incorrect int? -

i'm making simple program asks user minimum , maximum values (between 32 , 127, inclusive), reason every time try store minimum value gets replaced value. here code: #include <stdlib.h> #include <stdio.h> #define lenlimit 256 char text[lenlimit]; int enternumber(int lolimit, int hilimit) { printf("please enter integer between 32 , 127: "); fgets(text, lenlimit, stdin); int enter = atoi(text); int exit; if (enter < 32 || enter > 127) { printf("min %i out of range\n", enter); enternumber(enter, hilimit); } if (enter >= 32 && enter <= 127 && hilimit > 127) { exit = atoi(text); printf("min %i in range\n", exit); } if (lolimit >= 32 && lolimit <= 127 && hilimit <= 127 && enter >= lolimit) { exit = hilimit; printf("max %i in range\n", exit); } printf("num returned: ...

c# - Serviced Component interface not showing up -

i created serviced component access emails stored in sql server database. has 1 public method.i did apply attributes mentioned in this question when open component in local component services. can see reademail interface(version: 6.2 of component services) but when try open @ server can't.(version: 2001.12.4720.3959 of component services) i'm using .net 3.5 it suspect may have different versions of component services, have other components , show correctly i figured out. turns out using namespace used in component. changed namespace component , worked

Using encrypted password in Maven POM.xml -

background: need automate deployment of project(jar files). based on user input, jar file deployed on different server based on selected environment. example: using bat/cmd file ask user select environment. set /p environ=please enter execution environment(enter 1 dev, 2 qa, 3 stage, 4 prod) : based on user input passing credentials like. mvn install -dftp.username=user -dftp.password=password -dftp.server=servername the input user, password, servername changes based on selected environment. requirement: passing encrypted password in pom.xml needs decrypted maven (may using plugin) . i tried maven-encryption no success. use feature need know how can get/read decrypted password in pom plugin using deploying. <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-antrun-plugin</artifactid> <executions> <execution> <id>ftp...

javascript - Execute function on button click Codeigniter -

i new codeigniter. want create button in view when clicked execute function controller. i using right code in view: <button id="checkin" onclick="location.href=' <?php echo base_url();?>index.php/daily_attendance/check_in'">check in</button> this code not execute function check_in , me page. can use redirect() in controller of function , wherever want. the problem have jquery hide button on click , show button. when execute function redirect, page refresh , button not shown. my question that, there better way execute functions without going page in codeigniter? is there way pass function button or should make button in controller not advisable since it's not ui components , because need create many views manage ui since button in middle of page? this way can call function of controller on button click. <a href="<?php echo base_url(); ?>daily_attendance/check_in/<?php echo $stdrow->stud...

c++ - Delete dynamically allocated derived objects - Polymorphism -

i cannot figure out how delete dynamically allocated subclasses through basepointer. allocation in app-class , how delete allocated objects withing main-method? #include <iostream> using namespace std; class base { public: virtual void print() = 0; virtual ~base() { cout << "base destructor\n"; } }; class sub1 : public base { public: void print() { cout << "i sub1!\n"; } ~sub1() { cout << "sub1 destructor\n"; } }; class sub2 : public base { public: void print() { cout << "i sub2!\n"; } ~sub2() { cout << "sub2 destructor\n"; } }; class app { public: app(base *&b) { b = new sub1; b = new sub2; } }; int main() { base *b; b = null; app app(b); return 0; } the minimum fix leaks be: class app { public: app(base *&b) { b = new sub1; delete b; // chance s...

Meteor [RangeError: Out of memory] exited with code: 3 -

i'm running meteor app connects sql , mongo database. when start app error after connecting mssql. don't know if error related kadira or not here's happens: every once in awhile app run, exit , restart randomly after see out of memory error. i see sometimes: c:\users...\.meteor\local\build\programs\server\packages\meteorhacks_kadira.js:3130 originalrun.call(this,val); ^ rangeerror: out of memory @ fibers.run (packages/meteorhacks:kadira/.../async.js:25:1) @ object._onimmediate (pakages/meteor/fiber_helpers.js:126:1) @ processimmediate [as _immediatecallback] (timers.js:354:15) does mean computer doesn't have enough ram run application? i'm not sure how figure out source of error further wondering if has encountered this? don't think should happening because others run application without error.

java - Tess4j (Tesseract V3.03) Invalid memory access -

when invoking tesseract doocr on multi page tiff documents throws invalid memory access error. datapath set folder tessdata present , dlls present in classes folder exception in thread "main" java.lang.error: invalid memory access @ com.sun.jna.native.invokepointer(native method) @ com.sun.jna.function.invokepointer(function.java:470) @ com.sun.jna.function.invoke(function.java:404) @ com.sun.jna.function.invoke(function.java:315) @ com.sun.jna.library$handler.invoke(library.java:212) @ com.sun.proxy.$proxy0.tessbaseapigetutf8text(unknown source) @ net.sourceforge.tess4j.tesseract.getocrtext(tesseract.java:429) @ net.sourceforge.tess4j.tesseract.doocr(tesseract.java:284) @ net.sourceforge.tess4j.tesseract.doocr(tesseract.java:205) @ net.sourceforge.tess4j.tesseract.doocr(tesseract.java:189) @ test.main(test.java:23)

python - passing django request object to celery task -

i have task in tasks.py so: @app.task def location(request): .... i trying pass request object directly few task so: def tag_location(request): tasks.location.delay(request) return jsonresponse({'response': 1}) i getting error can't serialized guess? how fix this? trouble have file upload objects .. not simple data types. because request object contains references things aren't practical serialize — uploaded files, or socket associated request — there's no general purpose way serialize it. instead, should pull out , pass portions of need. example, like: import tempfile @app.task def location(user_id, uploaded_file_path): # … stuff … def tag_location(request): tempfile.namedtemporaryfile(delete=false) f: chunk in request.files["some_file"].chunks(): f.write(chunk) tasks.location.delay(request.user.id, f.name) return jsonresponse({'response': 1})

Java 7: Path vs File -

for new applications written in java 7, there reason use java.io.file object more or can consider deprecated? i believe java.nio.file.path can java.io.file can , more. long story short: java.io.file never deprecated / unsupported. said, java.nio.file.path part of more modern java.nio.file lib, , java.io.file can, in better way, , some. for new projects, use path . and if ever need file object legacy, call path#tofile() migrating file path this oracle page highlights differences, , maps java.io.file functionality java.nio.file lib (including path) functionality article janice j. heiss , sharon zakhour, may 2009, discussing nio.2 file system in jdk 7

sql server - SQL TOP and Join challenge -

i have problem top , join in sql. i have 2 tables inventtable , ikmtechspecprod . inventtable contains products have. ikmtechspecprod contains technical specifications products. there can many technical specifications single product. want export products , 12 first technical specs each product, , want listed on 1 line per product example: itemid, itemname, spec1name, spec1value, spec2name, spec2value, spec3name, spec3 value..... i have tried sql query below, gives me: itemid, itemname, spec1name, spec2value itemid, itemname, spec2name, spec2value itemid, itemname, spec3name, spec3value query: select invent.itemid, itemname, [techspec].name, [techspec].value [inventtable] invent cross apply (select top 12 [ikmtechspecprod].name, ikmtechspecprod.value [ikmtechspecprod] [ikmtechspecprod].itemid = invent.itemid) techspec anyone know how solve this? you can write query as: select distinct t2.itemid, ...

How do I use the For clause to create a sum or total of an aggregated column in Cognos report studio? -

Image
how use sum in cognos report studio final policy premium? table 1 result (highlighted in blue) if set data item (final policy premium) total. goal see results shown in table 2 (highlighted in yellow). note: removed other columns think not needed support question. columns removed ones see in query. select a.[policy number], b.[final policy premium], a.[gwp amt], a.[transaction type code], a.[insured], a.[cancellation effective date], a.[transaction date] [modified date], a.[cancellation type code], a.[cancellation reason code], a.[policy transaction type code] dw.table inner join (select sum([gwp amt]) [final policy premium], [policy number] dw.table [policy number] in ('1111111', '2222222') group [policy number]) b on a.[policy number]=b.[policy number] a.[policy number] in ('1111111', '2222222') group a.[policy number], b.[final policy premium], a.[gwp amt], a.[transaction type code], a.[insured], a.[cancellation...

php - Passing Data to view - Undefined variable -

i'm new laravel framework , somehow got issue bothers me days now. i wanted pass simple variable blade view, version found in documentation or question on platform unfortunately didn't lead solution. i created route looks this: route::get('test', 'pagecontroller@index'); the code in pagecontroller looks this: public function index(){ $datatopass='datahere'; return view('admin.test', compact('datatopass')); } and got view looks this: @section('content') {{$datatopass}} @stop the problem 2 exeptions: #errorexception in d9e848d01f99ac2368ead804bd322152 line 3: undefined variable: datatopass (view: /home/vagrant/test/resources/views/admin/test.blade.php) errorexception in d9e848d01f99ac2368ead804bd322152 line 3: undefined variable: datatopass i'm using homestead development environment set in virtualbox. any ideas i've done wrong? i tried every type of datapassing like return view('...

c# - async await exception catching - which thread am I on? -

i'd this: public async task<int> dowork(int parameter) { try { await operationthatmaycompletesynchronously(parameter); } catch(exception) e { if(completedsynchronously) dosyncthing(); else doasyncthing(); } } note: i'm running tasks on thread pool, there no async context. i'd able tell difference between exception thrown immediately, , i'm still on calling thread (e.g. parameter invalid causing function abort), , exception thrown when async task completes, , i'm on other random callback thread (e.g. network failure) i can work out how might achieve if didn't use await , , used continuewith on async operation, possible using await ? store task in variable: var task = operationthatmaycompletesynchronously(parameter); //may throw then await it: await task; //may throw that way can differentiate between 2 origins potential exception. note, async methods never throw dir...

javascript - Find a div by color -

i find div has following color: #ff8533 . is possible find div color using jquery? if found, possible retrieve text contained within it? this how color value of element it's computed style: $(selector).css('color'); but, above return rgb value though color set hex value. hence, you'd need function convert rgb hex . so, bottom line is, filter div elements return 1 matches color specified, store in variable, whatever variable, such as, containing text etc. take @ example below. only tested on major browsers , ie9+ var matcheddiv = $("div").filter(function() { return rgb2hex($(this).css("color")) === "#ff8533" }); alert (matcheddiv.css('border', '1px solid black').text()); //credit: http://stackoverflow.com/a/3971432/572827 function rgb2hex(rgb) { rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/); function hex(x) { return ("0" + parse...

node.js - Session variables in node express-session don't persist to the next request -

i using basic node express-session setup memory store , have code on server: app.use(require('express-session')({ secret: 'keyboard cat', resave: false, saveuninitialized: true, cookie: { secure: true } })); app.post('/api/login', function(req, res) { req.session.username = req.body.username; } app.get('/api/getprofile', function(req, res) { user.findone({'username' : req.session.username}, function (err, userprofile) { console.log('getprofile executed user:' + req.session.username); if (err) throw err; console.log(userprofile); }); }); the problem req.session.username getprofile route undefined, although not in previous request login route. inspected http headers , strangely there no headers dealing cookies, server or client. right have no idea problem. you cookie: { secure: true } , web server on secure connection? if not, cookie won't written. from docs : ...

java - error when base64String arrived from android to nodejs via socketio -

i work on app send image android nodejs via socket io , got error when send data has size 700,00 kb in node js , don't know how can me work better ??? java code file myfile = new file (selectedimagepath); int ficher = (int) myfile.length(); system.out.println(""+size(ficher)); int file_size = integer.parseint(string.valueof(myfile.length()/1024)); system.out.println(""+file_size); size(ficher); fileinputstream imageinfile = null; try { imageinfile = new fileinputstream(myfile); } catch (filenotfoundexception e) { // todo auto-generated catch block e.printstacktrace(); } byte imagedata[] = new byte[(int) myfile.length()]; try { imageinfile.read(imagedata); } catch (ioexception e) { // tod...

javascript - Scraping AJAX based value php -

part of html code im trying info follows <div class="price">15</div> and part of form is <select name="group_1" id="group_1" class="attribute_select" onchange="findcombination();getproductattribute();$('#wrapresetimages').show('slow');;"> <option value="1" selected="selected" title="1">1</option> <option value="4" title="5">5</option> </select> now when change select 1 4 price in div changes link www.domain.com/product.html/ changes www.domain.com/product.html#/in-pack-5. problem conbination of domdocument, loadhtml, domxpathdoesnt seem recognize "#/in-pack-5" in link , keeps scraping default price when force "selected" value="4". how can read second price than? ideas please im stuck. apologize if question been asked - searching answer hrs cant find anywhere or cant form q...

jvm - How to compress variables in Java using leading zero byte suppression? -

leading 0 byte suppression means leading 0 bytes of integer value removed , instead number of eliminated bytes stored. example: suppose have 32-bit integers, hexadecimal value 00000090 encoded binary value 01110010000 , 011 means there 3 0 bytes in 00000090 . my question how implement leading 0 byte suppression in java? give me examples? in example, suggest 0x00000090 encoded 11-bit number 0b01110010000 . know, there no 11-bit data types in java, doing "the java way" impossible. the way can think of achieve you're trying use single byte array store of data, implement 0 byte suppression algorithms on top of that. of course, remove entire point of java, object-oriented. if you're trying implement sort of integerzerobytesuppression class, effort naught, because every object in java comes several bytes of overhead anyway, far outweighing few bits you'll save 0 byte suppression itself. in end, if really need few bits of memory you'll save (...

Reversed IP localisation in python -

i have old project in python : ip corresponding location. know can ip location (i've read this ), , know if it's possible reverse process. here's idea had: •using method given in link, , "for", test large range of ip until wanted location. filters hope can reduce amount of ip test. => long, , not efficient •exploring database given here , don't know how does it's possible ? if yes, what's best solution ? thanks :) there python bindings geoip library. also databases downloadable. here there examples in python. use case seems not covered. may have manually open , search databases.

ssh - How to enable bash auto-completion for a function? -

i have read tutorial on bash auto-completion an introduction bash completion , trying same auto-completion done ssh 1 of functions (that loaded .profile ); acts pretty alias . what trying : same auto-completion, provided default ssh (which function _known_hosts ; complete -p | grep ssh , complete -f _known_hosts /etc/init.d/ssh ), , own function (which installed woul install alias, , in fact scp , ssh original argument) the completion function ssh here _ssh . you can see complete -p ssh (it should have been in grep output) though appears auto-loaded , not show until after have used once in session. anyway, being said should able hook _ssh function think. complete -f _ssh myfunc

string - while loop not working for tupled list c# db data update -

here code insertion method calling while iterating through while loop program p = new program(); var lines = system.io.file.readlines(@"c:\users\malik\desktop\research_fields.txt"); var dd = new list<tuple<string, double, string>>(); try { sqlconnection con = new sqlconnection("data source=khizer;initial catalog=subset_aminer;integrated security=true"); con.open(); sqlcommand query = con.createcommand(); query.commandtext = "select p_abstract sub_aminer_paper id between 1 , 500 , datalength(p_abstract) != 0"; sqldatareader reader = query.executereader(); string summary = null; while (reader.read()) { summary = reader["p_abstract"].tostring(); dd.addrange(lines.select(line => tuple.create(line, p.calculate_cs(line, summary), summary))); ...

delphi - Get the call stack from EurekaLog at any time -

there many posts on getting call stack exception handling, , have eurekalog handling that, want able stack @ point during runtime, can if put breakpoint in ide. an event somewhere in legacy code causing function execute doing it's not supposed do. while can see debug output name of function, can't tell called without stack trace. it's not exception , don't want raise exception in function eurekalog can fire. is there way call stack without exception? you not need raise exception stack trace. call eurekalog's gettracer() function teurekabasestacklist object, , call build() method stack trace. here example provided in eurekalog's documentation: var callstack: teurekabasestacklist; begin callstack := gettracer(tracerwindows); try // build current call stack including current execution point callstack.build(callstack.getcurrentinstruction); // ... use callstack somehow freeandnil(callstack); end; end;

string - How to pass huge data from html to jsp -

i'm passing data text area html form jsp. it's working small data, breaks if pass data of around 1mb , above. i'm storing data in string variable in jsp. how can achieve this? use form method='post' below : <form action="" method="post"> </form>

How to create a flat JSON Object instead of array of objects in PHP -

i trying create flat json object 3 arrays in php. output of following code object containing array of objects: { "amphibian":[ {"frogs":"green"} ], "mammal":[ {"bats":"black"}, {"elephants":"grey"}, {"rats":"black"}, {"turtles":"green"} ] } however, not want. possible turn output object containing flat objects during loop? desired output : { "amphibian": {"frogs":"green"}, "mammal": {"bats":"black","elephants":"grey","rats":"black","turtles":"green"} } here's code: $colors = array("frogs"=>"green","bats"=>"black","elephants"=>"grey","rats"=>"black","turtles"=>"green"); $allanima...

c++ - How to check for the existence of a subscript operator? -

i want write type trait uses sfinae check type existence of subscript expression. initial attempt below seems work when subscript expression possible not work when bracket operator not exist. #include <iostream> #include <vector> #include <cassert> template<class t, class index> struct has_subscript_operator_impl { template<class t1, class reference = decltype( (*std::declval<t*>())[std::declval<index>()] ), class = typename std::enable_if< !std::is_void<reference>::value >::type> static std::true_type test(int); template<class> static std::false_type test(...); using type = decltype(test<t>(0)); }; template<class t, class index> using has_subscript_operator = typename has_subscript_operator_impl<t,index>::type; struct doesnt_have_it {}; struct returns_void { void operator[](int) {} }; struct returns_int { int op...

html - Bootstrap: show map that fits the window height below nav header -

in bootstrap 3 have following elements starting top: the navbar header div contains google map row contains widgets. it's possible show google maps fits screen height , below maps have row contains other elements? if have fixed header , footer , know height in advance wrap map fixed element , set top , bottom properties accordingly. function initialize() { var mapcanvas = document.getelementbyid('map-canvas'); var mapoptions = { center: new google.maps.latlng(44.5403, -78.5463), zoom: 8, maptypeid: google.maps.maptypeid.roadmap } var map = new google.maps.map(mapcanvas, mapoptions); } google.maps.event.adddomlistener(window, 'load', initialize); #map-container { position: fixed; top: 50px; left: 0; bottom: 50px; right: 0; } #map-canvas { width: 100%; height: 100%; } <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.cs...

ios - Swift Array Pass by Value...same memory address? -

can please clear me. i understand (thought) swift passes arrays by value struct. but when pass array via segue next view controller appears me passing reference, when check memory address of array same. this how i'm checking println("\(unsafeaddressof(runs))") // 0x0000000174240c00 i have thought these memory addresses different ? or confusing myself. the run / stafftask classes both inherit nsobject saving purposes. class run: nsobject, nscoding { } furthermore, if access item in array var service = self.stafftasks[indexpath.row] and edit value, both service variable value , element in array updated. have same memory address, shown by println("\(unsafeaddressof(service)) \(unsafeaddressof(self.stafftasks[indexpath.row]))") also... stafftasks subset of larger array called runs when search service object, larger set, find same memory address if let index = find(self.runs, self.staff) { println("local \(unsafeaddresso...

scala.util.Try does not wrap Exception when used with Future and Play WS -

my understanding scala.util.try wraps exceptions thrown code inside try { ... } block. here simple example wraps nullpointerexception. object trydemo extends app { import scala.util.{failure, success, try} def dosomething(i: int): string = { if (i > 50) { println("going throw nullpointerexception @ index " + i) throw new nullpointerexception("- exception @ index " + i) } else "some-result" } val t: try[string] = try { var x = 0 while (x < 100) { dosomething(x) x += 1 } "result-" + x } val result: option[string] = t match { case success(s) => println("success " + s); some(s) case failure(f) => println("failure " + f.getmessage()); none } } this gives following output excepted. going throw nullpointerexception @ index 51 failure - exception @ index 51 however, when try following (with invalid url ensure fails...