Posts

Showing posts from March, 2013

javascript - Find element closest to click coordinates -

is there easy way detect closest child element coordinates of mouse click in container?. in case container div ex: <div style="white-space: pre-wrap"> <span>e1</span> <span>\n</span> <span>\n</span> <span>e4</span> <span>e5</span> </div> in above case determine span closest top/left coordinates click took place in div. due line breaks spans don't cover div in click event have access top/left through e.clienty; however, having difficulty traversing spans detect span closest coordinates of click inside div. click handler: function(e){ var yop = e.clienty; } here links might useful document.elementfrompoint : from summary on mdn link: returns element document elementfrompoint method being called topmost element lies under given point. element, specify point via coordinates, in css pixels, relative upper-left-most point in window or frame containing d

c# - Reverse Generated Items & Tab Order of ItemsControl Collection -

so know itemscontrol generate items top-to-bottom in itemspanel. yes can change sort order , generate them in different ways here's actual problem. if have itemscontrol using itemtemplate multiple uielement 's , use example, stackpanel itemspanel end natural tab order of like; a. 1 2 3 4 5 b. 6 7 8 9 10 c. 11 12 13 14 15 expected, use either order of placement or flowdirection on itemtemplate get; a. 5 4 3 2 1 b. 10 9 8 7 6 c. 15 14 13 12 11 now, question how achieve? (in efficient way) order more like; c. 11 12 13 14 15 b. 6 7 8 9 10 a. 1 2 3 4 5 now if you're thinking.. "ugh, shift + tab dummy..." wish option. requirement using tab, , generating collection in reverse bottom top instead of top bottom , having tab order reversed while they're in control. wise try , hijack shift/tab event , convert tab somehow? if case answers part of question. hopefully someones ran before or enjoys interesting question insigh

java - Is this a DAO manager pattern? What are the appropriate class and interface names? -

i have interface, somethingdao , , implementing class, somethingdaoimpl . interface consists of 11 methods, each method requires 1 or more complex sql queries. i broke implementing class several smaller classes, let's call them helper1 , helper2 , helper3 , ... helpern lack of better names. somethingdaoimpl has instance of each, , routes method calls each. public class somethingdaoimpl implements somethingdao { private helper1 helper1; private helper2 helper2; private helper3 helper3; // ... private helper8 helper8; public list<x> getx(...) { return helper1.getx(); } public list<y> gety(...) { return helper2.gety(); } public list<x> getdetailedx(...) { list<x> ds = getx(...); helper6.addto(ds); helper7.addto(ds); helper8.addto(ds); return ds; } } is there name technique? complex dao has several "worker" bees work it, , manages them

python - Why is my method returning None? -

i have following method call: ncols = 3 npegs = 4 first_guess = [] print("calling first guess method") first_guess = firstguess(ncols, npegs, first_guess) print("after method call: " + str(first_guess)) firstguess method: def firstguess(ncols, npegs, first_guess): """used setting first guess of game""" print("in firstguess method") c in range(1, ncols + 1): if len(first_guess) == npegs: print("about return first guess: " + str(first_guess)) return first_guess else: first_guess.append(c) print("out of loop, first_guess len " + str(len(first_guess)) + ", " + str(first_guess)) if len(first_guess) <= npegs: #there less color options pegs firstguess(ncols, npegs, first_guess) this seems returning none reason cannot figure out. here output: calling first guess method in firstguess method out of loop, first_guess len 3, [1,

google chrome - Cross-origin redirect with XHR -

i try realize following scenario: load page origin a.com start synchronous xhr request script on page resource on same origin a.com this request answered 302-redirect resource on origin b.com i expect cross-origin redirect processed, instead error returned xhr-send method , no request nor preflight request triggered. chrome (26): error message 'network_err: xmlhttprequest exception 101' firefox (20): error message [exception... "failure" nsresult: "0x80004005 (ns_error_failure)" ... ie9: no error message xhr send() returns status=12017 according xhr specification have expected redirect works cross-origin. any idea how cross-origin redirect running? that won't work because redirect handled browser , xhr sees page browser got redirected to—which means is cross domain—which means fail unless b.com explicitly allows a.com domain access it. you can have other page on a.com act proxy , download content on b.com , output respo

ruby on rails - Search polygons within polygon with elasticsearch -

is there way search polygons inside polygon elasticsearch? if not, possible solr or system? with solr 4.3 became possible; finished working on couple weeks ago , i'm pretty excited it. learn how use new solr 4 spatial field, see: http://wiki.apache.org/solr/solradaptersforlucenespatial4 what's new can use "iswithin" , "contains" predicates; there's "isdisjointto" too. based on question, it's not clear me of want. imagine 3-part sentence in first/left part index data, there's spatial predicate, there's query shape. if want search indexed shapes within query shape, use "iswithin". update wiki show these predicates.

ASP.NET MVC 3 - How do I allow to enter in html textarea -

i want use granular data validation. [allowhtml] attribute not working formcollection . there alternative use validateinput(false) ? in metadata: [allowhtml] [datatype(datatype.multilinetext)] [display(name = "content")] public string content { get; set; } in edit action: [httppost] public virtual actionresult edit(int id, formcollection formcollection) { var obj = service.get(id); if (modelstate.isvalid) { updatemodel(obj, formcollection); service.update(obj); return onedited(obj); } return view(obj); } you can't use allowhtml formcollection. use [validateinput] attribute disabled validation values: [httppost] [validateinput(false)] public actionresult edit(formcollection collection, int id) { var myentity = _myrepo.get(id); tryupdatemodel(objective); return dosave(objective); } this being said use following: [httppost] public actionresult edit(myentity entity) { if (modelstate.isva

Extract all but the first character in batch? -

to extract first character use: %var:~0,1% to extract last character use: %var:~0,-1% so how extract except first character? i tried looking in "set /?" under cmd prompt didn't help. to extract specific character end of string, specify starting index: %var:~1% this covered in set /? it's buried inside paragraph , not easy find: may specify substrings expansion. %path:~10,5% would expand path environment variable, , use 5 characters begin @ 11th (offset 10) character of expanded result. if length not specified, defaults remainder of variable value. if either number (offset or length) negative, number used length of environment variable value added offset or length specified.

vb.net - Operator '=' is not defined for type 'DBNull' and type 'Integer' -

i've been struggling past few hours , still can't head round 1 . issue having when has been admitted database updates giving them bedid , when try , discharge them can't seem set bedid (in database) nothing . issue need able admit , discharge many people can. sub dis1_click(byval s object, byval e eventargs) handles dis1.serverclick dim time string = now().tostring("dd-mm-yyyy hh:mm:ss") sql = "update allocation set bedid = null , dischargedate =" + "'" + time + "'" + " bedid = 1 " cmd = new odbccommand(sql, cn) cmd.executenonquery() end sub sub bedcheck1() if r("bedid") = "" else if r("bedid") = 1 ba = s & "<tr><td>" & r("surname") & "</td>" & "<td>" & r("forename") & "/<td>" & "<td>" & r("

storage - Why do Android updates of my app erase information? -

in app, have list of objects stored fileoutputstream in code below. also, have settings in app stored sharedpreferences. whenever updated app on google play store first time (for unfamiliar process, upload new apk), objects deleted using app, , settings set default. why did , how can have objects stored don't disappear after update? public objectstorage readlistfromfile() { objectstorage temp = null; string filename = "storefileobj"; fileinputstream fis; try { fis = getactivity().openfileinput(filename); objectinputstream = new objectinputstream(fis); temp = (objectstorage) is.readobject(); is.close(); } catch (filenotfoundexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (streamcorruptedexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktr

jquery - Convert string to time JavaScript (h:m) -

my friend , doing school project; task make room-reservation-site. our first year trying javascript, , want string formatted time (h:m). user of our room-reservation-site can choose time of day he/she wants room, , output is: h:m (24hour-clock:minutes). example 12:15. therefor question is: there possible convert string (h:m) time, , check if user typed more 30minutes of booking-time? can example say: if(start_of_reservation < start_of_reservation(+30minutes)){ alert("you need book room atleast 30minutes"); } else if(start_of_reservation > start_of_reservation(+6hours)){ alert("you can't book room longer 6 hours"); } else { // moving on.. } var year = '2013'; var month = '04'; var day = '18'; var hour = '12'; var min = '35'; var reserv = new date(year,month,day,hour,min) console.log(reserv); those year, month , day values might want fetch yourselves checking current date. purely sh

c++ - Friend class not able to access private data -

here class declaration: template <class t> class sptr { template<typename u> friend class sptr; template <typename t1, typename t2> friend bool operator==(const sptr<t1> &a, const sptr<t2> &b); template <typename u> friend sptr<t> static_pointer_cast(const sptr<u> &sp); private: rc* ref; //reference counter t* obj;//pointer current obj std::function<void()> destroydata; bool ok_; public: sptr(); ~sptr(); template <typename u> sptr(u *); sptr(const sptr &); template <typename u> sptr(const sptr<u> &); template <typename u> sptr<t> &operator=(const sptr<u> &); sptr<t> &operator=(const sptr<t> &); void reset(); t* operator->() const {return obj;}; t& operator*() const {return *obj;}; t* get() const {return obj;}; e

php - Do SQL Server and WAMP Server clash? Do I need to use different ports? -

alright, totally new programming easy on me. followed instructions lynda.com account on how install wampserver windows 7 run unable orange icon change green. have tried connect "put online" received following error: "could not execute menu item (internal error) [exception] not perform service action: service has not been started" so restarted services same error. tried stopping services restarting. no luck , still same error. some following things keep in mind: i have sql server installed before tried install wamp server wonder if they're linked same port. if so, not sure how find , edit port. -i not have skype not using same port. my theory it's having having sql server , mysql using same port. how change port if so. in advance suggestions! i got same problem , found not sql server conflicting, sql server reporting service. went services.msc , stopped sql server reporting service . chagned manual not start automatically

wordpress - How to append tags as classes -

in loop going through posts how can append tags of post part of class of div? <?php $page_name = $wp_query->post->post_name; query_posts('category_name='. $page_name .'&posts_per_page=-1&orderby=date&order=desc'); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="galleryitem "> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a> <div class="titleplate"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="permanent link <?php the_title_attribute(); ?>"> <?php the_title(); ?></a></h3> </div><!--end titleplate--> </div><!--end galleryitem--> <?php end

asp.net mvc 4 - How can I encode URL parameters? -

i used method in class library , calling method controller. value passed not encoding. cant trace reason behind it. class library using system.web; public static class commonlogic { public static string urlencode(string value) { return httputility.urlencode(value); } } controller var test = commonlogic.urlencode("2") test value "2" , not encoded. update: i realized reason comments below. need not encoding encryption , decryption. don't want url parameters exposed plain text, instead want encrypted value , later in controller decrypt again before processing value. ideas on this? "2" doesn't need urlencoded. it's not reserved symbol in urls. try testing string such "<".

jquery disable selectable grays out the element -

i'm trying use button turn on , off .selectable behaviour div on page. can using these commands: $('#selectable').selectable({disabled: true}) or $('#selectable').selectable("option", "disabled", true) the functionality works intended, problem grays out entire element selectable. enabling selectability removes grayed-out look, every time disable selectable grays out. does know how disable selectability attribute without graying out whole element? how destroying selectable $( "#selectable" ).selectable( "destroy" ); , when need $( "#selectable" ).selectable();

How to use Linq to Sql as a Serial Number Generator to avoid Gaps? -

have created following linq sql transaction try , create invoices number without gaps. assuming 2 tables: table 1: invoicenumbers. - columns id, serialnumber, increment - example: 1, 10001, 1 table 2: invoices. - columns: id, invoicenumber, name - example: 1, 10001, "bob smith" dim db new invoices.invoicesdatacontext dim lastinvoicenumber = (from n in db.invoicenumbers order n.lastserialnumber descending select n.lastserialnumber, n.increment).first dim nextinvoicenumber integer = lastinvoicenumber.lastserialnumber + lastinvoicenumber.increment dim newinvoicenumber = new invoices.invoicenumber {.lastserialnumber = nextinvoicenumber, .increment = lastinvoicenumber.increment} dim newinvoice = new invoices.invoice {.invoicenumber = nextinvoicenumber, .name = "test" + nextinvoicenumber.tostring} db.invoicenumbers.insertonsubmit(newinvoicenumber) db.invoices.insertonsubmit(newinv

css - how to get a CSSStyleSheet object from a <style> -

one < style > corresponding 1 cssstylesheet object (in document.stylesheets), how find it, such cssstylesheet object corresponding < style id="-ycoder-styles" >...< /style> console.log(document.stylesheets.length); var style = document.createelement('style'); style.title = "-ycoder-styles"; style.type= 'text/css'; style.id = "-ycoder-styles"; document.head.appendchild(style); //how corresponding cssstylesheet instance document.stylesheets console.log(document.stylesheets.length); var stylesheet = document.stylesheets[document.stylesheets.length - 1]; console.log(stylesheet.title == style.title); based on code provided, should able associated cssstylesheet with: var stylesheet = style.sheet this work after <style> element has been appended document. not exceptionally documented , difficult find poking around in console.

Select records with repeatable datetime PostgreSQL -

i facing problem calendar. i have extract records (events) (via select) with: 1. specific date, or 2. repeatable date the problem normal calendar displays entire month (or specific range of time), possible select record subset generated subquery (and compare date fragments), i.e.: select (generate_series('2012-06-29 00:00:00', '2012-07-03 00:00:00', '5 minutes'::interval))::timestamp; i have build view of calendar infinite list of events, can scroll down. have display events one-by-one. when select events (i.e. 2012-06-29 00:00:00 2012-10-29 00:00:00), statement not consider record date 2012-10-30 00:00:00, not expected. how can select multiple, non-continuous dates? the database schema: create table "public"."events" ( "id" int4 default nextval('events_id_seq'::regclass) not null, "date" timestamp(6), "date_repeat_interval" interval(6), &

java - trouble with ebeans in play framework -

hi dudes new play framework , hate tutorials in google missing every time have problem following code body me please. public static model.finder<long, blog> find = new model.finder<long, blog>(long.class, blog.class); public static list<blog> getallblogs(){ list<blog> menus = new arraylist<blog>(); menus = ebean.find(blog.class).findlist(); return menus; } what issue .class @ end of long , blog because in <> have why must explicitly type again? problem ebeans or thing else don't understand exactly

data binding - Apply the Grid Changes in Chart without using SharedDateSource? -

in project having same data-source grid , chart, need display data on chart in page load , display grid data in button click. but used shared data-source can apply grid changes in chart. used separate variable grid , chart , apply "autobind=true" chart , "autobind=false" both not working , grid changes has apply chart. how give relation both grid , chart? here fiddle : var shareddatasource = new kendo.data.datasource({ type: "odata", transport: { read: "http://demos.kendoui.com/service/northwind.svc/orders" }, schema: { model: { fields: { orderdate: { type: "date" } } } } }); var datasource = new kendo.data.datasource({ type: "odata", transport: { read: "http://demos.kendoui.com/service/northwind.svc/orders" }, schema : { model: { fields: { orderdate: { typ

osx - Bus Error 10 on Mac when creating a binary tree in C -

i getting bus error when i'm trying create binary tree using structures in c. please suggest me solution overcome bus error. compiling on mac osx. #include <stdio.h> #include <stdlib.h> struct node { int data; struct node* left; struct node* right; }; struct node* newnode(int data) { struct node* inode ; inode->data = data; inode->left = null; inode->right = null; printf("%d\n", inode->data); return(inode); } struct node* insert(struct node* node ,int data){ if(node == null) return(newnode(data)); else{ if(data <= node->data) node->left = insert(node->left, data); else node->right = insert(node->right, data); return(node); } } struct node* build123a() { struct node* root = newnode(2); struct node* lchild = newnode(1); struct node* rchild = newnode(3); root->left = lchild; root->right= rchild; return

iOS dropbox SDK loading thumbnails and number of files inside a folder -

hi developing application brings entire folder , file structure content management system have done box , sharepoint integration. looking sync dropbox now. in dbmetadata class have properties bool thumbnailexists; nsarray* contents; nsstring* icon; first thing want here want load thumbnails of files, not 1 thing icon property returns string, 'page_white_acrobat' (i thought return url or download thubmnail). there way bring thumbnails using dropbox sdk. uploaded .mp4 file , .png file, show thumbnails when open dropbox in chrome in sdk thumbnailexists property returns no. second want number of sub folders , files folder, tried accessing contents property of folder dbmetadata object , returned nil. there way in sdk count number of files inside folder or work around. it seems dropbox provides name of icon use. can't download it, should check string , use resources in app bundle. the contents of dbmetadata object null until make request load metadata @ path

iphone - Facebook: Get facebook messages for specific Date? -

i wanted facebook's messages not feeds . i've searched did not find solution. i have looked fql same didn't find useful things. is possible messages facebook specific date ? or messages ? it's possible lastest facebook messages on top of thread(conversation session) specific time fql api, such select snippet, recent_authors, updated_time thread folder_id = 0 , updated_time=1364564697 also, it's possible facebook message specific time api within thread. such as select body, created_time message thread_id=1774741570083 , created_time=1348806942 for question. yes. it's possible facebook message inbox messages specific date(by date, not time, request). example, inbox messages "thu aug 23 2012 00:00:00 gmt+0800 (myt)" "fri aug 24 2012 00:00:00 gmt+0800 (myt)" select body, created_time message thread_id in (select thread_id thread folder_id = 0) , (created_time>=1345651200 , created_time<1345737600)

python - PyVISA IV sweep with Keithley -

i'm trying iv curve measurement keithley , pyvisa. found matlab example on keithley website , there's 1 section not understand. % used serail poll function wait srq val = [1]; % 1st instrument in gpib object, not gpib add spoll(obj1,val); % keep control until srq fprintf(obj1,':trac:data?') what serial poll function do? , don't have spoll function in pyvisa, i? serial polling implemented in higher-level drivers. repeated querying scpi *stb? or equivalent bus command. pyvisa's read_stb(vi) calls visa's vireadstb(vi) . can own polling. edit: read_stb pyvisa's low-level module. use low-level calls need pass vi field obtained instrument object. there example here sure use appropriate scpi commands instrument , status model. status polling depends on status , event registers being set before measurements start. can set instrument indicate samples available or measurement complete. if bus gpib (ieee 488.2) pyvisa&

php - Access denied BO prestashop -

Image
in main page bo, catalog ->products -> edit ()->combination->product combinations generator , in administration -> permissions ->edit access denied.i attached print screen. how resolve that? find in ps_access tab adminhome , edit row.put 1 everywhere.

java - How to store values that dynamic column generated based on which on table and pass to querystring -

my title might not clear enough, let me explain senario first. have dropdownlist fetches table list table. if choose 1 of tables, show columns following code: <% string columnsql = "select column_name columnname information_schema.columns " + "where table_name = '"+ tablename + "' order ordinal_position"; printdebug.println("table:" + tablename); resultset myrs = adbmanager.retrieverec(columnsql); int count =0; //string[] arraycolumn; //boolean[] arraycheckbox; //string[] arraysearch; while (myrs2.next()) { columnname = myrs2.getstring("columnname"); //printdebug.println("column"+count+": " + columnname); %> <label id="lblcolumnname<%=count %>" value=<%=columnname%>> <%=columnname%></label> &nbsp; &nbsp; <input id="chkcheckbox<%=count %>" type="checkbox" value=<%=columnname %>> &a

android - Dynamic resource id for inflater.inflate -

i having dynamic layout below code. linearlayout=new linearlayout(sactivecontext); linearlayout.setlayoutparams(new layoutparams(layoutparams.fill_parent,layoutparams.wrap_content)); linearlayout.setorientation(linearlayout.vertical); customwebview webview=new customwebview(sactivecontext); framelayout layout=webview.createwebview(); (int = 0; < arraylist.size(); i++) { if(tab.getposition()==i) { webview.initwebview(arraylist.get(i)); mwebviewlist.add(i, webview); break; } } linearlayout.addview(layout); now, how can inflate linearlayout? please give suggestions. you return linearlayout object @ return statement of oncreateview. or else can add linear layout object inflated view(myfragmentview) can inflate xml layout files , not dynamic layout.

javascript - to distinguish between device and server internet connectivity -

i trying hit sharepoint server phone(ios) having wifi feature. basically, making ajax call sharepoint server , using response further tasks. when device has wifi off, http response status '0' , when device has wifi 'on', sharepoint server not connectible, status comes '0'. how can differentiate between 2 scenarios , handle both scenarios differently. appreciated. use reachability arc version: https://github.com/tonymillion/reachability

android - save Json object to a class with variable name same as in Json -

i want save json object class variable names same in json (just gson does). problem use gson is, datatype of class variable in json changes according datas available in server. example, times, contains list of data,and other time, contains "" null. gson crashes while dealing both cases single code. you can use normal json object, gson predefined datatype , makes handling data easier. if have changes in datatype, better use json itself.

How to generate report on a button click in an asp.net website in visual studio 2010? -

i building billing software school. having problems on printing bill. 1.should use report viewer or crystal report ?? whichever use have bind report source 1 of table in sql server database. 2.how can this?? 3.also want generate bill on button click. how can this?? whether want use ssrs or crystal entirely you, if want know advantages/disadvantages of 2 recommend reading - compare sql server reporting services crystal reports . you find large number of developers choose go ssrs, if feel same here's nice step-by-step example started - rdlc report in asp.net

c# - Deploy sql+winforms application on Linux/Ubuntu while development server is still Windows -

i have limited knowledge linux/ubuntu platform. there requirements coming though me deploy version of our desktop application on either of above platforms. with context, have following queries in mind: could same code can run on windows using mono/mono ide , can compile output os specific? or assuming there changes must make run them on different os, best way deploy on linux/ubuntu? or possible keep same code under windows development, can deployed on linux/unix environment? sql wont work on unix you'll need convert first. yes thats way go. you need step 1 work out if there required changes specific os's. assuming required assembly supported mono, shouldn't have - should binary compatible. that's 1 of points of il :) if find things aren't supported mono, suggest have unix branch of code.

c# - Connecting to Unity 3d tcp server from mac -

i have tcp server inside unity 3d app. want connect macbook. unity code in c#. listener = new tcplistener(port); // start listening listener.start(); // wait our first client listener.beginaccepttcpclient(onaccepttcpclientcomplete, this); now, want connect mac terminal on wifi. compiled app both android , ios apps. android, have given permission in manifest file - . but, ios, unable connect or telnet iphone or ipad. there permission required? missing ios? note: app ios compiles well, installs correctly on device well. no errors in xcode console. able telnet device itself, unable telnet outside.

restoring wordpress database from mysql dump -

is there way correctly restore wordpress database older mysqldumb file (.sql)? can't remember wordpress version, wasn't lower 3.4.2. at moment whenever try restore this: mysql -u blogadmin -p new_db < old_db_dump.sql i no error (at least no error output) , white first page on blog. white first page means there php error during rendering of page. try enable php error_reporting (or error logging) , see these error messages. depending on error messages can try fix wp scripts version or apply updates db.

Is it hard to transplant my ios app to android app? -

this question has answer here: converting iphone/ipad apps onto android [closed] 9 answers i have ios app want achieve deploy android play market, hard it? know how develop object c program, not familiar android coding. suggestion appreciated! thanks! i reality cannot convert ios app written in objective c android app. if using html , js easier ,other wise better start java , xml android here , if know logic of app can implement if quite easily.

Social authentication with Apache Shiro -

what best way integrate social authentication apache shiro? i've search site other sites , couldn't find answer. you can have @ tutorial: http://mrdwnotes.wordpress.com/2011/11/28/using-apache-shiro-security-to-allow-login-via-facebook-part-2/ it explains how use shiro allow facebook authentication.

unicode - Python escape sequence \N{name} not working as per definition -

i trying print unicode characters given name follows: # -*- coding: utf-8 -*- print "\n{solidus}" print "\n{black spade suit}" however output not encouraging. the escape sequence printed is. activepython 2.7.2.5 (activestate software inc.) based on python 2.7.2 (default, jun 24 2011, 12:21:10) [msc v.1500 32 bit (intel)] on type "help", "copyright", "credits" or "license" more information. >>> # -*- coding: utf-8 -*- ... print "\n{solidus}" \n{solidus} >>> print "\n{black spade suit}" \n{black spade suit} >>> i can see another asker has been able successfully. what's wrong? those sequences work in unicode strings , kind of string python 3 has. in python 2 need prefix string literal u . >>> print "\n{solidus} \n{black spade suit}" \n{solidus} \n{black spade suit} >>> print u"\n{solidus} \n{black spade suit}" / ♠

php fail to compare two exactly same string -

i've following piece of code $path = $resource['path']; if (strpos($path, base_url()) == 0) { $path = fcpath. substr($path, strlen(base_url())); } echo '<pre>'; $x = '/home/gofrendi/public_html/no-cms/themes/ubuntu/assets/default/script.js'; var_dump($path); var_dump($x==$path); var_dump('/home/gofrendi/public_html/no-cms/themes/ubuntu/assets/default/script.js' == $path); echo '</pre>'; i'm sure $path consists of /home/gofrendi/public_html/no-cms/themes/ubuntu/assets/default/script.js and get: string(82) "/home/gofrendi/public_html/no-cms/themes/ubuntu/assets/default/script.js" bool(false) bool(false) seems comparison failed. what's wrong here? php bug or mistake? edit: gladly show result of code: echo '<pre>'; $x = '/home/gofrendi/public_html/no-cms/themes/ubuntu/assets/default/script.js'; var_dump($path); var_dump($x); var_dump($x==$x); var_dump($x==$path); var_dump(

python - what does this operator means in django `reduce(operator.and_, query_list)` -

i reading questions constructing django filter queries dynamically args , kwargs i not able operator do filter(reduce(operator.or_, argument_list)) or this filter(reduce(operator.and_, query_list)) filter regular method of django model manager, there nothing explain. reduce built-in function similar code below: def reduce(func, items): result = items.pop() item in items: result = func(result, item) return result where func user defined function. operator.or_ python standard library function wraps or operator. similar code: def or_(a, b): return | b for example: reduce(operator.or_, [false, false, true]) will return true . in example context, or , and operators overloaded , therefore should return new query combined of smaller parts concatenated or or and operator.

Scroll issue in Jquery DataTable -

i not sure if repeating question if yes guide right place :) i using data table , trying implement horizontal scrolling , found link http://www.datatables.net/examples/basic_init/scroll_x.html i used these properties in data table code , having issues in ui. my data got horizontal scroll bar columns didn't expand , not working expected.i got additional empty column below normal column. basically ui messed up. saw old thread discussion on same! datatables fixed headers misaligned columns in wide tables are these issues fixed solutions ? ================================ adding sample code $("#results").datatable({ "aadata": [ //my data ], "aocolumns": [ //my columns ], "bpaginate": true, "bsort": true, "bfilter": false, "bjqueryui": false, "bprocessing": true, "sscrollx": "100%", "sscrollxinner&quo

OSGi bundles as SOAP web services in a plugin architecture -

i expose osgi bundles soap web services or in other words publish web service endpoints provided osgi bundles. the architectural model/idea there host web application normal war file deployed on jboss (5.1.0 ga) offering soap web service interface (jax-ws). this host application starts osgi framework embedded (via servletcontextlistener - equinox) , loads number of osgi bundles function plugins. plugin bundles have dependency host application part of request processing delegated them via internally defined interfaces. at same time plugin bundles should able contribute own public soap web service interface (endpoint implementations , respective wsdl files published , made available application server). first approach followed host web application deploys dispatcher/proxy servlet delegates processing relevant endpoints provided osgi bundles. there servlet bridge solution in osgi/equinox (bridgeservlet/httpserviceservlet) enables programmatic registration of servlets (for ex. i

struts2 - There is no Action mapped for namespace [/] and action name - Struts 2 -

Image
i getting error when using annotation instead of xml in struts 2. @namespace("/") @result(name = "success", location = "/output.jsp") public class helloanno extends actionsupport{ private string name; @action(value = "/annotest") public string execute(){ return success; } @requiredfieldvalidator(message = "required!") public string getname() { return name; } public void setname(string name) { this.name = name; } }

classpath - jar file not working java.lang.NoClassDefFoundError -

when run jar file in cmd error: exception in thread "main" java.lang.noclassdeffounderror: javax/media/j3d/canvas3d it happens both when use java -cp . main , java -jar balljump.jar im sure set classpath right have no idea why error message. this manifest.txt: main-class: main class-path: .;"c:\program files\java\java3d\1.5.2\lib\ext\j3dcore.jar";"c :\program files\java\java3d\1.5.2\lib\ext\j3dutils.jar";"c:\program files\java\java3d\1.5.2\lib\ext\vecmath.jar" i have tried replace ";" " " , add " class path suggested in answers non of them worked try replace ";" semicolon " " space separating jars in manifest.mf

event handling - Error 1023 Stack overflow with as3-signals-v0.9-BETA -

i using as3-signals-v0.9-beta in simple slide application. in signal handler, dispatching same signal again based on conditions. the application throws exception after couple of hours on signals dispatch method. below stack trace: error: error #1023: stack overflow occurred. @ com.chetansachdev.components::slidedeck/onnextslidepleaseevent()[d:\cb-trunk\solutions\components\slidelib\src\com\chetansachdev\components\slidedeck.as:75] @ org.osflash.signals::slot/execute()[c:\users\robert\documents\flash\osflash\signals\as3-signals\src\org\osflash\signals\slot.as:87] @ org.osflash.signals::oncesignal/dispatch()[c:\users\robert\documents\flash\osflash\signals\as3-signals\src\org\osflash\signals\oncesignal.as:125] @ com.chetansachdev.components::slidedeck/onnextslidepleaseevent()[d:\cb-trunk\solutions\components\slidelib\src\com\chetansachdev\components\slidedeck.as:89] @ org.osflash.signals::slot/execute()[c:\users\robert\documents\flash\osflash\signals\as3

css - Autoscaling an SVG embedded in HTML on window resize -

i embed svg in html page in way such is automatically resized (using svg, css, or js) when page resized, while still preserving original aspect ratio. for example, using example w3schools: <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red"/> </svg> is possible set svg width = 5% of window width, , have height scaled proportionately? i've tried couple things including preserveaspectratio="xminymin meet" , setting dimensions 100% within <div> container, haven't gotten working yet. any suggestions? you need viewbox -attribute on svg root element, define overall size of svg-image: <svg version="1.1" viewbox="0 0 300 185"> now can set width or height of image via css , scale perfectly.

Extending Core.Option module in F# -

i want extend 1 of existing "core" modules, core.option : module microsoft.fsharp.core.option let filter predicate op = match op | some(v) -> if predicate(v) some(v) else none | none -> none (i know bind function, think filter method options in case more convenient). but unfortunetely can't use filter method without explicitely open microsoft.fsharp.core namespace: // commenting following line break code! open microsoft.fsharp.core let v1 = 42 let v2 = v1 |> option.filter (fun v -> v > 40) printfn "v2 is: %a" v2 in cases can't use functions module without opening appropriate namespace. f# compiler "opens" predefine (core) namespace automatically (like microsoft.fsharp.core ), not bring scope methods "module extensions" , still should open core namespaces manually. my question is: there workarounds? or best way extend "core" modules create such extensions in cus

c# - Can't write in sql table with parameters -

i want write data in sql table following code en error. when have in visual studio can see there data in @p1, etc... sqlcommand send = new sqlcommand("insert test(code,type,datum,uur,controller,fout,teller,omschrijving,graad,var1,var2,var3,var4,var5,var6,var7,var8,var9,var10,var11,var12,var13,var14,var15,var16,var17,var18,var19,var20,var21,var22,var23,var24,var25,var26,var27,var28,var29,var30,var31,var32,var33,var34,var35,var36,var37,var38,var39,var40)" + "values (@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9,@p10,@p11,@p12,@p13,@p14,@p15,@p16,@p17,@p18,@p19,@p20,@p21,@p22,@p23,@p24,@p25,@p26,@p27,@p28,@p29,@p30,@p31,@p32,@p33,@p34,@p35,@p36,@p37,@p38,@p39,@p40,@p41,@p42,@p43,@p44,@p45,@p46,@p47,@p48,@p49)", connection); while (foutinformatie[0, lusteller] != null) //zolang uitvoeren als er data { //rij per rij in tabel plaatsensd key = foutinformatie[0, lusteller] + "/" + foutinformatie[1, lusteller] + "

How to get a json file into a text variable in javascript -

i new using json file , wanna put file text variable in javascript run function not in object.... have been trying this.. nothing... var jqxhr = $.getjson( "json/test.json", function() { console.log( "success" ); }) alert (getdepth(jqxhr)); what going want retrieve contents of json file within success callback - var jqxhr = $.getjson( "json/test.json", function(jsondata) { console.log( jsondata ); }) note resulting variable ( jsondata ) not in fact contain text - contains javascript object.

c# - How to name a Class whose only purpose is to return a Boolean -

i have class sole responsibility tell me if remote command has returned yes or no , i'm not sure how name it. more specifically, application front end collection of linux commands. communicate linux via ssh. each business operation (ex. getitem, createitem, getitemcount, etc) maps command class. each command class derives base ssh command class handles communication details. my latest command check if remote file of type (let's call doodle type). achieve remote file run through remote program , if program returns 1 or more lines on console file doodle. now i'm struggling how name class. if method , not class call isdoodle . because class involves getting information remote location , derives command base class, i'm tempted use getisdoodlecommand . any thoughts? update while understand suggestion of using commandresult don't think fits in existing pattern use. or maybe don't understand! either way, think original question benefit

How to #define if in C++ to be python-like -

i know can define like #define less(x, y) if(x < y) so wonder can define if in c++ python-like template or not? such as if x < y: something instead of if(x < y) something to put shortly - no . from cplusplus.com : when preprocessor encounters directive, replaces occurrence of identifier in rest of code replacement. replacement can expression, statement, block or anything. preprocessor not understand c++, replaces occurrence of identifier replacement. what want #define if(x):(y) if(x){##y##}; nevertheless, colon keyword , can't used identifier, breaks macro definition. there's no way escape it.

delphi - How to sent text string to service? -

i have desktop application , service. how can send string desktop application service , handle in service? i don't want use sockets because may blocked windows firewall. if don't want use network transport simplest way cross-session ipc use named pipe. main thing take care on need supply security attributes when creating named pipe. without doing won't succeed in cross-session communications. code looks this: var sa: tsecurityattributes; .... sa.nlength := sizeof(sa); sa.binherithandle := true; convertstringsecuritydescriptortosecuritydescriptor( 'd:(a;oici;grgw;;;au)',//discretionary acl allow read/write access authenticated users sddl_revision_1, sa.lpsecuritydescriptor, nil ); fpipe := createnamedpipe( '\\.\pipe\mypipename', pipe_access_duplex, pipe_type_message or pipe_readmode_message or pipe_wait, pipe_unlimited_instances, 0,//don't care buffer sizes, let system decide 0,//don't care buffer sizes, let syst

Get number of overlapping pixels PHP -

what shortest way number of overlapping pixels between 2 rectangles in php if have x,y coordinates , height/width? bit of best-practices question since i'm doing buggy/messy collection of if statements. edit: trying fix @ moment: echo overlapping(1,1,5,5,4,4,6,6).php_eol; echo overlapping(0,0,29,21,30,20,40,50).php_eol; function overlapping($x1,$y1,$w1,$h1,$x2,$y2,$w2,$h2){ $wover = abs($x1+($w1/2) - ($x2+($w2/2))) - ($w1/2)+ ($w2/2); $hover = abs($y1+($h1/2) - ($y2+($h2/2))) - ($h1/2)+ ($h2/2); return $wover*$hover; } echo overlapping(0,-1,10,20,30,20,40,50); function overlapping($x1,$y1,$w1,$h1,$x2,$y2,$w2,$h2){ $wover = abs($x1+($w1/2) - ($x2+($w2/2))) > ($w1/2)+ ($w2/2)?0:1; $hover = abs($y1+($h1/2) - ($y2+($h2/2))) > ($h1/2)+ ($h2/2)?0:1; if($hover && $wover ){ return 'over'; } return 'not'; } http://sandbox.onlinephpfunctions.com/code/1ea506fd72f827965d7241d520789a833b34dff5

First Name from database in php login form -

i have login form users , admin , want users greeted there first name after login. i have table called users following columns id , username , password , admin , fname , lname i have login script code below , if guys/gals can offer new php //connect db include("conndb.php"); session_start(); //get variables login form $username = $_post['username']; $password = $_post['password']; echo $username; echo $password; $password = md5($password); //query find if user , password exist , match password. $query = "select username, admin users (username = '$username' , password = '$password')"; $result = mysql_query($query) or die (mysql_error($connect)); if (mysql_num_rows($result) !=1) { $_session['loginfail'] = 1; header ('location: index.php'); } elseif (mysql_num_rows($result) ==1) { // check admin flag $a = mysql_fetch_array($result); if ($a[admin] == y) { $_session['admin']

vb.net - Not able to get data from oracle server to System.Data.DataTable -

i calling below query vb.net application oracle server , same query got executed on oracle sql developer , gives result properly. when same query called vb.net code below, result comes 0 rows in data table without exception. thanks in advance. oracle with sdk (select roll_no student roll_no='1001';) select * sdk; vb dim myconnectionstring string = &quot;provider=msdaora.1;data source=student;user id=ss;password=1234; dim myoledbconnection new oledbconnection(myconnectionstring) dim lodatatable new datatable dim locommand new oledbcommand dim lodataadapter new oledbdataadapter locommand.commandtext = "with sdk (select roll_no student roll_no=&#39;1001&#39;)select * sdk;" locommand.commandtype = commandtype.text locommand.connection = myoledbconnection locommand.commandtimeout = 0 lodataadapter.selectcommand = locommand lodataadapter.fill(lodatatable) you have 2 different queries: with sdk (select roll_no student

Long Polling with Ajax and PHP - Apache freezes -

we try implement long-polling based notification service in our company's erp. similar facebook notifications. technologies used: php timeout set 60 seconds , 1 second sleep in each iteration of loop. jquery ajax handling. apache web server. after month of coding, went production. few minutes after deployment had rollback everything. turned out our server (8 cores) couldn't handle long requests 20 employees, using ~5 browser tabs each. example: user opened 3 tabs our erp, 1 long-polling ajax on each tab. opening 4th tab impossible - hangs until 1 of previous 3 killed (and therefore ajax stopped). 'apache limitations', thought. went googling. found info apache's mpm modules , configs, gave try. our server use prefork mpm, apachectl -l shown us. changed few lines in config this: <ifmodule mpm_prefork_module> startservers 1 minspareservers 16 maxspareservers 32 serverlimit 50% maxclients

change application visibility according to user's choice in android -

hi developing application show/hide application according user's choice.in application, display applications installed on device , there check boxes application listing . if user select check box application not show menu if hidden show, when user presses ok button. there way show/hide application android device.can tell me way solve problem. yes, create own launcher/homescreen activity. android perfect creating kind of thing. refer question: how can create custom home-screen replacement application android?

java me - Nokia QA: The application cannot be launched successfully with an error message 'Application not supported. Delete?' -

my java s40 app asha failed qa test above title. have tried recreating problem download jar file 1 of supported asha phone , app launched successfully. every other things seems okay have used nokia rda test app. other reasons may causing failure. just error message can assume jar file's midp & cldc version doesnt match s40 asha series phone. you need open editor/ide , change midp version 2.0 & cldc's version 1.1.

c# - Object Reference Not set to instance of an object error while using FirstOrDefault -

when use below code, object reference error, might because there no match "spider". question is, how check null value in these situations int fooid = foos.firstordefault(f => f.bar == "spider").id; i'm using same scenario different conditions fetching different items list int fooid = foos.firstordefault(f => f.bar == "spider").id; string foodescription = foos.firstordefault(f => f.sides == "cake").description; is there other way check null values. the same way would, assign variable , check it. var foo = foos.firstordefault(f => f.bar == "spider"); if (foo != null) { int fooid = foo.id; } based upon updated example, need instead: var fooforid = foos.firstordefault(f => f.bar == "spider"); var foofordescription = foos.firstordefault(f => f.sides == "cake"); int fooid = fooforid != null ? fooforid.id : 0; string foodescription = foofordescription != null ? foofor