Posts

Showing posts from August, 2010

java - How to get current path when program is loaded dynamically -

i'm not able give question apt title apology that. making modularised application. load various jar files @ runtime , invoke particular method of particular class (of jar file) @ run time. the jar file has supported file. jar file uses application , lets abc located in same directory have kept jar file. when run jar file new file(".").getabsolutepath() gives correct path (this abc located) , program runs fine. when load jar file dynamically , invoke method using reflection above code gives path of parent program , abc not found @ path. now question how find path in jar file exists when i'm running jar file's code using reflection. please let me know if need more explanation. try this: public static void main(string[] args) { system.out.println(stringutils.class.getresource("stringutils.class")); } (note: stringutils present on classpath maven dependency @ time) gives me: jar:file:/home/******/.m2/repository/org/apach

xcode6 - Append result to datasource with swift -

i'm using promise result fill data source , update table view data. i have declared: var tdatasource: [friendresponser]? //contains de result previous bind var datasource: [friendresponser]? { //this total result after append didset { self.tableview.reloaddata() } } but, when try append result with: promise.then { user in self.tdatasource = user datasource?.append(tdatasource?) //self.datasource = user }.catch{ error in sclalertview().showerror("error", subtitle: error.localizeddescription) } but in datasource?.append(tdatasource?) giving me error: _?? not convertible '0' how can append result data datasource display both results? use extend append appends 1 element of same type extend appends array of same type

jquery - How to resize actions column in free jqgrid -

sometimes width of column containing inline edit buttons small. width cannot changed mouse. for example, open demo from http://www.ok-soft-gmbh.com/jqgrid/ok/removepagehorizontalscrollbar2.htm and try resize actions or number column dragging right border in header. column width not change. how fix actions , number column widths can changed user ? the referenced example contains column defined as { name: "act", template: "actions", width: 66 } the width of act column fixed , 66px . template actions defined following (see the line of code): actions: function () { return { formatter: "actions", width: (this.p != null && this.p.fontawesomeicons ? 33 : 37) + (jgrid.cellwidth() ? 5 : 0), align: "center", label: "", autoresizable: false, frozen: true, fixed: true, hidedlg: true, resizable: false, sortable: false, s

C# Rfc2898DeriveBytes to PHP -

i'm trying adapt following function c# php , can't work. i've searched other threads, couldn't find right answer solve problem. public static string decrypt(string encryptedtext) { byte[] bytes = encoding.ascii.getbytes("hello"); byte[] buffer = convert.frombase64string(encryptedtext); byte[] rgbkey = new rfc2898derivebytes("world", bytes).getbytes(0x20); icryptotransform transform = new rijndaelmanaged { mode = ciphermode.cbc }.createdecryptor(rgbkey, bytes); memorystream stream = new memorystream(buffer); cryptostream stream2 = new cryptostream(stream, transform, cryptostreammode.read); byte[] buffer4 = new byte[buffer.length]; int count = stream2.read(buffer4, 0, buffer4.length); stream.close(); stream2.close(); return encoding.utf8.getstring(buffer4, 0, count); } any appreciated. thanks! my php code far: <?php $key = hash_pbkdf2('sha1', 'world', 'hello',

html - Why doesn't the jQuery event ".on" have any event argument -

the following code doesn't work : var movedownbtnhtml = '<a href="#" class="movedown"> down </a>', moveupbtnhtml = '<a href="#" class="moveup"> </a>'; function reloadbtns() { $(".cats .cat .moveup").add(".cats .cat .movedown").remove(); $(".cats .cat").children("input").after(movedownbtnhtml + moveupbtnhtml); $(".cat:first-child .moveup").add(".cat:last-child .movedown").remove(); } $( document ).ready(function() { $(".cats").on('click', '.movedown .moveup', function(evt){ if(evt.target.attr("class") == ".movedown") { var = $(".cat").index(evt.target.parent()), ctm = "<div class='cat'>"+$(".cat").eq(i).html()+"</div>"; $(".cat").eq(i).

swift - find() using Functional Programming -

i'd create generic find() typically used in functional programming. in functional programming don't work array indices , loops. filter. way works if have list of ["apple", "banana", "cherry"] and want find banana assign array indices list elements creating tuples [(1, "apple"), (2, "banana"), (3, "cherry")] now can filter down "banana" , return index value. i trying create generic function error. what's wrong syntax? func findingenericindexedlist<t>(indexedlist: [(index: int, value: t)], element: (index: int, value: t)) -> int? { let found = indexedlist.filter { // error: cannot invoke 'filter' argument list of type '((_) -> _)' element.value === $0.value } if let definitefound = found.first { return definitefound.index } return nil } update 1 : use above solution opposed using find() (will deprecated) or in sw

ruby on rails - Setting a variable when a stubbed method is called in RSpec -

in 1 of tests want perform before :all action, , need want test method not called in before :all action. there way this? e.g. want able to: before :all @bar_called = false # set @bar_called true if bar called on instance of class foo do_other_stuff end and then, in 1 of specs later on, expect @bar_called == false you implement mock block, set @bar_called . expect(obj).to receive(:my_method) { @bar_called = true } now, may want consider setting expectation on mock/stub instead expect(obj).to receive(:my_method).exactly(0).times see rspec-mocks documentation on receive counts .

python - How to avoid having class data shared among instances? -

what want behavior: class a: list=[] y=a() x=a() x.list.append(1) y.list.append(2) x.list.append(3) y.list.append(4) print x.list [1,3] print y.list [2,4] of course, happens when print is: print x.list [1,2,3,4] print y.list [1,2,3,4] clearly sharing data in class a . how separate instances achieve behavior desire? you want this: class a: def __init__(self): self.list = [] declaring variables inside class declaration makes them "class" members , not instance members. declaring them inside __init__ method makes sure new instance of members created alongside every new instance of object, behavior you're looking for.

jquery - Create JSON array by each-loop through parent and child elements -

html: <section id="intro"> <div id="ih" contenteditable="true">header</div> <div id="ish" contenteditable="true">subheader</div> <a id="ibtn" contenteditable="true">test</a> </section> <section id="articles"> <div id="ah" contenteditable="true">header</div> <div id="ash" contenteditable="true">subheader</div> <a id="btn-1" contenteditable="true">button</a> <a id="btn-2" contenteditable="true">button</a> <a id="btn-3" contenteditable="true">button</a> </section> jquery: $(document).ready(function() { $('#edit-button').click(function() { var dataobj = []; var jsonobj = []; $('sect

language agnostic - Is floating point math broken? -

0.1 + 0.2 == 0.3 -> false 0.1 + 0.2 -> 0.30000000000000004 why happen? binary floating point math this. in programming languages, based on ieee 754 standard . javascript uses 64-bit floating point representation, same java's double . crux of problem numbers represented in format whole number times power of two; rational numbers (such 0.1 , 1/10 ) denominator not power of 2 cannot represented. for 0.1 in standard binary64 format, representation can written as 0.1000000000000000055511151231257827021181583404541015625 in decimal, or 0x1.999999999999ap-4 in c99 hexfloat notation . in contrast, rational number 0.1 , 1/10 , can written as 0.1 in decimal, or 0x1.99999999999999...p-4 in analogue of c99 hexfloat notation, ... represents unending sequence of 9's. the constants 0.2 , 0.3 in program approximations true values. happens closest double 0.2 larger rational number 0.2 closest double 0.3 smaller rational number 0.3 . sum

c# - Setting initial state of new saga -

we in process of migrating legacy system nservicebus 5.0. best way migrate our business data saga data? example, if had ordercancellationpolicy saga, allowed cancellation within 2 days, how past orders legacy system create these new sagas in correct state? i see 2 options. first being write sql script prepopulate saga persistence tables (we using nhibernate persistence). other being create kind of special import message, such migrateorderdatacmd, contains data legacy order. import script send out these messages sagas handle , set saga data way. any guidance in area appreciated. theoretically i'd go option two, or version of it. imagine saga being down day , messages piling in queue. messages day coming in, you'd want verify when message sent, or add custom datetime message yourself. when saga picks message, knows should not set timeout 2 days in future, rather time message took delivered saga. way when migrate current state, messages proper timeout set.

Interpret Google Geocoding API Response returned to know which of them are accurate -

we have program calls google geocoding api passing address. understand of address, latitude , longitude values correct , of them approximated. in response, there tags address_component can have multiple "type" tag. there location_type under 'geometry'-->'location' there 'type' directly 'result' we going following logic understand if lat , long accurate. check multiple "type" under "address_components" , if find either value "route" or "street_number" in of type tags, accurate.. should use anyother tags geocoder response "location_type" under "location" or "type" under "result" tags. there information on google geocoding info, did not figure out if there kind of logic apply. regards siva the location_type tells accuracy of result, partial match tells geocoder did not return exact match request. see documentation: results: location_type

html - When using a layout page in ASP.Net MVC is the layout loading every time a new page is called? -

Image
i'm curious know, because i'm still learning layout pages, if when use layout page (ex. sitelayout.cshtml) , have 2 pages getting rendered (index.cshtml, results.cshtml) in @renderbody() section, layout wrapper part loaded each time go between index.cshtml , results.cshtml? or _layout.cshtml page load @renderbody() section asynchronously? just throw in example pics unless you've setup donut caching ( http://weblogs.asp.net/scottgu/tip-trick-implement-donut-caching-with-the-asp-net-2-0-output-cache-substitution-feature ), sitelayout.cshtml executed separately every page. if sitelayout has long/expensive operation , don't want loading every time, can use aforementioned donut caching have execute once per user per x amount of time. if want sitelayout start sending data browser before body done executing/rendering (i.e. asynchronously overall speed purposes), can use nuget package called courtesyflush ( http://www.hanselman.com/blog/nugetpackageofth

android - AndroidAnnotations @EProvider annotation -

in android application i'm using contentprovider , sqliteopenhelper access db. learning androidannotations framework , found @eprovider annotaion in documentation, can't neither understand how use example on github nor find using examples on internet. can explain me using of annotation? many in advance. i think wiki pretty clear. annotation needed enable injecting stuff provider, beans, resources, services etc.

javascript - IE 11 not supporting audio playing? -

i have checked w3schools.com , createelement(), setattribute() , play() meant supported ie 11? below js code works fine in other modern browsers. thoughts? <!doctype html> <html> <head> <meta charset="utf-8"> <script type="text/javascript"> var amusic = document.createelement('audio'); amusic.setattribute('src', 'sing.wav'); amusic.play(); </script> </head> <body> </body> </html> live example - https://jsfiddle.net/40x303ka/ your code specifies wav file audio file. seen on w3schools website , internet explorer not support wav files. for maximum cross-browser support, reccomend either using mp3 file, or better, specifying files based on browser compatibility so: var amusic = document.createelement('audio'); var source= document.createelement('source'); if (audio.canplaytype('audio/mpeg;')) { source.type= 'au

rename - File renaming Linux -

i have tried rename several files on linux system. used rename 's/foo/bar/g' * files wish change in current directory. not change name of files think should. appreciated. an easy way do: mv file2rename newname

android - setContentView method giving error in FragmentActivity -

i newbie. line this.setcontentview(r.layout.activity_main); in mainactivity.java giving android.view.inflateexception: binary xml file line #2: error inflating class viewpager error i doing fragmentactivity tutorial codepuppet link viewpager tag strange. viewpager must fill full-package , class name. <android.support.v4.view.viewpager xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" />

php - Get dom elements with particular string in the attribute -

i trying use domxpath find attributes contain value {{xxx}} (where xxx can anything). this using, isn't working. nor getting errors saying invalid query. foreach($docx->query('//*[*="*{{*}}*"]') $node){ // stuff } i trying find items might (but not limited to) following: <a href="/path/{{value}}">link</a> <p class="{{classes}}"></p> is there way items using domxpath::query() ? xpath 2.0 has matches() function lets use regular expressions. in 1.0 though, domxpath uses, best bet like: //*[contains(@*,"{{") , contains(@*,"}}")] note still match cases }} precedes {{ or there's nothing between two, you'd want double-check results once them.

java - How can I make a 'global JAR library' accessible by every project I make in Android Studio -

i searched answer came away solutions how add jar libraries individual projects rather globally all. please correct me on terminology if i'm wrong regarding concept of global jar. hi use android studio on windows , appreciate if can please tell me how can add same jar library every project without having copy jar files libs folder of every project created. is there way make symlink jars or can somehow make them extension sdk. i'm newbie java , android development appreciate patience , help. thanks.

web services - Data Driving Open-Source SoapUI REST Requests -

Image
i using soapui 5.0.0 , want able change parameters of rest request calls using single file, saving me changing them each test. now appears soapui pro has feature called "data source" there nothing in free version of soapui? i have placed sample of values passed in request , xml response back. passed values postcode : xx xxx productlist : 123456 xml response <postcode>ls11 0ey</postcode> <products> <e> <localstockcount>309.0</localstockcount> <productkey>10006541</productkey> <stockunitofmeasure>ln</stockunitofmeasure> how can data drive postcode , productlist passed in request using free version of soapui? you can use soapui custom properties parameterize requests. consider following rest request example: when request submitted, soapui substitute (or "expand") property placeholder ${#project#timezonedbkey} in request parameter

three.js TypeError: Cannot read property 'center' of undefined -

i trying import obj (tried different) on server node.js , three.js - got error after parse file. current code how import geometry: var loader = new three.objloader(); loader.load(modelpath, function (geometryobj) { var materialobj = new three.meshbasicmaterial( { vertexcolors: three.facecolors, overdraw: 0.5 } ); mesh = new three.mesh(geometryobj, materialobj); scene.add(mesh); here call stack: this.center.copy( sphere.center ); typeerror: cannot read property 'center' of undefined @ three.sphere.copy (eval @ <anonymous> (/lib/three.js:32:3), <anonymous>:6074:27) @ three.frustum.intersectsobject (eval @ <anonymous> (/lib/three.js:32:3), <anonymous>:6253:11) @ eval (eval @ <anonymous> (/lib/three.js:32:3), <anonymous>:36578:53) @ three.object3d.traversevisible (eval @ <anonymous> (/lib/three.js:32:3), <anonymous>:7943:3) @ three.object3d.traversevisible (eval @ <anonymous> (/lib/three.js:32:3), &

g++ - my own .so lib Ubuntu->Debian migration (cannot open shared library) -

recently migrated self ubuntu debian, (fortunetly didn't delete old os) on ubuntu had written litle library called libmyh.so i've used in other app g++ (...) -lmyh -l../codesamples/myh/lib and ran perfectly, on debian witch same makefile get: ./glui.out: error while loading shared libraries: libmyh.so: cannot open shared object file: no such file or directory any clue wat wrong? .so files not linked g++, because not static libraries (which end .a ) or compilation objects ( .o ). instead, set path load dynamic libraries: export ld_library_path=/path/to/codesamples/myh/lib ./glui.out as not related debian vs ubuntu, think have set variable on ubuntu system not on debian one.

php - Laravel5 Carbon date string not correctly parsing -

i've been struggling issue on 4 hours now. laravel's carbon date thing isn't playing nice bootstrap or something. i've been trying set mutator articles model public function setpublishedatattribute($date){ $this->attributes['published_at'] = carbon::createfromformat($date); } in articles model, i've included use carbon\carbon; . @ point, have bootstrap date picker: <div class="form-group"> {!! form::label('published_at', 'publish on:') !!} {!! form::input('date', 'published_at', date('y-m-d'),[ 'class' => 'form-control']) !!} </div> my error log throws this: [2015-08-16 22:32:36] production.error: exception 'invalidargumentexception' message 'trailing data' in /users/alexanderkleinhans/misc/laravel_test/laravel/vendor/nesbot/carbon/src/carbon/carbon .php:414 and huge stack trace: #0 /users/alexanderkleinhans/misc/laravel_test

c++ - unordered_map, why some buckets have more than 1 element even hashed values are all different? -

i playing default hash function std::unordered_map , checking if there collisions happening. here below code: void check(std::map<long, bool> & mp, const string & s, const long v){ if(mp.count(v) == 0){ mp[v] = true; }else{ cout<<"collision "<<s<<endl; } } int main(){ std::unordered_map<std::string, long> um; std::map<long, bool> map; auto hasher = um.hash_function(); std::string str = ""; long count = 0; (int = 0; < 26; ++i) { str = char(65+i); um[str]; auto value = hasher(str); check(map, str, value); (int j = 0; j < 26; ++j) { str = char(65+i); str += char(65+j); um[str]; auto value = hasher(str); check(map, str, value); (int k = 0; k < 26; ++k) { str = char(65+i); str += char(65+j);

unity3d - onTriggerEnter not called -

Image
in unity 5, having rigidbody , trigger , trigger has tag name "goal" now on rigidbody class have script - void ontriggerenter(collider other) { print ("test"); if(other.transform.tag == "goal") { print ("test"); } } but in console not "test" printed the sources here the rigidbody properties- the trigger properties- that's because it's ontriggerenter, captial "o".

php - How do I store the value of my dropdownlist to mysql database? -

i've created dynamic drop down list, totally clueless how save value mysql database. please :'( have tried several methods none seems work me. these original codes. page2.php <?php require_once("includes/connection.php"); ?> <?php require_once("includes/functions.php"); ?> <!doctype html> <html> <form action="page2insert.php" method="post"><br/> <table> <tr> <td>* name:</td> <td><input type="text" name="pname" style="width: 300px" ></td> </tr> <tr> <td>* type</td> <td><input type="radio" name="ptype" value="student" checked>student <input type="radio" name="ptype" value="staff">staff (eg. lecturer)</td> </tr> <tr> <

wso2 - how to configure the WSO2BPS to subscribe to the event stream from a WSO2CEP -

my design of system use cep "engine" of system, customer requests sent on cep events, , re-routed bps trigger different business processes. my question : how may configure bps subscribe event stream(or streams) cep, , 'trigger' execution of business process? thanks wso2 cep capable of communicating several protocols such http, jms, mqtt, thrift, tcp , soap. case can use soap protocol. on wso2 bps side can create bpel workflow. can use wso2 developer studio create project. when creating bpel process use xpath expressions , access requestmessage attributes (which cep stream attributes). once create bpel process can export , upload wo wso2 bpel exposed service. please refer creating bpel workflow tutorial in cep side have stream , have create soap publisher stream , can point wso2 bpel service.

c# - Set WPF Textbox Value in innerclass -

it may bit of noob question i'm not experienced programmer. i using wcf in combination wpf create chatroom gui. problem use callbackhandler set value of textbox incoming messages. because innerclass cannot call textbox. know solution this? namespace wpfclient public partial class mainwindow : window { service1client s; public mainwindow() { initializecomponent(); instancecontext site = new instancecontext(new callbackhandler()); s = new service1client(site); } private void button_click(object sender, routedeventargs e) { message m = new message(); m.content = txtmessage.text; m.user = txtname.text; s.sendmessage(m); } public class callbackhandler : iservice1callback { public void sendmessagetoclients(message m) { //i call alrdy generated textbox here set value, txtmessageall.text("setting text"); } } } } thanks! as ca

android , downloaded file image does not exist? -

i new in android , using android asynchronous http client library download image file server when trying download images status success image not downloaded in internal storage !! here code download.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { string url = getintent().getstringextra("url"); asynchttpclient client = new asynchttpclient(); client.get(url, new fileasynchttpresponsehandler(fullimageactivity.this) { @override public void onfailure(int statuscode, header[] headers, throwable throwable, file file) { toast.maketext(fullimageactivity.this, "error", toast.length_short).show(); } @override public void onsuccess(int statuscode, header[] headers, file response) { toast.maketext(fullimageactivity.this, "done", toast.length_short).

Putting into table from a complicated array using php -

simplexmlelement object ( [@attributes] => array ( [version] => 2.0 ) [channel] => simplexmlelement object ( [title] => yahoo!ニュース・トピックス - トップ [link] => http://news.yahoo.co.jp/ [description] => aa [language] => ja [pubdate] => mon, 17 aug 2015 10:20:57 +0900 [item] => array ( [0] => simplexmlelement object ( [title] => aa [link] => aa [pubdate] => aa [enclosure] => simplexmlelement object ( [@attributes] => array ( [length] => 133 [url] => http://i.yimg.j

shell - Convert UTC time to GMT bash script -

i trying convert utc time gmt time in small script, doesn't work: timestamputc=$(date +"%s") echo $timestamputc dates=$(date -d @$timestamputc) echo $dates ## 2 hours difference between utc , gmt hours2=120 timestampgmt=$((timestamputc - hours2)) echo $timestampgmt diff=$((timestamputc - timestampgmt)) echo $diff dategmt=$(date -d @$timestampgmt) echo $dategmt the displayed result $dategmt same $dates . thanks in advance. error in script. unix timestaps given in seconds. hours2=120 means 120 seconds. so 2 timestaps diverging 2 minutes, not 2 hours. this code correct: hours2=7200 also claim having 2 hours between gmt , utc, i'm sure mean cet (central european time) note: there nothing cet timestamp. it's normal unix timestamp displayed timezone offset. independently of world location, unix timestamp always, worldwide, same @ same instant. you can replace code this # timestamp 2 hours in future date2h=$(date -d "2 hours

html - How to make a responsive mosaic css fullscreen width -

hello having troubles make responsive mosaic, trying acomplish here keep same order of 7 images , if screen smaller make mosaic full width respective proportions in mobile screen maintaining order. this css: #mosaic { width: 100%; background-color: aqua; } .largeimg, .smallimg { /*display: inline-block;*/ float: left; } .largeimg { /*width: 40%;*/ background-color: #165384; } .smallimg { /*width: 60%;*/ background-color: #ef0808; } .col-wrap { display: inline-block; } this demo: jsfiddle demo hope can , reading. you can achieve desired functionality using media queries , code below specific mobile devices, try on; @media , (max-width: 658px) { // mobile devices #mosaic { display:block; // have each musaic in 1 line

java - Parse nested JSON with varying number of entries -

i'm working on bus transit app , 1 of network calls need make gets trip info on how point point b. bus transit api has method provides info. method returns 3 viable itineraries, , each itinerary has variable amount of legs. there 2 types of legs, walking legs , riding legs. i wondering on how should go parsing data , transferring ui. what's throwing me off nested entries have nested arrays of variable length (that can of either 2 types). first retrieve data think using arraylist of arraylist work. should create 2 models correspond 2 type of legs, add data those, , dynamically add listview i'm going use display results? (i have dynamically add itineraries). oh , thing. if bus need on finishes route , starts new 1 (while need stay on whole time) return multiple services in single leg , have no idea how efficiently check , convey user. here's link documentation https://developer.cumtd.com/documentation/v2.2/method/getplannedtripsbystops here's sample json r

javascript - Blanket.js vs Istanbul-js vs JSCover -

i trying decide on js test code coverage tool cannot see differences between them. top hits in google blanket.js, istanbul-js , jscover. can offer information on key differences between them , advantages/disadvantages? are there other useful ones out there? after trying around find istanbul convenient tool bring coverage analysis node-js project. its installed npm install it sets behavior via .istanbul.yml gets invoked own executable it provides multiple report formats such clover, lcov, jscoverage, etc. istanbul uses provided executable or js-script perform tests , collect coverage information. can installed via npm : npm install istanbul mocha after successful installation invoke ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha respect '_' since mocha forks _mocha -executable stated here blanket.js nodejs integrates its installed npm install configuring behavior via package.json getting invoked mocha requiring blanket

android - URL finder from qr code -

i'm developing application scans qr code , displays data stored in it. open browser whenever url stored in qr code. how determine whether normal text or url stored in qr code.. tried using regular expressions or there other way? used zxing library scanning qr codes. please me out its simple. whenever getting data qr code try below. valid url return true otherwise false. try { httpurlconnection con = (httpurlconnection) url.openconnection(); con.setrequestmethod("head"); return (con.getresponsecode() == httpurlconnection.http_ok); } catch (exception e) { e.printstacktrace(); return false; } also see link httpurlconnection

Apache Logging one result in wrong access.log file -

i've created multiple customlog files(created logs different websites), via vhost.conf aren't being logged in access.log from there i've taken 1 step further isolate folder, on website, , log information separately usage can tracked. the code; few setenvif request_uri's removed (like 1 css , js) easier reading. <virtualhost *:80> serveradmin support@domain.com documentroot "/var/www/domain.com" servername domain.com serveralias www.domain.com errorlog "/var/www/domain_apache_error.log" ## flag image requests setenvif request_uri "(\.gif|\.png|\.jpg)$" image-request=nolog ## flag folder calls setenvif request_uri "^/folder/" folder-request=nolog ## set do_not_log if of above flags set setenvif image-request nolog do_not_log setenvif folder-request nolog do_not_log ## log if do_not_log not set customlog "/var/www/domain_folder_access.log" common env=folder-request customlog "/

How to capture mouse cursor location over my uploaded image in html and php? -

i want write text on uploaded image. using html , php. same, trying save position of mouse cursor user clicks on image write text. have tried these things below. shows error in click.php. index.php <form action="click.php" method="post" enctype="multipart/form-data"> <h3>select image upload:<br/></h3> <input type="file" name="filetoupload" id="filetoupload" accept="image/*"/> <input type="submit" value="upload image" name="submit"/> </form> click.php <script> function getpos(e){ x=e.clientx; y=e.clienty; cursor="your mouse position : " + x + " , " + y ; document.getelementbyid("displayarea").innerhtml=cursor } function stoptracking() { document.getelementbyid("displayarea").innerhtml=""; } </script>

ascii - My "\b" character prints a blank space rather than deletes to the left. Is this normal? -

i'm trying replace or delete printed line i'm trying use /b. when enter: print "p\by\bt\bh\bo\bn" it prints out "p y t h o n" rather replacing characters. using special char incorrectly? that works fine, in normal environment: >>> print "p\by\bt\bh\bo\bn" n the first thing would check outputting. if you're under unix-like os, can put following line script called qq.py : print "p\by\bt\bh\bo\bn" the run it, converting output hex dump: pax> python qq.py | od -xcb 0000000 0870 0879 0874 0868 086f 0a6e p \b y \b t \b h \b o \b n \n 160 010 171 010 164 010 150 010 157 010 156 012 0000014 that shows output indeed consist of correct characters. if see that, there's wrong terminal setting in backspace not set correctly, in case it's environmental issue outside scope of programming.

javascript - Accessing custom template property in helper -

i know why need use template.instance() rather this in helpers access property attached template. here code question arose. template.mytemplate.oncreated(function () { this.myproperty = new reactivevar(1); }); template.mytemplate.helpers({ myproperty: function () { return template.instance().myproperty.get(); // works return this.myproperty.get(); // not work. (this.myproperty undefined) } }); i thought this inside helper reference template instance. why not second 1 work? in body of callback under template.oncreated, template.onrendered , template.ondestroyed, this template instance object. however, within helpers, this data context of dom node helper used not template instance. example, html {{> mytemplate name='max'}} template(name='mytemplate') ul {{#each users}} li {{getavatar}} {{/each}} js template.mytemplate.oncreated(function(){ console.log(this); // template.instance() }) template.mytempl

java - Elegant mapping from POJOs to vertx.io's JsonObject? -

i working on vertx.io application , wanted use provide mongo api data storage. have rather clunky abstraction on top of stock jsonobject classes get , set methods replaced things like: this.backingobject.get(key_for_this_property); this , now, won't scale particularly well. seems dirty, when using nested arrays or objects. example, if want able fill fields when actual data known, have check if array exists, , if doesn't create , store in object. can add element list. example: if (this.backingobject.getjsonarray(key_list) == null) { this.backingobject.put(key_list, new jsonarray()); } this.backingobject.getjsonarray(key_list).add(p.getbackingobject()); i have thought potential solutions don't particularly of them. namely, could use gson or similar library annotation support handle loading object purposes of manipulating data in code, , using serialize , unserialize function of both gson , vertx convert between formats (vertx load data -> json st

python - Tkinter Text Scrollbar goes Too Far -

i wondering why scrollbar goes far tkinter text widget . have bottom label supposed fill space below, yet somehow scrollbar reaches beyond label end. not sure widget causing this. import tkinter tk import tkinter.filedialog class textlinenumbers(tk.canvas): def __init__(self, *args, **kwargs): tk.canvas.__init__(self, *args, **kwargs) self.textwidget = none def attach(self, text_widget): self.textwidget = text_widget def redraw(self, *args): '''redraw line numbers''' self.delete("all") = self.textwidget.index("@0,0") while true: dline= self.textwidget.dlineinfo(i) if dline none: break y = dline[1] linenum = str(i).split(".")[0] self.create_text(5,y,anchor="nw", text=linenum) = self.textwidget.index("%s+1line" % i) class customtext(tk.text): def __init__(

javascript runtime error '$' is undefined -

i facing "javascript runtime error '$' undefined" error on asp.net project in visual studio 2010. have tried many solutions given here not succeed. code is <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><link rel="shortcut icon" href="../../favicon.ico" /><title> website </title> <script type="text/javascript" src="../javascript/jquery-1.3.2.min.js"></script> <script type="text/javascript" language ="javascript"> function mainmenu() { $(" #nav ul ").css({ display: "none" }); $(" #nav li").hover(function () { $(this).find('ul:first').css({ visibility: "visible", display: "none"

android - Fragment onKeyDown() not working as intended -

i have framgments called in order fragone calls fragtest , fragtest calls fragbook. when current fragment fragbook on pressing button, fragtest shown split second , app sent app tray. @override public boolean onkeydown(int keycode, keyevent event) { fragmentmanager fragmanager = getsupportfragmentmanager(); fragment frag = fragmanager.findfragmentbytag("frag_book"); if ((keycode == keyevent.keycode_back)) { if (frag.isvisible()) { fragmanager.begintransaction() .replace(r.id.container, fragment.instantiate(mainactivity.this, fragments[1]),"frag_test") .commit(); } } return super.onkeydown(keycode, event); } where have gone wrong in approach? thanks... @override public boolean onkeydown(int keycode, keyevent event) { fragmentmanager fragmanager = getsupportfragmentmanager(); fragment frag = fragmanager.findfragmentbytag("frag_book&quo

ruby on rails - ActiveRecords: Search only on non empty parameters -

so have search on 3 fields. age , sex , ethnicity if age given have return records matching age. if age , ethnicity given sex empty return matching records age , ethnicity. etc.. the naive way of solving this: class profile def self.search_profile(search_params_array) if search_params_array.first != nil && search_params_array.second != null && search_params_array.third != null profile.where("age = ?", search_params_array.first).where("sex = ?", search_params_array.second).where("ethnicity = ?", search_params_array.third) end ... ... # can permutate between possible conditions 1 of element nil ... end end what better way approach this? class profile def self.search_profile(search_params_array) params = %w(age sex ethnicity).zip(search_params_array).reject |_, v| v.nil? end.to_h where(params) end end if can pass search params hash, things can easier.

vb.net - Default Handler created in designer -

if create usercontrol , drag form, double click on it, create sub: private sub myusercontrol_load(sender object, e eventargs) handles myusercontrol.load end sub is possible change default handler? example produce on click handler: private sub myusercontrol_click(sender object, e eventargs) handles myusercontrol.click end sub you'd have create own class this... little waste of time really, since you'd have add code inherit custom class every time create new usercontrol. but if you're interested in testing it: <defaultevent("click")> _ public class myusercontrol inherits usercontrol end class then put in every usercontrol create (below public class line): inherits myusercontrol note error on inherits myusercontrol line. if so, apply fix says "change [class name] inherit myusercontrol." hope helps!

android - Ionic Cordova Build / Manifest Supported Devices on Play Store -

i'm using ionic cordova building android app. i've built , deployed app play store using ionic's deployment instructions. has worked fine apart from, support 5674 devices. many devices nexus 5 (which developed with) not supported. i assuming config.xml or androidmanifest posted below: config.xml <?xml version="1.0" encoding="utf-8" standalone="yes"?> <widget id="xxx" version="0.0.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>xxx</name> <description> xxx. </description> <author email="xxx" href="xxx"> xxx </author> <content src="index.html"/> <access origin="*"/> <allow-navigation href="xxx"/> <preference name="webviewbounce" value="false"/> <preference name="uiwebvi