Posts

Showing posts from September, 2013

javascript - Auto click button script for tampermonkey? -

am trying create user script click following button possible on loadiing page. <button class="btn" tabindex="10" disabled="disabled" onclick="validateandsubmit('1')" title="" pay-tab="1">do now</*button> please trying long time failing so. i tried this: <script type="text/javascript"> settimeout(function() { document.getelementbyid("btn").click(); },1000); </script> try this (function() { window.addeventlistener('load', validateandsubmit('1'), false); })(); (function() {})() defines scope self executed without waiting events. window.addeventlistener('load', validateandsubmit('1'), false); subscribes function validateandsubmit window load event function executed on load. same function trying execute clicking button.

uiscrollview - Anyone know how to use CCScrollView(vertical scrolling) and CCMenu together in cocos2d? -

anyone know how use ccscrollview(vertical scrolling) , ccmenu in cocos2d?also can use ccscrolllayer instead of ccscrollview or on better use in cocos2d? in advance vontio has posted solution in cocos2dx here

javascript - I can't get my todo list to work right -

for reason can't todo list work. first, have global variable named "list" stores: document.getelementbyid('glist'); "glist" id of ordered list element have. then, have textarea id named "goal" , function called addgoal() . see below, first thing function value of textarea id named "goal" , stores variable named "goal". variable created called "entry" stores created li element var entry = document.createelement('li'); variable "entry" given attributes using entry.setattribute . it's given class , class name "mylist". happens code below is, type in text textarea, text added list , fine until try add item list. once add item, replaces first item , adds additional li elements containing same replacing text. appreciate help. this last part of function adds text typed in textarea ordered list , li element class "mylist". entry.appendchild(document.createtextnode(goal))

unix - How do I perform a portable, readable and pipeable character-by-character diff from the command line? -

the standard diff tool useful find lines in file differ, doesn't work character-by-character differences. need merge texts character-by-character (i.e. written text, not code) modified without synchronization on different computers (yes, know shouldn't, happens anyway). apart adding paragraph or two, might have altered comma, spelling mistake or other small change in text common both files. diff tell me lines changed, since there might multiple diffs per line, must scan lines find each physically small important diff per line. after fixing, must repeat diff make sure didn't miss edits. gets worse when lines paragraph formatted (i.e. 1 line per paragraph), , when many consecutive lines have such small differences. right must admit load both files microsoft word , use built-in diff function. of course inconvenient start huge package word find small differences, @ least compares files on character-by-character basis. what want unix way of doing this. small , cute too

Android error: java.lang.Throwable: EventHub.removeMessages(int what = 107) is not supported before the WebViewCore -

i have error logging happening in background: 10-06 14:05:47.787: w/webcore(554): java.lang.throwable: eventhub.removemessages(int = 107) not supported before webviewcore set up. 10-06 14:05:47.787: w/webcore(554): @ android.webkit.webviewcore$eventhub.removemessages(webviewcore.java:1683) 10-06 14:05:47.787: w/webcore(554): @ android.webkit.webviewcore$eventhub.access$7900(webviewcore.java:926) 10-06 14:05:47.787: w/webcore(554): @ android.webkit.webviewcore.removemessages(webviewcore.java:1795) 10-06 14:05:47.787: w/webcore(554): @ android.webkit.webview.sendourvisiblerect(webview.java:2917) 10-06 14:05:47.787: w/webcore(554): @ android.webkit.zoommanager.setzoomscale(zoommanager.java:593) 10-06 14:05:47.787: w/webcore(554): @ android.webkit.zoommanager.access$1700(zoommanager.java:49) 10-06 14:05:47.787: w/webcore(554): @ android.webkit.zoommanager$postscale.run(zoommanager.java:984) 10-06 14:05:47.787: w/webcore(554): @ android.os.handler.handl

ruby on rails - Issue with configuring active admin -

try install active admin , encounter error "invalid route name, in use: 'admin_root'" after research stackoverflow . found answers ,trying apply them case it's not working . here's routes.rb. im confused routes should delete fix prob.i don't have admin routes . it's little confusing. devise_for :admin_users, activeadmin::devise.config activeadmin.routes(self) resources :activities, only: [:index, :destroy] "relationships/create" "relationships/destroy" "users/show" # can have root of site routed "root" root 'videos#index' 'home', :to => "pages#home", :as => :home 'login', :to => "pages#login", :as => :login 'about', :to => "pages#about", :as => :about 'browse', :to => "pages#browse", :as => :browse 'recent', :to => "videos#recent", :as =>

jquery - Check if selector is defined -

i have following plot function: function plot(selector, data) { var context = selector.get(0).getcontext("2d"); var wrapper = $(selector).parent(); } and on javascript main file have following: plot($('#pageviews'), data); in pages not pageviews item error: typeerror: selector.get(...) undefined how can check, inside plot function, if selector defined? and if undefined exit plot function. thank you, miguel you can use .length check selector exists or not: if (selector.length > 0){ // here }

ruby - How so I translate a MySQL statment to a numerical value? -

i fetching data external database, , feeding dashing widget. when numerical data returned widget, looks like: mysql::result:0x21a25 i need data decimal number. here code fetching data , feeding widget: require 'mysql2' scheduler.every '1m', :first_in => 0 |job| # mysql connection db = mysql2::client.new(:host => "some ip", :username => "user", :password => "password", :port => 3306, :database => "database_name" ) # mysql query sql = "select count(*) out_sms type = 'standard_sms' " # execute query results = db.query(sql) # update man hours saved e widget send_event('manhourse', { current: results } ) end the mysql2::client#query method return mysql2::result object, ruby enumerable . means can iterate via lots of different means array or hash ( results.each {} example), or use enumerable methods .first or .last on it. your query, havin

c# - Webpage not rendering the same way in WebBrowser control, works fine in Mobile IE -

i got strange issue. i'm using webbrowser control in app facebook connect. i'm not using facebook sdk because doesn't suit needs. here issue : inside webbrowser control in app, elements (ie text, images , select list) doesn't show/work ! though work fine mobile ie (same url etc...). i tried use exact same user agent mobile ie use, no change. any idea of why difference ? thanks here pictures : from ie : http://i.stack.imgur.com/fm6ku.png from app : http://i.stack.imgur.com/egnni.png here code (pretty standard) : void browser_loaded(object sender, routedeventargs e) { (sender webbrowser).navigate(new uri("http://m.facebook.com/dialog/oauth?client_id=id&redirect_uri=redirect&scope=publish_stream,offline_access,publish_actions"), null, "user-agent: mozilla 5.0 (compatible; msie 9.5; windows phone 8.0; trident/6.0; iemobile/9.5; arm; touch; nokia; lumia 725)"); } the user-agent header has same value mobile ie, it&#

javascript - Are client side cookies accessible by all and are there cookies on the server side -

if have sitea writing cookie browser, can siteb write code access cookie or cookies hidden websites didn't create them ? my answer yes, siteb can read document.cookie , if knows what's cookie name, can access it. right ? regarding second questions, don't think there server side cookies other sessions. right? cookies usable both server , client. cookies can read website domain creates them; can use sub-domains domains, url paths. cookies considered insecure if used client side, , should not used hold sensitive data if accessed client side. server can encrypt information , store in cookie long encryption done on safe manner on server. using cookies way of avoiding use of session server, , if not save sensitive data way store state in web application. although can more challenging other session mechanisms, work on both client , server. advertising products double click use cookies track monitor user activity, how ads follow site site. third-party , first-p

coffeescript - Why setInterval (->...) ,0 won't run as I expected? -

from coffeescript accelerated javascript development , chapter 6.6, question: count = 10 h = setinterval (-> count--),100 (->) until count 0 clearinterval h console.log 'suprise!' count won't 0,i try change 100 0,result same. stack setinterval in? when callback function (-> count--) run? javascript strictly single-threaded. asynchronous callbacks run after code finishes running. your infinite loop never finishes running, setinterval callback never runs.

android - U-boot: Dual Boot + Dummy Kernel + Modified Splash Image -

i want integrate dual boot feature u-boot. during execution of spl, u-boot.img gets authenticated. if authenticated correctly, android ics started. if not, dummy kernel shall started, nothing more showing error message (maybe boot logo). thus, have 3 challenges: i need pass u-boot.img different parameters, boot different kernel images based on authentication process. i need integrate kind of dummy kernel, nothing displaying boot screen. i need modify boot screen own version. i know how perform last step, since boot screen seems zip file, needs replaces. however, give me hints regarding first , second task? thanks, p i think mean authenticate kernel. correct? if want that, u-boot has capability. can of in script either boot authenticated kernel or display splash screen. for splash screen, there several ways it. 1 way use u-boot command, depending on version, display bitmap stored in flash or on sd card. other way require convert bitmap header file , rebuild u-

google chrome app - Can't use the window.api properly -

i trying create borderless chrome app custom "control panel" closing/minimizing/maximizing. i have 3 divs ( #minimize , #maximize , #close ) act buttons. trying handle clicks javascript obviously. have main.js included in html header has code want. closing window code looks this: document.queryselector('#close').onclick = function() { window.close(); } that works charm. as maximizing window tried: document.queryselector('#maximize').onclick = function() { window.maximize(); } which not work. did work was: document.queryselector('#maximize').onclick = function() { window.moveto(0,0) window.resizeto(screen.width,screen.height); } i guess missing obvious. window.hide() not work , impossible call other appwindow functions such getbounds . know doing wrong here? the window object trying manipulate not chrome's appwindow. use chrome.app.window.current().maximize() etc.

python - Using Counter with list of lists -

how use counter in collections library convert list of lists count of number of times each word occurs overall? e.g. [['a','b','a','c'], ['a','b','c','d']] -> {a:2, b:2, c:2, d:1} i.e. a , b , c occur in both lists d occurs in 1 list. using generator expression set : >>> collections import counter >>> seq = [['a','b','a','c'], ['a','b','c','d']] >>> counter(x xs in seq x in set(xs)) counter({'a': 2, 'c': 2, 'b': 2, 'd': 1}) responding comment, without generator expression : >>> c = counter() >>> xs in seq: ... x in set(xs): ... c[x] += 1 ... >>> c counter({'a': 2, 'c': 2, 'b': 2, 'd': 1})

c++ - QWebView not printing multiple pages on real printer? -

well i'm trying print qwebview multiple pages, using css page-break attribute, works fine webkit. i'm using qt 5.1.1. my main problem fine when i'm printing pdf using qt, when i'm trying print real printer, pages first 1 blank! here (stripped) test's code : test.h : class mainwindow : public qmainwindow, private ui::mainwindow { q_object public: explicit mainwindow(qwidget *parent = 0); public slots: void printhtml(); void printpreview(qprinter *printer); private: qwebview webview; }; test.cpp : #include "test.h" mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent) { qstring html; html= "<!doctype html><html> <head> <meta http-equiv='content-type' content='text/html;charset=utf-8' /> <title>paginated html</title> <style type='text/css' media='print'> div.page { page-break-after: always; page-b

Oracle SQL Upating a not null column with an empty string -

i having issue writing sql update statement, need update not null field empty string. update channel_mgmt.channels set registered_address_id=p_address_id ,vendor_id=p_spc_code id=v_channel_id; in case, p_spc_code, can set '', , running sql error when run this: error report: ora-01407: cannot update ("channel_mgmt"."channels"."vendor_id") null ora-06512: @ line 8973 01407. 00000 - "cannot update (%s) null" *cause: *action: any ideas how can around this? need use empty string cases, unsure why oracle complaining null value. desc channel_mgmt.channels name null type --------------------- -------- ------------------ id not null number(16) channel_status_key not null varchar2(64 char) registered_address_id not null number(16) vendor_id not null varchar2(64 char) have tried using ' ' (string 1 space

Custom InputView for UISearchBar doesn't work after tap cancel button in iOS7 -

in ios app , need set custom inputview uisearchbar in ios7 . so wrote following codes. nsarray *searchbarsubviews = [[self.sbar.subviews objectatindex:0] subviews]; for(int =0; i<[searchbarsubviews count]; i++) { if([[searchbarsubviews objectatindex:i] iskindofclass:[uitextfield class]]) { uitextfield* search=(uitextfield*)[searchbarsubviews objectatindex:i]; [search setfont:[uifont fontwithname:@"customfont" size:15]]; search.delegate = self; [search setinputview:self.customkeyboard]; [self.customkeyboard settextview:search]; } } it working fine. when type custom keyboard , tap cancel button resignfirstresponder . and tap uisearchbar again, can't type text in uisearchbar , including native english keyboard. and cancel button hiding , uisearchbar not working anymore. i don't

ios - Is there/what is a UIImagePicker allowsEditing equivalent for Windows Phone SDK? -

Image
at moment, in process of trying convert ios app on windows phone 8, however, in ios app, used uiimagepicker's allowsediting method happens in image below. in image below, user can resize picture have selected can use part of picture selected in app, while picture select gets cropped square app use too. my question is, making app using windows phone 8 sdk, there simple method same functionality, or have program functionality in myself? thank much. jon. you should use photochoosertask pixelheight , pixelwidth properties: photochooser.pixelheight = 612; photochooser.pixelwidth = 612;

java - Why Iterator<E> iterator() is put in Collection, AbstractCollection when already in Iterable -

this question has answer here: why there method iterator() on java.util.collection 4 answers when iterator iterator() put in iterable interface , extended collection interface , abstractcollection interface, why again mentioned in collection / abstractcollection no definition given in abstract class. please me understand missing in design perspective the iterator() appears in iterator , collection javadoc different. in abstractcollection different again, doesn't appear add value.

ios - Showing a UIProgressView inside or on top of a UINavigationController's UINavigationBar -

Image
i want have uiprogressview show progress on bottom of navigation bar (just when sending imessage or text message in ios 7). need consistently on every table view view of navigation controller. me clear: have add uinavigationcontroller. problem is, it's not possible add uiprogressview uinavigationcontroller. tried out 2 things: 1st tried add uinavigationcontroller's view programmatically. problem position uiprogressview , make when changing device rotation. the 2nd thing tried add uiprogressview every uitableview, have every view. doesn't good, because not on top of navigation bar beneath it. main reason why didn't 2nd solution because progressviews go , come tableview, don't have static 1 changing ones. after this, don't have idea this, ask you… have idea how this? that's how should like: i found solution: i made custom uinavigationcontroller , added viewdidload - (void)viewdidload { [super viewdidload]; // additional setup a

Making ontology in Protege or by Jena API library in Eclipse(Java coding) -

is possible build ontology jena api example java coding in eclipse? if yes difference between making ontology in protege making ontology jena api in eclipse?i confused differences not in java programming. lots of thanks it depends on want do. trying build new ontology scratch? have existing ontology want extend adding data. generating lots of triples using pre-existing classes , properties, based on data you're processing in java? protege offers gui allows create ontology more quickly. gives graphical overview of ontology in creation. it's hard big picture help. it's powerful tool overall ontology authoring. writing entire ontology scribbling java code line-by line seems gruelling task me. writing plain java code create onthology difficult , inefficient. on top of complexity of rdf itself, you'd need understand jena api. imo, makes sense if have well-defined ontology , you're sure kind of triples want add. in such case, using java code interface dat

list - How to write a “set-equal?” predicate? -

how build same? predicate returns #t (same? '(4 6) '(6 4)) ? i'm stuck writing (same? b) -predicate returns #t if a , b equal sets , #f otherwise. similar predicate (element? el set) determines if el element of set . (and yes, homework i'm not after finished solution. need bump or few, in right direction since there's no found our teachers.) we representing sets using lists. asked build need our selves. higher order functions map etc pretty banned. the problem is element? , same? doesn't work with: (same? '(4 6) '(6 4))<br/> (element? '(2 3) '(1 8 5 '(3 2) 4)) these should return #t , don't , understand why still can't fix it. my element? looks this, , kind of knew work lists of same order question how can improve it? ( setempty , setfirst , setrest defined null? , car , cdr . we've been asked make our own reason.) (define element? (lambda (x set) (cond ((setempty? set) #f) ((equal?

c# - Having trouble connecting to wcf service on localhost from Android emulator -

i'm building app xamarin studio that's supposed access wcf service. accessing service works fine browser following url: http://localhost:52277/api whenever try access android code, following exception: system.net.webexception: error: connectfailure (connection refused) ---> system.exception: connection refused @ system.net.sockets.socket.connect (system.net.endpoint remoteep) [0x00000] in <filename unknown>:0 @ system.net.webconnection.connect (system.net.httpwebrequest request) [0x00000] in <filename unknown>:0 --- end of inner exception stack trace --- @ system.net.httpwebrequest.endgetresponse (iasyncresult asyncresult) [0x00000] in <filename unknown>:0 @ system.net.httpwebrequest.getresponse () [0x00000] in <filename unknown>:0 @ servicestack.serviceclient.web.serviceclientbase.send[string] (system.string httpmethod, system.string relativeorabsoluteurl, system.object request) [0x00051] in c:\users\nicklas.winger\documents\githu

database - How to remove duplicate rows keeping other unique rows alive? -

this question has answer here: sql delete duplicates in table 3 answers below records table contains. want remove duplicate rows , result must contain rows having ids 50, 10, 20, 30, 40. thanks 50 engineering pune 50 engineering pune 50 engineering pune 50 engineering pune 50 engineering pune 50 engineering pune 50 engineering pune 50 engineering pune 50 engineering pune 10 accounting new york 20 research dallas 30 sales chicago 40 operations boston the different thing between same rows in oracle rows got unique rowid there can use min or max of rowid group columns query this: delete tablename rowid not in (select max (rowid) tablename group id, name, place );

UITableView separator line disappears when selecting cells in iOS7 -

in tableview set separator line between cells. allowing selection of multiple cells. here's code setting selected cell background color: uiview *cellbackgroundcolorview = [[uiview alloc] initwithframe:cell.frame]; [cellbackgroundcolorview setbackgroundcolor:[uicolor darkgray]]; [cell setselectedbackgroundview:cellbackgroundcolorview]; the problem if 2 adjacent cells selected, there no separator line between them in ios7, while there (as expected) in ios6. i tried setting cellbackgroundcolorview 's frame height of cell.frame - 1.0 , doesn't work either. any ideas? i haven't gotten bottom of yet (at first glance seems ios 7 bug..), have found workaround. in tableview:didselectrowatindexpath, if send both messages below, issue visually resolved (with probable performance cost). [tableview deselectrowatindexpath:indexpath animated:yes]; [tableview reloadrowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationautomatic]; for work (for

php - "Same" syntax, different results using mysqli fetch_assoc()? -

so, not problem need solving, rather question out of curiosity , want of clarification. struggling piece of php/mysqli , while debugging , splitting code discovered code working, not way wrote it. initial code (not working) $result = $mysqli -> query("select nick userdata id=".$_session['uid']); // ... error checking here ... for($i = $result -> num_rows - 1; $i >= 0; $i--){ $result -> data_seek($i); $nick = ($result -> fetch_assoc())['nick']; // crash } final code (working) $result = $mysqli -> query("select nick userdata id=".$_session['uid']); // ... error checking here ... for($i = $result -> num_rows - 1; $i >= 0; $i--){ $result -> data_seek($i); $row = $result -> fetch_assoc(); // working $nick = $row['nick']; // working } so, can enlighten me why first code breaks me? best regards. php 5.4 (2012-03-01) , later versions support array dereferencing functio

backbone.js - How to solve Rails environment difference? Works in staging but not in dev -

i have dashboards in backbone.js app in larger rails app. in staging , production (on heroku) dashboards work fine. however, in local pow dev environment following error in browser console when try , view specific dashboard: uncaught typeerror: object #<object> has no method 'merge' after tracking down bit, here came with. merge method being referred in error message coming rendered /assets/templates/dashboard/details.js file. here code browser calling error @ start of line 5: helpers = this.merge...: (function() { this.handlebarstemplates || (this.handlebarstemplates = {}); this.handlebarstemplates["dashboard/details"] = handlebars.template(function (handlebars,depth0,helpers,partials,data) { this.compilerinfo = [4,'>= 1.0.0']; helpers = this.merge(helpers, handlebars.helpers); data = data || {}; var buffer = "", stack1, functiontype="function", escapeexpression=this.escapeexpression; buffer += "<p&g

java - ECC memory overflow on Android -

i'm trying make eliptic cureve crypto code work on android. ( https://github.com/k3d3/ed25519-java ). works fine on computer on android stackoverflowerror. where problem occurs depends on android device. on 1 it's in scalarmult() on expmod(). debugger shows work while sudden death. ideas? memory problem? static biginteger[] scalarmult(biginteger[] p, biginteger e) { //system.out.println("scalarmult open e = " + e); if (e.equals(biginteger.zero)) { system.out.println("scalarmult close q = 0,1"); return new biginteger[]{biginteger.zero, biginteger.one}; } biginteger[] q = scalarmult(p, e.divide(biginteger.valueof(2))); //system.out.println("scalarmult asq = " + q[0] + "," + q[1]); q = edwards(q, q); //system.out.println("scalarmult aeq = " + q[0] + "," + q[1] + " e="+e+" testbit="+(e.testbit(0)?1:0)); if (e.testbit(0)) q = edwards(q, p);

jquery - Hide specific value of option form -

i have code generated plugin arrays categories. need hide specifics categories form, "pro", "basico" , "todas las provincias. <select id="category_name" class="taxonomies-filter-widget-input tax-with-childrens" name="category_name"> <option value="0">todas</option> <option class="level-0" value="pro">pro</option> <option class="level-0" value="basico">basico</option> <option class="level-0" value="todas-las-provincias">todas las provincias</option> <option class="level-0" value="alava">Álava</option> <option class="level-0" value="albacete">albacete</option> <option class="level-0" value="alicante">alicante</option> <option class="level-0" value="almeria">almería</option> <op

datetime - ColdFusion 10 ORM (Hibernate) Date Evaluation -

i'm having difficult time understanding why following hql isn't working data... ormexecutequery('from campaign startdate < ? , enddate > ?', [utcnow(), utcnow()]) sample of data looks like... startdate enddate 2013-10-06 22:15:00.0 2013-12-31 23:15:00.0 dump of utcnow() function return {ts '2013-10-06 23:14:15'} , i'm system calculating utc correctly. now, if remove startdate portion of query works fine , respects enddate not work startdate in fashion.

php - Curl - Retrive headers - empty response -

using php when working curl. i'm attempting recive headers. i request following url: http://halens.se/kvinna-klader-bad-strand-baddrakter-93/baddrakt-074209/ my settings this: curlopt_autoreferer => true, curlopt_certinfo => false, curlopt_crlf => true, curlopt_connecttimeout => 15, curlopt_failonerror => true, curlopt_followlocation => true, curlopt_forbid_reuse => true, curlopt_fresh_connect => true, curlopt_header => true, curlopt_maxredirs => 15, curlopt_protocols => curlproto_http, curlopt_redir_protocols => curlproto_http, curlopt_returntransfer => true, curlopt_ssl_verifypeer => false, curlopt_timeout => 15, curlopt_header => true, curlopt_nobody => true but response empty.. what did wrong? or how can solve in alternative way? if instead change last setting to: curlopt_nobody =&g

multithreading - C - Sending a PIPE FD, that was created in a thread, to the parent process through a FIFO -

i'm trying create small server chat app, using internet domain sockets. server composed of dispatcher , main-server. the dispatcher in charge of detecting new connection requests , handling them in new thread. thread sends information main-server through fifo. bundle sent thread has pipe fd created, main-server can communicate response. dispatcher initialised main-server fork , using execve() . the problem can't write data pipe server. [ebadf bad file descriptor] error. i understand i'm supposed pass pipe fd parent process child process, solution doesn't work me because don't know how many pipes i'm going need @ same time. moreover, don't want create fifo each thread, means need create new file every thread active , think not elegant solution. so summarize: is possible use pipes in manner? if problem use of pipes, why can't pass pipe fd through fifo , use in process? read possible communicate between unrelated processes pipes using unix

c - Issues with fgets and printf..printing a string -

working on c project , i've hit roadblock. i'm trying print point coordinate style, , i've included code necessary folks me out! //point.h struct point{ char label; int x; int y; }; //point.c displaypoint(struct point p){ char label = p.label; int x = p.x; int y = p.y; // label: (x, y) printf("(%c: (%d, %d)", label, x, y); } //build point standard input readpoint(){ struct point point; printf("enter label (character): "); fgets(buff, max_line, stdin); point.label = buff; //i think issue here printf("enter x:"); fgets(buff, max_line, stdin); point.x = (int) strtol(buff, null, max_line); printf("enter y:"); fgets(buff, max_line, stdin); point.y = (int) strtol(buff, null, max_line); upon compilation, receive following error: points.c: in function 'displaypoint': points.c: warning: initialization makes pointer integer without cast [enabled default] po

flask - Iterate through model fields in jinja template -

i have several models in application, , have views doing same thing (form + tables showing existing records in model), implemented dfferently because of model, different in each case, wondering if possible make generic. i googled bit , not able find relevant case. achieve: in view, want go through each object model passed template, example: return render_template('addstatus.html', form=form, statuses=status.query.all(), target_model="status", fields=status.__mapper__.c.keys()) but want have 1 view, whatever model be, not able know in advance fields of model, number of columns , on. i want have in view: {% obj in objects %} {% field in obj.fields %} (not existing) <h1> {{ field }} :: {{ obj.fields.field.value }} {% endfor %} {% endfor %} is possible? how can achieve that? you can add method db.model class (either subclassing or monkeypatching): from sqlalchemy.orm import class_mapper, columnproperty def columns(s

spring mvc - apache tile HTML rendering with empty <a></a> -

i having strange problem html. on backend, problem part this. <div class="content"> <a href="detail.html"></a> <img src="assets/img/tmp/img.png" alt=""></img> </div><!-- /.content --> on brower(google chrome) view source <div class="content"> <a href="detail.html"/> <img src="assets/img/tmp/img.png" alt=""></img> </div><!-- /.content --> but when inspect element <div class="content"> <a href="detail.html"> <img src="assets/img/tmp/img.png" alt=""></img></a> </div><!-- /.content --> as can see tag interpreted differently, , caused lot of problems, ideas why happens? when add <a href="detail.html"&g

actionscript 3 - What is the best way to access/reference a dynamically generated object that has linkage in the stage? -

in actionscript 3, best way access/reference dynamically generated object has linkage in stage type of movie clip, dynamically placed object(s) located in specific frame (one keyframe) , accessed via custom function timeline code in long frame? and also, appropriate code remove child/object dynamically placed object/class name (which being extended library) stage (main timeline)?

c++ - How to optimize Knight's tour algorithm? -

Image
i code knight's tour algorithm in c++ using backtracking method. seems slow or stuck in infinite loop n > 7 (bigger 7 7 chessboard). the question is: time complexity algorithm , how can optimize it?! the knight's tour problem can stated follows: given chess board n × n squares, find path knight visits every square once. here code : #include <iostream> #include <iomanip> using namespace std; int counter = 1; class horse { public: horse(int); bool backtrack(int, int); void print(); private: int size; int arr[8][8]; void mark(int &); void unmark(int &); bool unvisited(int &); }; horse::horse(int s) { int i, j; size = s; for(i = 0; <= s - 1; i++) for(j = 0; j <= s - 1; j++) arr[i][j] = 0; } void horse::mark(int &val) { val = counter; counter++; } void horse::unmark(int &val) { val = 0; counter--; } void horse::print() { cout<< "\n - - - - - - - - - - - - - - - - -

ios - How to present a setup screen from my app delegate? -

i have first time setup screen wish present on first time run of application. have tab bar controller 5 tabs , independent view controller appear on initial run. after clicking uibutton on setup screen, has return tab bar navigation first tab being shown. far in app delegate have this: // override point customization after application launch. [[nsuserdefaults standarduserdefaults] setbool:yes forkey:@"first time"]; [[nsuserdefaults standarduserdefaults] synchronize]; if([[nsuserdefaults standarduserdefaults] boolforkey:@"first time"] == yes) { [[nsuserdefaults standarduserdefaults] setbool:no forkey:@"first time"]; [[nsuserdefaults standarduserdefaults] synchronize]; sssetupscreenviewcontroller *setupcontroller = [[sssetupscreenviewcontroller alloc] init]; [(uinavigationcontroller *)self.window.rootviewcontroller pushviewcontroller:setupcontroller animated:no]; however, brings black screen every time app launched. simple missing

Matplotlib fill_between edge effect with `where` argument -

Image
i want plot region between 2 curves different colors whether 1 of line positive or negative. got edge effect non-continuous coloring of region when curve changes of sign. setting interpolate=true not help. edge effect related resolution (voluntarily coarse in basic example below) - enhancing not want. better solution make smooth transitions? thanks. import matplotlib.pyplot plt import numpy plt.figure() x=numpy.arange(0.,1.05,0.05) y1=numpy.sin(2*numpy.pi*x) y2=y1+0.2 y1positive=y1>0 y1negative=y1<=0 plt.plot(x,y1,'r',label='y1') plt.plot(x,y2,'g',label='y2') plt.plot(x,x*0,'--k') plt.fill_between(x,y2,y1,where=y1positive,color='green',alpha=0.5) plt.fill_between(x,y2,y1,where=y1negative,color='red',alpha=0.5,interpolate=true) plt.legend() http://i.stack.imgur.com/9q9ff.png ** edit ** based on pyhazard's answer addressing problem above, still encounter difficulties: revised case (see code) - need fill area

asp.net mvc - How to pass a ko.observablearray via JSON to an MVC controller -

i'm using knockout js build model pass mvc controller. ko.observable() items passed controller no problem, however, ko.observablearray([]) data appearing "count=0" @ controller. below object building in view: var addviewmodel = function () { self.modelrequest = { object: { vararray: ko.observablearray([]), var1: ko.observable(""), var2: ko.observable("") } }; .... the modelrequest.object.vararray ko.observablearray contains few attributes in object: name, id, code, type. below how i'm sending data via json: p = ko.tojson(addviewmodel.modelrequest); debugger; $.ajax({ url: url, type: 'post', contenttype: 'application/json; charset=utf-8', data: ko.tojson(addviewmodel.modelrequest), success: function (data) { ...something... } }); when debugging code, examine p variable described above , see below: {"object

android - IAB setup never completes -

i've searched around hours trying figure out. here's have done far. (note: i'm developing in android studio) generated signed apk , uploaded developer console made in-app product , activated it added billing permission manifest extensively combed stack try , find similar problems. basically in logcat see iabhelper starts setup, never completes @ time. (the listener never gets callback) private static final string tag = "preference activity"; private static final string sku_pro = "desk.clock.pro.license"; static final int rc_request = 10001; iabhelper mhelper; private boolean mispremium; private arraylist<preference> prosettings; iinappbillingservice mservice; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); addpreferencesfromresource(r.xml.preferences); bindservice(new intent("com.android.vending.billing.inappbillingservice.bind"), mserviceconn, conte

html - PHP Invalid argument supplied for foreach() loop -

i trying make sure every column in database pull html first 2 columns pull. last 3 columns don't work. 2 text values , last column decimal. can please tell me missing? thank you! $colmname = $_post["colname"]; $colmvalue = $_post["colvalue"]; $count = 0; if ($colmname = 'productid') { $thequery = "select * products productid = $colmvalue"; $rset = $db->query ($thequery); } elseif ($colmname = 'categoryid') { $thequery = "select * products categoryid = $colmvalue"; $rset = $db->query($thequery); } elseif ($colmname = 'productcode') { $thequery = "select * products (productcode = '$colmvalue')"; $rset= $db->query($thequery); } elseif ($colname = 'productname') { $thequery = "select * products (product

java - Hibernate and @ElementCollection: Duplicate Key -

i have cronjob running, calculating lot of stuff once day. there 2 entites involved. first 1 "kpi" entity, containing information user activities. every kpi entity 1:1 related user ofc. kpi entity related 1:n more detailed drill down. (it's element collection inside kpi entity). simpliefied: @entity @table(name = dbconstants.kpi_table_name) @namedqueries({ @namedquery(name = "kpi.byuser", query = "select k kpientity k k.user = :user"), @namedquery(name = "kpi.all", query = "select k kpientity k"), @namedquery(name = "kpi.allactiveusers", query = "select k kpientity k k.user.accountactive = :accountstatus") }) public class kpientity implements serializable { @id @generatedvalue(strategy = generationtype.identity) private int id; @column private long taskscompleted; @elementcollection(targetclass = java.lang.long.class, fetch = fetchtype.eager) @mapkeyclass(jav

cryptography - Should nonce / IV be private as a key? -

in block cipher modes nonce / iv , counters introduced ( http://en.wikipedia.org/wiki/block_cipher_modes_of_operation ). should private key , why? no, nonce/iv there provide distinct outputs provided same input plaintext. there's no requirements keep them confidential (but shouldn't guessable or re-used usually), , in protocols, e.g. tls >= 1.1, it's sent in clear @ beginning of every encrypted message.

javascript - Get an specific value of css class, using d3js -

i have html table , want set color of specific part of table (border-top-color of cell classed "first"). color need access specific value within css class. example: table <table class="tabla"> <caption>title</caption> <tr> <td class="first">a</td> <td class="first">157</td> </tr> </table> css class need able color .color { fill: #95ccee; background-color: #95ccee; } to achieve, i'm using d3.js in follow way var selecttablas = d3.selectall (".tabla"); selecttablas.selectall(".first") .style("border-top-color", "here function color"); the function should loop dataset and, depending of "d", different values of different classes. here, extended code http://jsfiddle.net/ploscri/dhycd/ thanks in advance. ok here's first stab @ i