Posts

Showing posts from February, 2015

ruby - Capybara: Unable to find xpath "/html" (Capybara::ElementNotFound) -

i have read lot of articles online , have yet find resolution problem. using selenium webdriver: capybara.default_driver = :selenium capybara.javascript_driver = :selenium class firefoxbrowser capybara.register_driver :firefox |app| client = selenium::webdriver::remote::http::default.new client.timeout = 280 capybara::selenium::driver.new(app, :browser => :firefox, :http_client => client) end end here gemfile: gem "rspec" gem "zentest" gem "cucumber" gem "selenium-webdriver" gem "capybara", "~> 2.1.0" gem "capybara-webkit", "~> 1.0.0" gem "simplecov", :require =>false, :group => :test gem "capybara-screenshot" gem "autotest", "~> 4.4.6" gem 'json', '~> 1.7.7' gem "rack-test", require: "rack/test" gem "poltergeist" i running ruby code us

Cannot display errors with spring <form:errors/> -

i not able spring validation errors displayed on jsp page. here code. on jsp page, when enter empty name, controller code return modelandview errors, doesn't display on jsp page. any appreciated. thank you! @requestmapping(value = "/edittag.htm", method = requestmethod.post) public modelandview edittag(@modelattribute("tag") tag tag) { bindingresult result = new beanpropertybindingresult(tag, "tag"); validationutils.rejectifemptyorwhitespace(result, "name", "field.required", "tag name required"); if (result.haserrors()) { return new modelandview("tag.edit").addobject("tag",tag).addobject("errors", result); } tagdao.merge(tag); return new modelandview("redirect:/tags/listtags.htm"); } <form:form commandname="tag"> <form:errors path="name"/><br /> <form:input path="name" size="30&q

jquery - Show a div for couple of seconds and then disappear automatically -

when page loads, div should appear 3 seconds , automatically disappear. i'm having trouble code @ moment. i'm using code below: jquery("#infor").delay(6000).fadeout("slow"); my html is: <div id="infor"> </div> but doesn't seem working. have idea why code not working? is code within document.ready block? $( document ).ready(function() { $("#infor").delay(3000).fadeout("slow"); }); it works me: http://jsfiddle.net/ydu4z/

css - How to hide/show the content of a div with dynamic height? -

i trying develop small module (like collapse component of twitter bootstrap). i don't know how treat content of div growing up/down, take me many descriptions, nothing's better example: collapse deployment . you can see div.container block destined grow up/down. here declare height: 50px illustrate state of deployment. is there way hide content (here part of text) out of height of parent div ? i idea can access content deploying one, don't don't understand how make happen in css. like this? jsfiddle example: http://jsfiddle.net/sw86b/1/ updated css .header { background-color: green; height:20%; } .container { background-color: red; height: 0; overflow: hidden; -webkit-transition: height 0.2s ease; -moz-transition: height 0.2s ease; transition: height 0.2s ease; } .container.open { height: 50px;} p { margin: 0; } use jquery toggle states $('button').on('click', function(event){ $('.con

.net - Retrieving value from database and set dropdown selected item -

i having hard time retrieve value database columns , assign value dropdownlist.selecteditem.text. have query like select [productname]+' '+ '('+[category]+')' productnamecategory products i want assign query result drop down list. this dropdownlist.selecteditem.text=productnamecategory can call displaymember on ddl? the below syntax windows app. combobox set ddl. need tell value binded. try //try block opening, querying , displaying pulled data { sqlconnection sqlconn = new sqlconnection("connstring"); //connection string sqlconn.open(); using (sqldataadapter dataadapter = new sqldataadapter("select * test_names", sqlconn)) { var table = new datatable(); a.fill(table); combobox1.datasource = t; combobox1.displaymember = "firstname"; //name of column/displayname

plone - How should I create an action on the content tab of a folder that acts on all items that are selected? -

i asked series of questions in post last week, , person answered wisely suggested split separate questions. have added cmf action folders called "remote publish". button shows when viewing "content" tab folders. how 1 add logic simple writing titles of selected items log when button clicked? have selected items share titles web service have written, thinking baby steps :d appreciated. the simplest thing can is: copy other button doing! for example: copy cmf skin script name folder_delete.cpy . you'll see paths parameter if loaded request.

Resolve function not working in Angularjs $dialogue service -

folks using ui.bootstrap.dialog server open modal window data in it. in order create modal window have following code: $scope.data = {"one" : "a","two" : "b"}; $scope.viewopts = { backdrop: true, keyboard: true, backdropclick: false, templateurl: 'templates/view-add-dialogue.tpl.html', controller: 'viewadddialogcontroller', resolve: { user: function(){ return $scope.data; } } }; $scope.addcustomview = function() { console.log("addcustomview"); var d = $dialog.dialog($scope.viewopts); d.open(); }; later on have defined controller below: function veiwadddialogcontroller($scope,dialog,user){ console.log(user); $scope.close = function(result){ dialog.close(result); }; } however "user" object gets passed controller not have data instead prints following console: function (){ return $scope.data; } what missing here ? ok .. using

python accessing global variable in the method.? -

kindly bare if question silly, c/c++ background. i have following code. #!/usr/bin/python import os class logger(object): def __init__ (self): print "constructor of logger " def logmsg(self): print "logmsg::" class filelogger (logger): def __init__ (self): print "constructor of file logger" def logmsg (self): print "filelogger::" class ftplogger (logger): def __init__ (self): print "constructor of ftp logger" def logmsg (self): print "ftplogger::" def logmsg(log): print "logging message" loghandler.logmsg() # **here: how possible access loghandler variable?** loghandler = filelogger (); logmsg(loghandler); question: how logmsg() function of filelogger class able access loghandler?. can consider 'loghandler'is global variable? when define loghandler variable outside function, variable become

sign() much slower in python than matlab? -

i have function in python takes sign of array (75,150), example. i'm coming matlab , time execution looks more or less same less function. i'm wondering if sign() works , know alternative same. thx, i can't tell if faster or slower matlab, since have no idea numbers you're seeing there (you provided no quantitative data @ all). however, far alternatives go: import numpy np = np.random.randn(75, 150) asign = np.sign(a) testing using %timeit in ipython : in [15]: %timeit np.sign(a) 10000 loops, best of 3: 180 µs per loop because loop on array (and happens inside it) implemented in optimized c code rather generic python code, tends order of magnitude faster—in same ballpark matlab. comparing exact same code numpy vectorized operation vs. python loop: in [276]: %timeit [np.sign(x) x in a] 1000 loops, best of 3: 276 per loop in [277]: %timeit np.sign(a) 10000 loops, best of 3: 63.1 per loop so, 4x fast here. (but a pretty small here.)

prolog and translating propositional logic -

my ultimate goal load set of propositional formulas in prolog file in order deduce facts. suppose have propositional formula: p implies not(q). in prolog be: not(q) :- p prolog not seem not operator in head of rule. following error: '$record_clause'/2: no permission redefine built-in predicate `not/1' use :- redefine_system_predicate(+head) if redefinition intended i know 2 ways rewrite general formula p implies q . first, use fact contrapositive logically equivalent. p implies q iff not(q) implies not(p) second, use fact p implies q logically equivalent not(p) or q (the truth tables same). the first method leads me current problem. second method conjunction or disjunction. cannot write conjunctions , disjunctions in prolog not facts or rules. what best way around problem can express p implies not(q) ? is possible write propositional formulas in prolog? edit: wish connect results other propositional formulae. suppose have following

ios - Any way to specify a path pattern with parameters in RestKit 0.20? -

i trying consume web service path object?special=true&id=100 should map specialobject , path object?special=false&id=100 should map regularobject . but when try use pathpattern s of "object?special=true" , "object?special=false" in rkresponsedescriptor s not working - restkit reports url object?special=true&id=100 not match descriptors. is possible specify path pattern use in rkresponsedescriptor incorporates specific parameter value? not really. pattern matching based on path, not parameters. don't think it's possible use parameters during pattern matching. one option use dynamic mapping looks @ url , interprets query parameters decide mapping. another option use metadata while mapping gives access url , parameters contains.

python - Decode punched tape from image -

Image
is there library decode punched tape image? punched tape this: the dots have different color background. image white rectangle black dots. need locate dots , decode text. desired output example array ("00011", "11001", ...) 1 dot, 0 missing dot. what approach recommend? prefer easy use python's pil or imagemagick or in ruby.

PHP htmlspecialchars encode -

i must mention first of all. im newbie in php, pls understand me. i have difficult form.. <form action="something.php" method="get"> <input type="text" name="something"> <input type="submit" value="send"> in "something.php" have line of code: <?php $something = $_get["something"]; ?> when write in html form, <a href="#">asdqw</a> example, it's show me code... understand me.. im newbie on that, , want learn.. i want encode that, if write characters < , > , $ , ^ etc, , display else, cuz dont want affect me. i want mention, use , database. write in form, saved in database, , showed in page, , in url bar like: " http://some-site.com/page.php?something=something " . hope understand me, , forgive me bad language. im romanian, , dont want use translator. use htmlspecialchars() : $something = ht

sql - How can I get sets of 2 entries where each set starts with a different letter and no letter is repeated from a sqlite database? -

like this: apple aardvark banana bet cow car ... zipper zoo assuming database has more 2 different entries start of letters. thinking of doing top , wildcards, don't know enough sql pull off. can do? you can substr function , correlated subquery: select * yourtable wordfield in (select wordfield yourtable b substr(a.wordfield ,1,1) = substr(b.wordfield ,1,1) order wordfield limit 2) demo: sql fiddle you can use order by adjust 2 records returned. order random() if that's supported.

href syntax in allowing javascript -

i wondering whether injecting javascript href tag text inside possible or not. know can this: <a href="javascript:alert(1)"> now if href value has text like: <a href="hello welcome xxxx site"> within quotes how possible inject javascript? this: <a href="hello welcome xxxx site javascript:alert(2)"> i know start part onmouseover="alert(1)" i'm wondering whether it's possible within href tags in circumstance. use: <a href="javascript:alert('hello welcome xxxx site')"> using javascript: bad form in href. should using null anchor " # " , using onclick instead. a better way is: <a href="#" data-text="hello welcome xxxx site">...</a> ...then using javascript hook event handler , access html5 data element.

internet explorer - Out of Stack Space in IE 10 64-bit. Registry tweak? -

i'm working on gxt application crashes out of stack space error in ie 10 64 bit (because 32 bit ie runs out of addressable memory) while attempting display extremely large data set in tree control. isn't stack overflow; it's hitting memory limit rather recursion limit. i've researched multiple options (including fundamentally re-designing app), memory usage outside our control , haven't been able traction behind better solutions. so, while inevitable suggestions we're doing fundamentally wrong appreciated, acknowledged , welcomed, i'd ask if there ie registry entry can tweaked increase artificial stack space limit seem running into. note system has sufficient ram; i'm running software limit. the default stack size new threads embedded in .exe file (see "size of stack" fields in dump output below). when creating threads, application can specify custom stack size, applications use default specified @ compile time. >link.exe /

visual c++ - Screen shakes when the object moves -

hello im working on project , got problem screen/ground shakes when moved main object. normally when moved "w" button dont problem. if move while im rotating camera got problem. to see: give degree 30 right mouse button.(do not release button) , keep w button while rotating object. see shake @ ground. i think problem looat function calculation. glulookat(sin(rot*pi/180)*(10-fabs(roty)/4) +movex ,3-(roty/2), cos(rot*pi/180)*(10-(fabs(roty)/4)) +movez , -sin(rot*pi/180)*6 + movex, roty, -cos(rot*pi/180)*6 +movez, 0, 1, 0); here rotation function. draw after func. void system::rotater(){ if(mousestates[2][0]==1 && mx!= savex && mx!=mousestates[2][1]){ rot += (mx-mousestates[2][1]) * 90 / glutget(glut_window_width)/2; if(rot>360)rot-=360; if(rot<0)rot= 360+rot; } glrotatef(rot,0,1,0); } and last move option here: if(a==87 || a==119){ movex -= sin(rot*pi/180)/3; movez -= cos(rot*pi/180)/3; } i've found seen scr

jpa - spring data lazy loading -

i use spring data, jpa , hibernate i have advertisement class @entity public class advertisement implements serializable { @id @generatedvalue(strategy = generationtype.auto) private long id; @onetomany(mappedby="id", cascade={cascadetype.remove}, fetch=fetchtype.lazy) private set<message> messages = new hashset<message>(); } and message class @entity public class message implements serializable { @id @generatedvalue(strategy = generationtype.auto) private long id; @manytoone(fetch = fetchtype.lazy) private advertisement advertisement; } when search advertisement id, can see message... don't understand why, put lazy... i search way load advertisement without message. you not loading messages until call it.

.net - Understanding gcroot -

i have been reading article understand gcroot template. understand gcroot provides handles garbage collected heap and the handles not garbage collected. what don't understand following: when clr object moves garbage-collected heap, handle return new address of object. variable not have pinned before assigned gcroot template. does mean clr object deleted garbage collector if there gcroot handle referencing object? what "new address" refers to? , mean "variable not have pinned before assigned gcroot template"? garbage collection doesn't remove unreferenced objects, moves around objects still referenced, e.g. defragment free memory pool. when article talks objects moving in clr heap, it's saying "when garbage collection moves still-referenced object, gcroot handle automatically updated still point clr object." you can prevent gc moving objects around using pin_ptr keyword, so: object ^obj

java - Typing into a JTextField enables a button. Is it wrong to use a KeyListener? -

i have button called "save changes" save changes if changes detected in jtextfield component. now, assume if user types anything, content has changed. i using keylistener, this question sounds using other actionlistener wrong? you can add documentlistener document of jtextfield. actionlistener gets called when used presses enter. advantage of using document listener can detect changes made other means typing.

ruby - In rails removing $ and , from a price field -

i saving price string database in decimal type column. price comes in "$ 123.99" fine because wrote bit of code remove "$ " (the dollar sign , space). seem have forgotten price may include comma. "$ 1,234.99" breaks code. how can remove comma? this code remove dollar sign , space: def price=(price_str) write_attribute(:price, price_str.sub("$ ", "")) # possible code remove comma also? end you can there 2 ways easily. string's delete method removing occurrences of target strings: '$ 1.23'.delete('$ ,') # => "1.23" '$ 123,456.00'.delete('$ ,') # => "123456.00" or, use string's tr method: '$ 1.23'.tr('$, ', '') # => "1.23" '$ 123,456.00'.tr('$ ,', '') # => "123456.00" tr takes string of characters search for, , string of characters used replace them. consider chain of

magento - set values in form fields in edit mode when data comes from multipal tables -

Image
i developing custom module project. created custom form , custom form's data saved in 2 tables. when form open in edit mode not able saved data both tables. have no idea how can resolve issue, please me. here 2 tables structures: table1- ------------------------- id | page_id | title 1 | 3 | abc 2 | 4 | pqrs 3 | 10 | xyz table2- -------------------------------- id | page_id | child | position 1 | 3 | 8 | left 2 | 3 | 7 | right 3 | 3 | 15 | right 4 | 4 | 14 | right 5 | 4 | 15 | left 6 | 10 | 15 | left -------------------------------- here attaching screen-shot more explain myself. want selected saved option values in 'left' & 'right' text-area in edit mode, values comes table2. please suggest me. in advance. left , right here multiselect field types , these kind of fields receives values in comma separated string. example presen

iphone - UIImage from image picker blurry -

i know question has been asked quite few times can't figure out why uiimage still blurry. what i've done: import image uiimagepicker. resized image according code here: http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/ initialised uiimage initwithimage hold uiimage. added subview, made frame cgrectintegral(frame) ensure frame's coordinates integers. despite this, uiimage appears on screen still bit blurry. ideas i'm doing wrong? code: uiimage *gotimage = [info objectforkey:uiimagepickercontrolleroriginalimage]; float scale = (self.view.frame.size.width)/(imagetoresize.size.width); imagetoresize = [imagetoresize resizedimage:cgsizemake(scale * imagetoresize.size.width, scale * imagetoresize.size.height) interpolationquality:kcginterpolationhigh]; uiimageview *background = [[uiimageview alloc] initwithimage:imagetoresize]; background.contentmode = uiviewcontentmodescaleaspectfit; background.frame = cgrectintegral(background.frame

python - How to get a file from curled url -

i have following curl, pass file url: curl -f file=@/users/david542/spreadsheet.xls http://localhost:8000/spreadsheet and in view: @csrf_exempt def wb_spreadsheet(request): # how file?? return httpresponse('hello!') how file object process here? it passed in request.files -- @csrf_exempt def wb_spreadsheet(request): file = request.files.get('file') return httpresponse('hello!')

google apps script - How to use .findElement(DocumentApp.ElementType.TABLE_OF_CONTENTS) to get and parse a Document's Table of Contents Element -

Image
my goal parse tableofcontents element in google document , write one. want every document in folder. having gone bother of converting each document type generated docslist can use method [ document generated documentapp not have. why, don't understand, because otherwise 2 'documents' similar when comes finding parts. ], find searchresult. how elusive construction used? i've tried converting tableofcontents element [ ele = searchresult.astableofcontents() ], not error out, nothing allows me parse through child elements recover text works. interestingly enough, if tableofcontents element parsing through document's paragraphs it, let's parse toc. would speak question. sure appreciate code snippet because i'm getting nowhere, , have put hours this. the astableofcontents() method there editor's autocomplete function. has no run-time impact, , cannot used cast different type. (see containerelement documentation .) to parse table of contents,

visual studio - I can't seem to change the window form text in C# -

i'm using visual studio create program. far, has 1 window button. in form1.designer.cs, initializes window: namespace test { private void initializecomponent() { // took out else, isn't needed. // // formmain // this.autoscaledimensions = new system.drawing.sizef(6f, 13f); this.autoscalemode = system.windows.forms.autoscalemode.font; this.backcolor = system.drawing.systemcolors.controllightlight; this.clientsize = new system.drawing.size(624, 442); this.icon = ((system.drawing.icon)(resources.getobject("$this.icon"))); this.name = "formmain"; this.text = "program name"; this.load += new system.eventhandler(this.formmain_load); this.menubar.resumelayout(false); this.menubar.performlayout(); this.resumelayout(false); this.performlayout(); } } in form1.cs: private void button1_click(object send

c# - How could I convert a value that looks like a double into an unsigned long, but properly? -

i programming in c# , trying convert string containing value seems double , did first convert string double , typecast double unsigned long . problem unsigned long either few digits greater or few digits lower value suppose receiving. after typecast double unsigned long , convert hexadecimal string , pad it. here example of doing: string valuetoparse = "2.53327490880368e+15"; double nvalue1 = double.parse(valuetoparse); ulong nvalue2 = (ulong)nvalue1; string str = nvalue2.tostring("x16"); here results of this: string str = "00090000070ec260"; this problem: right seems if nothing wrong average programmer. what i'm trying do value being returned real result looking 00090000070ec258 - not - 00090000070ec260 , have no clue may causing difference in values. assumption can think of may causing value difference typecasting double unsigned long , within process of value being converted, precision of double messing things up.

android gridview - GridLayout - showing basic info from data in sqlite -

i had description, going direct point editing now, better way: i need select , display 10 attributes sqlite database, string types. questions: 1) need create king of grid, fill listview (baseadapter)? posted pic of result, client expect. thanks ! as per question, assume want display data on activity correct? here link expalins using intent in android application show activity

PHP Session variables not saving between pages? -

login page: <?php session_start(); #echo session_id (); $_session["auth"]= "yes"; echo '<a href="portaltest.php?t='.time().'">portal page link. auth set to: {$_session["auth"]}</a>'; ?> portal page: <?php session_start(); echo "auth = {$_session["auth"] } <br />"; echo session_id (); ?> the auth session lost between 2 pages somehow! edit here test url: http://proserv01.services.lyris.com/nfpinsurance/unsegmentedmemberreport/logintest.php when trouble-shooting sessions, there few things tend do, let's start code. here updated version of page code see value stored in $_session['auth'] (your quotes causing trouble): <?php session_start(); $_session["auth"] = "yes"; echo '<a href="portaltest.php?t='.time().'">portal page link. auth set to: ' . $_session["auth"] . '

HTML Shrinking and expanding table cells -

is possible tell table cell should shrink uses less space possible , on other hand tell specific other cells automatically expand fill remaining space? by default, <td> tags small possible. if want cell remain size when content smaller, can set width of <td> tag this: <td style = "width: 50px;" . cell automatically grow larger when needs to, not shrink below specified size.

python - Drawing a semi-transparent rectangle on a jpeg file with wx.Bitmap -

i need load jpeg->draw semi-transparent rectangle->save jpeg file using wx.bitmap of python wx package. rectangle appears opaque. i'm using windows 7 32bpp. checked , try "docs , demos\demo\alphadrawing.py" wx demo, , works well. draws correctly on wx.panel semi-transparent rectangle. i checked on internet solution problem, none of solutions worked. i created more simple example, minimize possibilities of error, , still didn't work. load jpg->draw semi-transparent rectangle->save jpg file wimg = wx.image(r"n:\images\wallpapers\processed\a.jpg", wx.bitmap_type_jpeg) print wimg.hasalpha() wimg.initalpha() print wimg.hasalpha() bmp = wimg.converttobitmap() print bmp.hasalpha() dc = wx.memorydc(bmp) r, g, b = (34, 34, 34) dc.setpen(wx.pen(wx.colour(r, g, b, wx.alpha_opaque))) dc.setbrush(wx.brush(wx.colour(r, g, b, 128))) dc.drawrectangle(100, 300, 200, 200) bmp.savefile(r"n:\images\wallpapers\processed\b.jpg", wx.bitmap_type_

javascript - Using JS 1.7+ keywords in a blob Worker -

my problem when i'm trying use javascript 1.7+ keywords, let , in web worker, source blob, silently fails. code use is function myworker() { let msg = 'hello'; postmessage(msg); } let blob = new blob( ['(' + myworker + ')();'], {'type': 'text/javascript;version=1.8'} ); let url = url.createobjecturl(blob); let worker = new worker(url); worker.onmessage = function(msg) alert('got message: ' + msg.data); worker.postmessage(null); the same code works fine if replace first let keyword var . there way make firefox (i checked versions 21.0 , last stable 23.0) understand new js1.7+ in blob?

ios - Adding UITexfield to UITableviewCell causes detailTextLabel to slide "up" -

i'm trying add uitextfield contentview of uitableviewcell. works, , field has focus, detailtextlabel slides 10px. what's deal here? secondary question, there better way create in-line edtiable uitableviewcell? here's code. i'm trying result of double tap on tableview cell. retrieve actual cell tapped this: cgpoint swipelocation = [recognizer locationinview:self.tableview]; nsindexpath *swipedindexpath = [self.tableview indexpathforrowatpoint:swipelocation]; uitableviewcell *swipedcell; then try add textfield this: swipedcell = [self.tableview cellforrowatindexpath:swipedindexpath]; nsinteger indent = swipedcell.indentationwidth; uitextfield * newtext = [[uitextfield alloc] initwithframe:cgrectmake(indent, swipedcell.contentview.frame.origin.y, swipedcell.contentview.frame.size.width, swipedcell.contentview.frame.size.height)]; newtext.font = swipedcell.textlabel.font; newtext.text = swipedcell.textlabel.text; n

sql - Optimizing a SELECT with sub SELECT query in Oracle -

select id, (select sum(totalpay) table2 t t.id = a.id , t.transamt > 0 , t.paydt between trunc(sysdate-0-7) , trunc(sysdate-0-1)) pay table1 in spite of having indexes on transamt, paydt , id, cost of sub-query on table2 expensive , requires full table scan. can sub-query optimized in other way? please help. try this: select a.id, pay.totalpay table1 (select t.id, sum(totalpay) totalpay table2 t t.transamt > 0 , t.paydt between trunc(sysdate-0-7) , trunc(sysdate-0-1) group t.id ) pay a.id = pay.id push group joining columns (id column in example) subquery calculate results values in table2 , join table1 table. in original query calculate result every crow table1 table reading full table2 table.

c++ - How to read and write shared_ptr? -

when data use shared_ptr shared number of entries, way read , write data show sharing? example i have data structure struct data { int a; int b; }; data data; data.a = 2; data.b = 2; i can write out in file data.txt as 2 2 and read file, can data values a = 2 , b = 2 . if data uses share_ptr, becomes difficult. example, struct data { shared_ptr<int> a; shared_ptr<int> b; }; data data; data can data.a.reset(new int(2)); data.b = data.a; or data.a.reset(new int(2)); data.b.reset(new int(2)); the 2 cases different. how write data data.txt file , read file data, can same data same relations of a , b ? this kind of data serialization problem. here, want serialize data has pointer types within it. when serialize pointer values, data pointing written somewhere, , pointers converted offsets file data. in case, can think of int values being written out right after object, , "pointer" values represented number o

c# - Join Extension Method -

i having trouble figuring out how simple left join using linq in extension method. i need use extension method opposed comprehension query paging results. var carparkpagedlist = db.carpark .join(db.userprofiles, cp => cp.userprofileid, => up.userid, (cp, up)) .orderby(f => f.name) .where(f => f.floorid == floorid) .select(f => new carparklistdisplaymodel { carparkid = f.carparkid, name = f.name }).topagedlist(page, 10); i cannot find on anywhere, have tried 101 linq examples , find comprehension queries won't provide support extension methods. ok simon, approach worked , use on, more logical. var carparkpagedlist = (from cp in db.carpark cp.floorid == floorid join occupant in db.userprofiles on cp.userprofileid equals occupant.userid gj occupant in gj.defaultifempty() orderby cp.name select new carparklistdisplaymodel { carparkid = cp.carparkid, name = cp.name, usersname = (occupant == null ? "un-ocupied" : occupant.

Perform math on dynamically updating javascript Value -

i have figured out how update html dynamically based on current input of form. however, stumped how perform math on value (ie value*5), , display result, instead of merely displaying value in form. here live example: https://dl.dropboxusercontent.com/u/14749627/happy2/number.html here javascript: <script> window.onload = function() { var purchase_quantity = document.getelementbyid('purchase_quantity'); purchase_quantity.onclick = updatenamedisplay; purchase_quantity.onclick = updatenamedisplay; purchase_quantity.onclick = updatenamedisplay; function updatenamedisplay() { document.getelementbyid('namedisplay').innerhtml = this.value || "1"; } }; </script> campari's solution works, should convert number explicitly habit. if tried add instead , wouldn't work expected. also, oriol pointing out other problem. var purchase_quantity = document.getelementbyid('purchase_quantity'); purchase_quantity.onclick = updat

iOS, Facebook app posting only by ME -

am missing something. i'm creating app user able take picture, edit , post facebook. have created app on developers.facebook.com, inserted keys ios app. can login , post image on profile, no problems @ all. says nicely "few minutes ago via --my app--" , works perfectly. i'm posting using: nsmutabledictionary* params = [[nsmutabledictionary alloc] init]; [params setobject:message forkey:@"message"]; [params setobject:uiimagepngrepresentation(image) forkey:@"picture"]; //disable button [fbrequestconnection startwithgraphpath:@"me/photos" parameters:params httpmethod:@"post" completionhandler:^(fbrequestconnection *connection, id result, nserror *error) { if (error) { //showing alert failure [self showalert:@"facebook unable sha

python - dev_appserver.py no such file or directory -

i trying enable sending email in development. need run server. in directory called 'trade' application located.(see pwd , ls) kenzos-macbook-pro:trade kenzotakahashi$ pwd /users/kenzotakahashi/desktop/main/webdevelopment/project/trade kenzos-macbook-pro:trade kenzotakahashi$ ls app.yaml main.pyc model.pyc util.py main.py model.py templates util.pyc but got error. kenzos-macbook-pro:trade kenzotakahashi$ dev_appserver.py trade traceback (most recent call last): file "/usr/local/bin/dev_appserver.py", line 184, in <module> _run_file(__file__, globals()) file "/usr/local/bin/dev_appserver.py", line 180, in _run_file execfile(script_path, globals_) file "/users/kenzotakahashi/desktop/main/webdevelopment/googleappenginelauncher.app/contents/resources/googleappengine-default.bundle/contents/resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 727, in <module> main

php - How can I import the sample xml data into my Wordpress site? -

Image
i have premium wordpress theme sample data in xml format. i've installed theme cannot import xml data can see how theme works. can please give me idea how xml data can imported wordpress? thanks in advance help. go wp-admin->tool->import->wordpress on click -> install importer plugin import xml. http://wordpress.org/plugins/wordpress-importer/

solr tagging & excluding filters for range facets -

i'm creating uneven range facet , want support multiple selection it. however, facet on tags/exclusions filters stop working. following price facet ranges 0-20 20-50 50-100 100-* populating above range using facet query. whenever end user selecting 0-20 , 20-50, generating following http://localhost:8983/solr/catalog/select?q=games&facet=true&wt=xml&rows=0& fq={!tag=saleprice}saleprice:[0 20]&facet.query={!ex=saleprice}[0 20]& fq={!ex=saleprice}saleprice:[20 50]&facet.query={!ex=saleprice}[20 50]& other params. & system returning 0 results. i seeing following solr jira bug closed fixed. https://issues.apache.org/jira/browse/solr-3819 however, in case,only 1 facet.query in action. in example, using multiple facet.query uneven ranges. please help. your query has 2 fq clauses don't overlap. why 0 results — nothing facets or tags themselves. multi selection need combine them "or". instead of

c# - Coldfusion - How to update Table Cells in Real time? -

i relatively new coldfusion (using coldfusion 10) , have question regarding creating real-time updated table. currently have c# application have writing stock prices csv (text) file every 2 seconds , reflect these changes happen in table on web page. know have entire table refresh every 2 seconds, generate lot of requests server , know if there better way of doing ? achieved using coldfusion 10's new html5 web-sockets functionality ? any advice/guidance on way proceed or how achieve appreciated ! thanks, alanjames. i think rewrite question , @ least 5 answers in first hour. now answer it, if understood you're asking. imho websockets aren't there yet, if website wide population , not 100% sure they're coming recent chrome or ff, forget it. you use javascript websocket library gracefully fallback flash or ajax http polling, http://socket.io/ or cloud service pusher.com . complicate life because have 2-3 times more work in backend if implement pol

java - Get Value out of Try/Catch exception? -

i'm try create simple android application currency exchange , got stuck when got try , catch. wanna value of rate inside try , catch , use it, im unable figure out how possible or if possible. appreciated. string exchange = "http://rate-exchange.appspot.com/currency?from=" + + "&to=" + + "&q=1"; double rate = 0; jsonobject json; try { json = readjsonfromurl(exchange); for(int = 0; < json.length(); ++) rate = json.getdouble("v"); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (jsonexception e) { // todo auto-generated catch block e.printstacktrace(); } total.settext(string.valueof(rate*amount)); double rate = 0; // initialize rate jsonobject json; try { // rate

perl - Multiply each element of an array to each other -

i have array of float numbers: (.25, .45, .15, .27). multiply each element each other divide number of array elements. foreach $element (@array) { $score = $score * $element; } $score = $score/$numofelements; this produces value 0. not sure if syntax correct. your syntax correct, initializing $score variable each time through loop, sets 0 each iteration. move outside loop , should work: my $score = 1 #need initialize 1 multiplying foreach $element (@array) { $score *= $element; } $score = $score/$numofelements; #assuming $numofelements set

c# - Make div look like ListBox -

i have div contains table. need somehow change style , make ordinary listbox. possible or can make several border changes? (if so, how can view listbox standart style?) <div id="div1" runat="server"> <table> <tr><td>...</td></tr> <tr><td>...</td></tr> ... </table> </div> by words: listbox have specific border. want make div border looks listbox border. css code have custom borders td { border-top:1px solid black; border-botton:1px solid black; } the above code add border in top , bottom, if expected

javascript - Random timing for Opacity + Random movement -

i'm trying create random movement of div (successful), tied random opacity changes (partially successful). i've put following mashing 2 separate scripts one. the opacity changes after each movement of div. i'd opacity work independent of movement. appreciated! i have in jsfiddle here , or: html: <div id="container"> <div class="a"></div> </div> css: div#container {height:500px;width:100%;} div.a { width: 284px; height:129px; background:url(http://www.themasterbetas.com/wp-content/uploads/2013/08/aliens.png); position:fixed; } jquery: $(document).ready(function() { animatediv(); runit(); }); function makenewposition($container) { // viewport dimensions (remove dimension of div) $container = ($container || $(window)); var h = $container.height() - 50; var w = $container.width() - 50; var nh = math.floor(math.random() * h); var nw = math.floor(math.random() * w);

Knowing length of input argument of a function in python -

let's have function: def func(x, p): return p[0] * x ** 2 + p[1] * x + p[2] and now, can information function using inspect: import inspect args, varargs, varkw, defaults = inspect.getargspec(func) but know have 2 arguments, instead of information on each argument (whether it's scalar or else). just making sure - theoretically, there way can know minimum length of tuple p used in function? thank you! the answer no. firstly can't assume type (let alone size of argument). secondly, there no way tell length, because it's supposed arbitrary , function may nothing input @ all. if want similar, try use *l variable-length arguments. there **d arbitrary map (named arguments).

looking for best way of giving command line arguments in python, where some params are req for some option and some params are req for other options -

hi trying send command line arguments first time. condition 1 parameter required 1 option , others other parameter.(looking user friendly). below code looks need optimization: import argparse parser = argparse.argumentparser(description='usage options.') parser.add_argument('-o','--options',help='options available: run,rerun,kill, resume, suspend',required=true) parser.add_argument('-c', '--config',help='config file input',type=file,required=false) parser.add_argument('-j', '--id',help='id of job',type=str,required=false) args = parser.parse_args() action_arg = list() action_arg.append(args.options) action = {'run': start_run, 'rerun': start_rerun, 'kill': kill_job, 'resume': resume_job, 'suspend': suspend_job, 'get_run': get_run, 'get_component': get_component, '

System Verilog Function return value as parameterized bit vector -

i need create function in system verilog return value parameterized bit vector. code follows: class my_class #(parameter addr_width = 32); bit [addr_width-1:0] address; function bit [addr_width-1:0] get_address(); return address; endfunction : get_address endclass : my_class i compile time error in function declaration saying parameter addr_width not defined. can please explain why happening? same working without parameter (i.e if have known value bit [31:0]) there nothing wrong code showed in original example, , i've tried on earlier versions of questa. when unexplainable errors on code looks fine, either using version old, or real error on line above the code in question.

jquery - How to use putting validation message underneath a control using backbone validation -

Image
i using backbone.validation.js i able implement shown in demo here so, able show error messages next field. want able show these message underneath controls. i checked html generated these messages, reads <span class="help-inline error-message"> please provide first name </span> i tried doing through css, gets little messy. wanted know if there provision may have missed. please advice. you should try remove help-inline class. according documentation help-inline class feature: you may use <input .... data-error-style="inline"> in form force rendering of <span class="help-inline"> so have remove/change data-error-style attribute.

Why do I need to use these nasty comments in C# / .Net code? -

i'm building application , 1 of requirements use comments one: /// <summary> /// creates new client. /// </summary> /// <param name="uri">the uri.</param> /// <param name="param">the param.</param> /// <returns></returns> i understand it's easy various kind of tools generate docs based on these xmls. decreases code readability, , that's we, humans, trying achieve. could approach replaced other technique in .net? , what's better way improve code readability , cleanness? that information should pop on visual studio when uses intellisense while going through methods. save time since whoever using code not need go code (thus meaning not need expose of code) , see other comments have written. i think documentation, when kept short , point, never bad thing , not affect code readability.

security - TYPO3 naw_securedl in email -

i have installed naw_securedl , works correctly. need send links files via emails. have stored emails pages in backend , when show page links correctly translated naw_securedl . if send email links in normal way. is there possibility translated in email? typo3 version 4.7 naw_securedl version 1.7.1 nav_securedl works hooking page rendering process. if not render page done frontend, need call hook yourself.

node.js - changing time format in node js -

here fetching date stored in database in format(2013-08-17 07:50:21), getting below output, need date in format 17 august 2013 without using third party module. possible? if yes suggest solution. var sql2 ="select `user_id`, `vote_date` `tb_post_votes` `post_id`=?"; connection.query(sql2,[postid],function(err, result) { var post={"user_id":result[0].user_id,"date":result[0].vote_date}); res.send(json.stringify(post)); }); output: {"user_id":11,"date":"2013-08-17t07:50:21.000z"} javascript / nodejs not give format method date objects. can date, month , year provided native methods... getyear() - gives year count 1990 113 2013 getfullyear() - gives full year 2013 getmonth() - gives month number 0 based index getdate() - gives date of month also new date() takes date in different formats , convert local date/time 1 of utc date format. if node server @ utc

javascript - take screenshot on web page with flash element -

i take screenshot of page displayed in webview. page may contains flash elements , refer google feedback , when take screenshot flash parts of page blank. the flash element(for example video) can not controlled because not own website. beside not want use extension of browser . it's impossible take screenshot of flash elements on webpage using javascript embedded on same page. available js solutions ( more details here ) reading current dom state , rendering (using js render engine implementation) web page on canvas element. flash object executed separate application - flash player. js can't access contents, there no flash render engine implementation in js. however, since mentioned webview , talking flash assume working on native android app. therefore, should easy native app create screenshot ( see this ).

android - Using GridView inside View Pager Fragment -

how can refresh gridview inside fragment of view pager? i have tried using adapter.notifydatasetchanged() , that's not working . i want delete elements gridview , refresh grid view. i removing elements arraylist , gridview.getcount() shows decreased values shows deleted values in grid view , how can update/refresh gridview ? the layout of fragement dynamically created no fragemt tag findfragement id. ok while scrolling fragment grid view repopulate grid inside viewpager on pagechangelistener

json - Simple BPM or Workflow in Javascript -

i have requirement route between different pages in mobile app (hybrid) based on output 1 page. routing should configurable, able updated independently of app , ideally able edited visually. server-side handled bpm solutions (jbpm, ibm bpm, etc), on client-side can't find suitable. what need json based set of rules define page route if set of conditions met. example, if on page1 have 2 fields: name , age , user clicks next rules might define if age >= 21 route page2, if age < 21 route page3. is there technology out there this? i've seen there javscript rules engines such nools , aren't bpm-like enough. please don't suggest writing myself - that's being considered. bpm isn't designed "page flow". include sort of page flow technology own uis, don't know of promote feature building uis in other technologies. fundamentally, looking mvc framework. have pages (views) , assumably have model already, looking controller link t

c# - Enum item mapped to another value -

i have enum: enum myenum{ aaaval1, aaaval2, aaaval3, } i need have abbreviated version of 'myenum' maps every item 'myenum' different values. current approach method translates every item: string translate(myenum myenum) { string result = ""; switch ((int)myenum) { 0: result = "abc"; 1: result = "dft"; default: result = "fsdfds" } return result; } the problem approach every time programmer changes myenum should change translate method. this not way of programming. so.. is there more elegant solution problem? thank :-) four options: decorate enum values attributes, e.g. enum myenum { [description("abc")] aaaval1, [description("dft")] aaaval2, aaaval3, } then can create mapping (like dictionary solution below) via reflection. keep switch statement switch on enum value instead of number bet

hmvc - FuelPHP - Building a page in blocks -

what best way build page in fuelphp each of blocks of page built on own modules , output html put in layout. the best have found far hmvc below. $block1= request::forge('mycontroller/block1')->execute(); $block2= request::forge('mycontroller/block2')->execute(); $data['block1'] =$block1; $data['block2'] = $block2; //assign view browser output return view::forge('home/index', $data); however loading whole framework calls seems rather inefficient (and possibly slow result) . there better way this? if you're using modules (instead of calling different action in same controller seem here), requests absolutely way go. , since requests use routing table, can control controller/action called manipulating routes. setting new request isn't complex, additional delay few milliseconds tops. for completeness, way perform hmvc request: try { $result = \request::forge('your/uri/here')->execute()->respon

UIBezierPath and gradient iOS -

Image
i have path values , want make gradient. here code: cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsetstrokecolorwithcolor(context, [[uicolor colorwithred:245.0/255.0 green:245.0/255.0 blue:171.0/255.0 alpha:0.6] cgcolor]); cgcontextsetfillcolorwithcolor(context, [[uicolor colorwithred:245.0/255.0 green:245.0/255.0 blue:171.0/255.0 alpha:0.6] cgcolor]); uibezierpath *apath = [uibezierpath bezierpath]; [apath movetopoint:cgpointmake(30.0, 100.0)]; [apath addlinetopoint:cgpointmake(200.0, 120.0)]; [apath addlinetopoint:cgpointmake(300, 210)]; [apath addlinetopoint:cgpointmake(300, 420)]; [apath addlinetopoint:cgpointmake(30, 420.0)]; [apath addlinetopoint:cgpointmake(30, 100.0)]; [apath closepath]; [apath fill]; any pointers figure out issue code? first - i've created simple arrow bezier path: uibezierpath* bezierpath = [uibezierpath bezierpath]; [bezierpath movetopoint: cgpointmake(24.5, 1.5)

Stop logging downloads from repository on Maven -

is there way remove redundant output lines informs every small download maven made repository. want see output of actual plugins. is there plugin in charge of output can configure? thanks! i dont think can achieve changing maven settings. options knw mvn -q hides [info] lines , mvn -x shows debug messages. you should save log messages in file ans use unix grep command filter messages want.

sql - How to configure jooq-sbt-plugin -

i'm relatively new sbt. i'd include jooq-sbt-plugin ( github ) in sbt config. i'm using build.scala handle multiple projects , i'd include jooq-sbt-plugin config there couldn't figure out put it. import sbt._ import keys._ object samplebuild extends build { lazy val = project(id = "all", base = file("."), settings = defaultsettings) aggregate( one, 2 ) lazy val 1 = project( id = "one", base = file("one"), settings = defaultsettings ++ seq( librarydependencies ++= dependencies.one ) ) lazy val 2 = project( id = "two", base = file("two"), settings = defaultsettings ++ seq( librarydependencies ++= dependencies.two ) ) dependson (one) override lazy val settings = super.settings ++ buildsettings lazy val buildsettings = seq( organization := "org.sample",

How to release submodules with different version numbers with Maven? -

in current maven project have lot of submodules. need build release , deploy nexus... now facing challange need of modules differing version numbers. how can handle usage of release & deploy plugin? or need other maven plugins??? configured release plugin inside parant pom. there possibility disable example "autoversionsubmodules" of submodules? ideas??? if have multi-module build modules should have same version number otherwise it's indicator multi-module build not right choice.

javascript - How can I change arrow direction on Facebook comment window -

Image
i'm using facebook api button. after pressing "like" appears comment window. as can see appears under button. can change it? need above button? possible? no. facebook button mark-up , styles provided facebook’s servers, have no control on them. protect “look” , brand, it’s consistent no matter website placed on.

sql - how to work duplicate values delete from query -

this query.... delete second_salary a.rowid > ( select b.rowid second_salary b a.salary = b.salary) can 1 explain query? sql 1: delete second_salary a.rowid > ( sql 2 ) browse each record in table second_salary , if record have rowid > value in array result of sql 2 delete it. sql 2: (with a.salary number knew form record reviewed, example n) select b.rowid second_salary b a.salary = b.salary result return: array rowid of records have n = b.salary end: retain record have smalless rowid in records have salary simalar.

mysql - HTTP Status 500 - Internal Server Error -

i trying develop simple web application netbeans , mysql. have data in mysql , want show them in web browser. following error in web page when running project. type exception report messageinternal server error descriptionthe server encountered internal error prevented fulfilling request. exception javax.servlet.servletexception: select subject_id, name subject : table/view 'subject' not exist. root cause java.sql.sqlsyntaxerrorexception: table/view 'subject' not exist. root cause org.apache.derby.client.am.sqlexception: table/view 'subject' not exist. note full stack traces of exception , root causes available in glassfish server open source edition 4.0 logs. try making table name uppercase. select subject_id, name subject please have @ following post describing identifier case sensitivity