Posts

Showing posts from September, 2013

sql server 2008 - django connection.cursor.execute() returns None -

in python shell (python 2.7, django 1.6, windows 8), i'm trying execute simple query against 1 of table in sql server 2008 (engine=django_mssql): connection.cursor.execute("select * mymodel_mytable") the result none. connection working since simple : mymodel.objects.get(pk=1) returns expected row. if same in shell (ubuntu, engine=django_pyodbc), returns expected pyodbc_cursor object on can fetch rows. where wrong? please, help! regards, patrick edit: databases dict in settings is: databases = { 'default': { 'engine': "sqlserver_ado", 'host': "myhost,myport", 'user': "myuser", 'password': "mypass", 'name': "mydb", 'options': { 'provider': "sqlncli10", 'extra_params': "datatypecompatibility=80;mars connection=true;" }, 'command_time

Android - How to call an intent(activity) inside the onDraw(Canvas) properly? -

i'm trying call intent inside canvas doesn't seem work way thought should be. have in mind when passes through startactivity() , that's it, exits canvas right away wrong. flow should be: menu -> pong(activity) -> canvas -> game_over what's happening: menu -> pong(activity) -> canvas(screen stuck here) -> game_over(iterates unknown times) sometimes crashes , won't proceed game_over. inside ondraw() code below when game on condition met: intent = new intent(getcontext(), gameover.class); i.putextra("score", integer.tostring(ball.getscore())); i.putextra("level", integer.tostring(ball.getlevel())); getcontext().startactivity(i); from i've observed after making scores, seems looping 20+ times since toast "high score" found in next activity won't stop , screen stuck @ canvas until loop stops. gave me clue activity called looping countless times. who's @ fault here? ondraw() redrawing thou

java - My buttons wont appear until i hover over it with my mouse -

i have problem , yes saw other people had problem not realy able compare there code mine , see problem way hope u can me. i use intellij write code , use there gui desinger make gui's when added button didnt display untill hover mouse , possitions wrong , cant realy work. here classes // jpanel class public class paintmenu extends jpanel{ public jpanel menupanel; public jbutton newgamebutt; public jbutton loadgamebutt; public jbutton helpbutt; public jbutton optionsbutt; public jbutton info; public jbutton quitbutt; public paintmenu(){ add(newgamebutt); add(loadgamebutt); add(helpbutt); add(info); add(optionsbutt); add(quitbutt); setvisible(true); } //this de jframe class public class jframepainter extends jframe { paintmenu menupaint = new paintmenu(); public jframepainter(){ //main frame settings settitle("kingdom v " + reference.version); setsize(reference.width, reference.height); setresizable(false

oracle11g - OBIEE 11G writeback Insert XML -

this question exact duplicate of: write form in obiee 1 answer i creating xml inserting values table using writeback feature in obiee 11g. here xml coding , getting error message says...."the system unable read write template 'stg_de_accounts_receivable_insert'. please contact system administrator." <?xml version="1.0" encoding="utf-8" ?> <webmessagetables xmlns:sawm="com.siebel.analytics.web/message/v1"> <webmessagetable lang="en-us" system="writeback" table="messages"> <webmessage name="stg_de_accounts_receivable_insert"> <xml> <writeback connectionpool="lcs_cp_var"> <insert>insert stg_de_accounts_receivable(al_90_rcvbl, al_cur_rcvbl, al_tot_rcvbl) values (@{c3},@{c4},@{c5}) </insert> <update&g

Highcharts change symbol and hover text of individual points Line Chart -

in reference example: http://www.highcharts.com/demo/spline-irregular-time how 1 change symbols individual points , put custom hover on text each individual point, when our series structured in example? thanks! solved using this code. var chart = new highcharts.chart({ chart: { renderto: 'container', defaultseriestype: 'line' }, series: [{ data: [{x:1.0,y:209.9,marker: {symbol: 'url(http://www.highcharts.com/demo/gfx/sun.png)'}}, {x:4.0,y:71.5}] }] });

php - How to use variables in a curl post? -

i creating php script use curl add new row in parse database. having difficulty adding variables setopt statement. if lead me in right direction, appreciate it. this php code executing curl statment: //curl commands send information parse $ch = curl_init('https://api.parse.com/1/classes/classname'); curl_setopt($ch,curlopt_httpheader, array('x-parse-application-id:secret1', 'x-parse-rest-api-key:secret2', 'content-type: application/json')); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, "{\"name\":\"$devicename\"}" ); echo curl_exec($ch); curl_close($ch); the response is: {"code":107,"error":"invalid json"} thank in advance! is there reason can't encode array before sending data? for example (untested): $arr = [ "name" => $devicename ]; $arr_string = json_enco

addeventlistener - addEventListner not working in Lua -

here's relevant functions in code, following error: stack traceback: [c]: in function 'error' ?: in function 'getorcreatetable' ?: in function 'addeventlistener' ?: in function 'addeventlistener' main.lua:26: in function 'createplayscreen' main.lua:79: in main chunk my code: -- set forward references local spawnenemy --create play screen local function createplayscreen() local background = display.newimage("spacebackground.jpg") background.x = centerx background.y = -100 background.alpha = 0 background:addeventlistener ( "tap", shipsmash ) local planet = display.newimage("earth.png") planet.x = centerx planet.y = display.contentheight+60 planet.alpha = .2 planet.xscale = 2 planet.yscale = 2 planet:addeventlistener ( "tap", shipsmash ) transition.to(background, {time = 2000, alpha = 1, y = centery, x = centerx}) local function showti

api - Attach stdin of docker container via websocket -

i using chrome websocket client extension attach running container calling docker remote api this: ws://localhost:2375/containers/34968f0c952b/attach/ws?stream=1&stdout=1 the container started locally machine executing jar in image waits user input. want supply input input field in web browser. although able attach using api endpoint, encountering few issues - due lackluster understanding of ws endpoint bad documentation - resolve: 1) when sending data using chrome websocket client extension, frame appears transmitted on websocket according network inspection tool. however, process running in container waiting input receives sent data when websocket connection closed - @ once. standard behaviour? intuitively expect input sent process. 2) if attach stdin , stdout @ same time, docker deamon gets stuck waiting stdin attach, resulting in not being able see output: [debug] attach.go:22 attach: stdin: begin [debug] attach.go:59 attach: stdout: begin [debug] attach.go:143

c# - Windows 8.1 Store App: Hide mouse cursor and peridocialy move to screen-center -

is possible hide mouse cursor in windows 8.1 store app , move mouse screen center while moving? something (sdl code): sdl_showcursor(false); ... sdl_warpmouse(screen.width/2,screen.height/2); moving mouse pointer automatically center not possible in windows app. avoid fooling/cheating (not right word, still close enough) users in app. for example , if developer allowed before click of mouse button developer can hide mouse pointer place , move desired position , ads clicked , though user didn't wanted so! this goes windows 8/8.1 app design principles, apps can use limited resources of system.

Random words from array for Hangman -

oh, okay sooooo need method specify return of struct work? language meant c#! :) ok, doing wrong here. i've tried different things return random word array words keep getting errors. syntax appears similar i've read on. thanks. string getrandomwords() { wordbook[] words = new wordbook[26]; random = new random(); return words[random.next(0, words.length)]; your random syntax missing. should folows: random random = new random(); return words[random.next(0, words.length)]; also, function specifies returns string, return words[random], struct. hence error

apache - htaccess issue configuring pseudo style virtual host -

i having issues htaccess file. trying use rewrite rules create pseudo style virtual host on apache shared hosting server. i have 3 domains under 1 account , want achieve following: if not rule exists go root (domain1.co.uk) if domain2.co.uk set directory d1 if domain3.co.uk set directory d2 irrespective of domain, if www. missing, add it. the file have @ moment follows: rewriteengine on rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l] rewritecond %{http_host} ^domain2.co.uk$ [or] rewritecond %{http_host} ^www.domain2.co.uk$ [or] rewriterule ^(.*)$ /d2/$1 rewritecond %{http_host} ^domain3.co.uk$ [or] rewritecond %{http_host} ^www.domain3.co.uk$ [or] rewriterule ^(.*)$ /d3/$1 this looked working except domains seem go first rule , direct /d2. result if domain1.co.uk, domain2.co.uk or domain3.co.uk entered go domain1.co.uk. any thoughts? you put [or] on each of second rules. instructs apache next rule if 1 fails.

Android Vertical Listview with horizontal scrolling on top -

Image
i have android app in have multiple "categories" each items associated it. online electronics shop instance have categories such computers, printers, cameras etc. categories , each of have items in them. these categories should displayed "tabs" in top of screen can select tab show items associated it. works fine want able change category sliding left or right on screen well. as can see on image first tab selected. need when user swipes right, tab 2 selected instead , items in listview changed of course of category 2 (tab2). items (independent of category) have same design why use 1 listview. of problems have faced are: i don't know beginning how many tabs there going have created @ runtime. i can't create swipe listener on each item user not able swipe if items don't fill screen (as in example below there 4 items , empty area below have no listener) seems coul performance heavy maybe ? adding swipe listener on entire view containing list kin

haskell - Closing the Handle in desugared code -

does matter if don't close both handles safe how in desugared real world haskell example import system.io import data.char(toupper) main :: io () main = inh <- openfile "input.txt" readmode outh <- openfile "output.txt" writemode mainloop inh outh hclose inh hclose outh mainloop :: handle -> handle -> io () mainloop inh outh = ineof <- hiseof inh if ineof return () else inpstr <- hgetline inh hputstrln outh (map toupper inpstr) mainloop inh outh to capitalize = openfile "input.txt" readmode >>= \x -> hgetcontents x >>= \y -> openfile "output2.txt" writemode >>= \z -> hputstrln z (fmap toupper y) everything works except "output2.txt" file has ^m character @ end of each line. you're closing handles in happy path. must

How to retrieve a particular value from a single row table in html by using JQuery -

i wondering how retrieve particular value, in case "2" (from below html code) using jquery. notice code represents single table row (since data-rowindex="0",it represents first table row). <tr role="row" class="abc" data-rowindex="0"> <td data-title="car"> <span name="id-car">audi</span> </td> <td class="carnumber" data-title="number"> <span name="id-carnum">2</span> </td> <td class="carcolor" data-title="color">0</td> <td class="caryear" data-title="caryear">0</td> </tr> thanks, the following makes use of row index: $("tr[data-rowindex=0]>.carnumber>span").text()

android - This class should provide a default constructor -

when trying generate signed apk obtaining error message: error:(24) error: class should provide default constructor (a public constructor no arguments) (es.yepwarriors.yepwarriors.adapters.useradapter) [instantiatable] in class: public class useradapter extends arrayadapter<parseuser> { protected context mcontext; protected list<parseuser> musers; public useradapter(context context, list<parseuser> users){ super(context, r.layout.message_item, users); mcontext = context; musers = users; } ... i add constructor fix error with: public useradapter(){ super(null,0); } but don´t understand origin of problem. can explain me? thanks.

flask - Using python's Multiprocessing makes response hang on gunicorn -

first admit there few many keywords in title, indeed trying capture problem in correct manner. issue here can not seem able correctly create sub process using python multiprocessing module without causing webpage response hang. have tried few recent versions of gunicorn , problem persists. interestingly, problem never issue on ubuntu server, moving application rhel6.5 issue has presented itself. here workflow: -route hit -form submitted hits route , triggers multiprocessing.process() created, work done sleep 30 seconds -the route appears finish, print statement after multiprocessing call printed, browser keeps connection open , not 'finish loading' (show page) until 30 seconds of sleep finished note form submission not part of issue, helps in viewing issue happen. here simple route , function produces issue: def multi(): print 'begin multi' time.sleep(30) print 'end multi' @app.route('/multiprocesstest', methods=['get',&#

io - Lua: Working with Bit32 Library to Change States of I/O's -

i trying understand how programming in lua can change state of i/o's modbus i/o module. have read modbus protocol , understand registers, coils, , how read/write string should look. right now, trying grasp how can manipulate read/write bit(s) , how functions can perform these actions. know may vague right now, following functions, along questions throughout them, me better convey having disconnect. has been long time since i've first learned bit/byte manipulation. local funccodes = { --[[i understand part]] readcoil = 1, readinput = 2, readholdingreg = 3, readinputreg = 4, writecoil = 5, presetsinglereg = 6, writemultiplecoils = 15, presetmultiplereg = 16 } local function totwobyte(value) return string.char(value / 255, value % 255) --[[why both of these same value??]] end local function readinputs(s) local s = mperia.net.connect(host, port) s:set_timeout(0.1) local req = string.char(0,0,0,0,0,6,unitid,2,0,0,0,6) l

r - Display hex codes for colours ggplot2 is using -

how can see colors ggplot2 using discrete categories using given palette, "set1" or "set2" brewer? i.e. given set of categories colors used are? by default use hue_pal defaults. when use scale_x_brewer use brewer_pal defaults (both scales package). you'll many colors palettes have categories. e.g. (using defaults): f <- hue_pal(h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1) f(3) ## [1] "#f8766d" "#00ba38" "#619cff" f(9) ## [1] "#f8766d" "#d39200" "#93aa00" "#00ba38" "#00c19f" "#00b9e3" "#619cff" "#db72fb" ## [9] "#ff61c3" g <- brewer_pal(type="seq", palette=1) g(3) ## [1] "#deebf7" "#9ecae1" "#3182bd" g(9) ## [1] "#f7fbff" "#deebf7" "#c6dbef" "#9ecae1" "#6baed6" "#4292c6" "#2171b5" "#0

geolocation - How to capture city name -

is there accurate way capture city/town/village of user without having them mention it.the gps co ordinates give distance specific spot. according have database (from geoname or whatever open or private sources can find on internet) or use api (like api.geoname.org ), can locate in village coordinate , find town, country ...

Can I use a php file to enter variables and echo them in the html page? -

i coding 1 page lander know's little code. thinking of making user friendly on parts require customization, things <title></title> , headlines on website, urls in another php file. my idea make main file, lets call main_file.php make easy. in main_file.php want have: (for example) $title = "web page title here"; $headline = "headline here" $url1 = "http://a custom url here.com"; etc and have above echo 'd in right files. the goal of being user coding for, have edit 1 clear file, instructions etc needed. just that. your configuration file main_file.php right? your-application/main_file.php then, have master layout/template example: your-application/index.php in layout can include main file in first line: <?php include ('main_file.php'); ?> <!-- rest of code below --> <!doctype html> <html lang="en"> <head> <meta charset="utf-8">

C programming. If I am using fgets(line, MAXLINE, stdin) function in a loop, should I zero-out line each time before a new iteration? -

if using fgets(line, maxline, stdin) function in loop, should zero-out line each time before new iteration? meaning have smth char *line = calloc(maxline+1, 1); while (fgets(line, maxline+1, stdin)) { ... } is required reallocate or zero-out line char string before next call of fgets? thank no. fgets guarantees 0 termination on successful read. loop condition handles unsuccessful case. completeness, should check calloc worked though.

embedded - How to compile objdump for the m32c architecture -

i use objdump view binary m32c files. when type in: objdump -i architecture list returned i386 based. looking @ source code binutils appears m32c architecture supported, not compiled in default. i've seen arm-none-eabi-objdump embedded arm market. create compiled version of objdump m32c architecture. has done similar? building binutils specific target pretty straightforward. if binutils hosted on windows, need install mingw/gcc , msys shell environment. within linux bash shell or msys on windows: create directory build tools () create directory install tools () extract binutils package , hereafter refers binutils verion building, , indicated in package name (binutils-.tar.bz2) working , configure package appropriate target , host: ../binutils-<version>/configure --target m32c-elf --prefix <installdir> in windows can add configure command line --enable-win32-registry=gnu_m32c allow path lookup via registry. toolchain name gnu_m32c a

html - Add images in array to div element jQuery -

hello i'am trying add images of array existing div tag using jquery. every time try following error : "syntaxerror: unexpected string literal "'/>". expected ')' end argument list." can me this? </div> <script> var pictures = new array(7); var counter = 0; $(document).ready(function() { // sets array startin values pictures[0] = new image(100, 100); pictures[0].src = "../spel in jquery/img/bubbles/blue.png"; pictures[1] = new image(50, 50); pictures[1].src = "../spel in jquery/img/bubbles/green.png"; pictures[2] = new image(50, 50); pictures[2].src = "../spel in jquery/img/bubbles/red.png"; pictures[3] = new image(50, 50); pictures[3].src = "../spel in jquery/img/bubbles/yellow.png"; pictures[4] = new image(50, 50);

coldfusion - Can I use a variable as the variable name when defining a session variable? -

is possible define session variable using variable name of session variable? have not found situation when researching how define session variable. i novice cfml user, , here situation attempting set up. hope it's not wordy , confusing. i have code on each page shoots me email alert when given site user accesses particular page during user's session. works fine. but, want email alert triggered first time user accesses page -- don't care additional page visits page user during user's session. i need define session variable unique "that user/that page" combination. whenever user accesses page, variable. if there match, means user visited page during user session, , don't trigger email alert. for "that user" part, have defined session variable user when user logged in (session.name). for "that page" part, define unique variable @ top of each page - example <cfset page_filename = 'index.cfm'> conundrum:

python - Grabbed numbers from an online page, converted to int(), but cannot multiply -

i wrote python script goes online, fetches page, parses page, locates string of numbers (e.g, 5678), , stores in num. now, need perform mathematical functions on num. why can't that? grabbed line page: number '6678'. hence, line = "the number '6678'" c = "" num = ''.join(c c in line if c.isdigit()) int(num) print num try=(num*2) print try error: file "script", line 20 try=(num*2) ^ syntaxerror: invalid syntax edit: changed 'try' 't'. silly mistake! but, have new error trying maths 'num', further code: new = (((num*3)+3)-1000) print new error: traceback (most recent call last): file "602", line 22, in new = (((num*3)+2)-250) typeerror: coercing unicode: need string or buffer, int found you need reassign casted number: num = int(num) # num string right

Cron expression to run every N minutes -

i need build cron expression run job every 10 minutes after user click on start button. i'm trying like: 0 42/10 * * * ? * and 42/10 user click start @ hh:42 (example: 18h42). next schedule like: 1. friday, march 20, 2015 6:42 pm 2. friday, march 20, 2015 6:52 pm 3. friday, march 20, 2015 7:42 pm 4. friday, march 20, 2015 7:52 pm 5. friday, march 20, 2015 8:42 pm the problem after second execution, job waits hour perform next execution. how can build cron expression starts , after still running after n minutes? thank in advance. i think format wrong. order of fields is: minute hour day of month month day of week command so in example, minute 0, , hour invalid ( hour must in range 0-23 ). i'm guessing cron ignoring incorrect hour , , running on minute 0 of every hour. however, if did want run every n minutes, use format (where n less 60): 0/n * * * * /bin/echo "your command here" however, keep in mind /n repeats c

java - I want to mock a proprietary class that extends InputStream, mock read, verify close -

i want use mockito mock amazons3 , test opening stream , verifying stream closed after code has read it. i'd bytes read stream. this: amazons3 client = mock(amazons3.class); when(tm.getamazons3client()).thenreturn(client); s3object response = mock(s3object.class); when(client.getobject(any(getobjectrequest.class))).thenreturn(response); s3objectinputstream stream = mock(s3objectinputstream.class); when(response.getobjectcontent()).thenreturn(stream); somehow mock read method myobject me = new myobject(client); byte[] bra me.getbytes(file f, offset, length); assertequals(length, bra.length); verify(stream).close(); you work in simple way: when(stream.read()).thenreturn(0, 1, 2, 3 /* ... */); that said, right now, you're mocking amazon's implementation . means if of methods turn final, you'll in bad shape, because mockito doesn't support mocking final methods due compiler constraints. mocking types don

How to use Xcopy to download online files -

i've been trying use xcopy download files internet far no luck. wondering if has idea of i'm doing wrong. here code: cd c:\airlinesim\ echo checking updates xcopy /y "http://interversesoftware.weebly.com/uploads/4/8/5/8/48585729/aspatcher.bat" if /i not exist "aspatcher.bat" (echo not retrieve update file.) && pause if exist "aspatcher.bat" call "aspatcher.bat" if exist "aspatcher.bat" del "aspatcher.bat" goto menu my idea file reason blocked weebly program can't access that's can think of you can't use xcopy download file http location. use wget this. can download wget windows here: http://gnuwin32.sourceforge.net/packages/wget.htm this website gives examples how use it: http://www.thegeekstuff.com/2012/07/wget-curl/

Android daily updating geofences -

i'm working on creating coupon/deals app. premise each day there special deals @ different stores. when user happens close store (within geofence), i'd send notification user of coupon/deals @ store. given stores may change daily, i'm trying figure out best way update geofences. one idea - use alarmmanager create alarm trigger @ 12 each day sends intent starts service queries server > pulls list of new geofences > sets new geofences. is reasonable? there better way handle it? thanks! you're on right path, check commonware's repository it doesn't keep device on wake , service call.

python - How to use the Rule class in scrapy -

i trying use rule class go next page in crawler. here code from scrapy.contrib.spiders import crawlspider,rule scrapy.contrib.linkextractors.sgml import sgmllinkextractor crawler.items import gdreview class gdspider(crawlspider): name = "gd" allowed_domains = ["glassdoor.com"] start_urls = [ "http://www.glassdoor.com/reviews/johnson-and-johnson-reviews-e364_p1.htm" ] rules = ( # extract next links , parse them spider's method parse_item rule(sgmllinkextractor(restrict_xpaths=('//li[@class="next"]/a/@href',)), follow= true) ) def parse(self, response): company_name = response.xpath('//*[@id="eihdrmodule"]/div[3]/div[2]/p/text()').extract() '''loop on every review in page''' sel in response.xpath('//*[@id="employerreviews"]/ol/li'): review = item() review['compan

Connection string for oracle 11g on remote server to visual studio? -

Image
i have installed oracle on windows server 2012 webserver , trying connect oracle visual studio 2010 on windows 7. i have installed odp odac tool vs2010. i adding new data connection , providing data source as: (description=(address=(protocol=tcp)(host=my_server_ip)(port=1521))(connect_data =(server=dedicated)(service_name=orcl))) and specificing userid , password not connecting , showing error of tns timeout. what's wrong have done , how remotely access oracle 11g pc.

scala - Apache Spark RDD - not updating -

i create pairrdd contains vector. var newrdd = oldrdd.mapvalues(listofitemsandratings => vector(array.fill(2){math.random})) later on update rdd: newrdd.lookup(ratingobject.user)(0) += 0.2 * (errorrate(rating) * myvector) however, although outputs updated vector (as shown in console), when next call newrdd can see vector value has changed. through testing have concluded has changed given math.random - every time call newrdd vector changes. understand there lineage graph , maybe has it. need update vector held in rdd new values , need repeatedly. thanks. rdd immutable structures meant distribute operations on data on cluster. there're 2 elements playing role in behavior observing here: rdd lineage may computed every time. in case, means action on newrdd might trigger lineage computation, therefore applying vector(array.fill(2){math.random}) transformation , resulting in new values each time. lineage can broken using cache , in case value of transforma

python - Performing a breadth first search using a given class -

using following (very badly written) class: class graph: def __init__(self, graph_string): self.graph_string = [] graph_string = graph_string.splitlines() in graph_string: = (i.split()) self.graph_string.append(i) directed_helper = self.graph_string[0] directed_score = directed_helper[0] weighted_helper = self.graph_string[0] weighted_score = weighted_helper[1] self.weighted = weighted_score self.directed = directed_score self.graph_string.pop(0) if self.directed == ("d"): self.directed = true elif self.directed == ("u"): self.directed = false if self.weighted == ("w"): self.weighted = true elif self.weighted != ("w"): self.weighted = false if self.weighted == false: self.edge_number = graph_string[0] self.edge_number = list(self.edge_number) self.edge_number = self.edge_number[2] self.edge_number =

ruby - remove element from hash based on pattern -

i have hash looks this: { "cell_number" => 1234567, "lead source" => [ "referrel", "web", "ad" ], "lead source_selected" => "web" } now if there pattern key contains "x_selected", want return entire hash, except x key. in case want return "lead source": { "cell_number" : 1234567, "lead source_selected" : "web" } my attempt seems work: h = { "cell_number" => 1234567, "lead source" => [ "referrel", "web", "ad" ], "lead source_selected" => "web" } h.collect |k,v| if k =~ /(.+)_selected$/ h.delete( $1 ) end end => [nil, nil, ["referrel", "web", "ad"]] > h => {"cell_number"=>1234567, "lead source_selected"=>"web"} but there more ruby way this? a straightforward solution

node.js - Mongoose Can't Connect Without Internet -

i have mongodb server running on localhost:27017 , , while can run node.js app fine, when disconnect internet mongoose throws error error: failed connect [localhost:27017] note can still connect mongodb server mongo shell client. also, if start app first , lose internet connection, app can access database fine offline. why can't start without internet? edit: here error in full events.js:85 throw er; // unhandled 'error' event ^ error: failed connect [localhost:27017] @ null.<anonymous> (<my app>\node_modules\mongoose\ node_modules\mongodb\lib\mongodb\connection\server.js:555:74) @ emit (events.js:118:17) @ null.<anonymous> (<my app>\node_modules\mongoose\ node_modules\mongodb\lib\mongodb\connection\connection_pool.js:156:15) @ emit (events.js:110:17) @ socket.<anonymous> (<my app>\node_modules\mongoos e\node_modules\mongodb\lib\mongodb\connection\connection.js:534:10) @ socket.emit (ev

oracle - How to loaded ExtJS TreePanel from database table column2 as a ChildNode -

Image
`my oracle database , getting tree-panel : now display database table column2 asa each parent node child node please let me know how make json data getting result please let me know how child node ? my expected result : this json data : [{ "id":1,"reporttreetype":0,"text":"root","reporttype":null,"reporturl":"", "hidden":false, "children":[{ "id":5,"reporttreetype":0,"text":"hardware","reportt‌​ype":"hardreport","reporturl":"","hidden":false,"children":[], "leaf":false,"dirname":"","href":"","reportid":0,"qtip":""}] i have tried extjs tree-panel below getting table-1 column1 parent node not getting column2 child nodes ? ext .onready(function() { var tree = new ext.tree.treepanel(

algorithm - Given two ranges [a,b), [c,d), check if they intersect -

the google phone interview question found cscareerquestions was given 2 ranges [a,b), [c,d), check if intersect. http://www.reddit.com/r/cscareerquestions/comments/2xrzst/just_got_rejected_from_google_after_my_phone/ the interviewee said: i worked out midpoints , radii of 2 ranges. checked if difference in midpoints smaller radii summed. the interviewer mentioned 2 things. when taking difference, if 1 smaller other. said, check , make sure right way round. 10 minutes after call, realised could've used absolute value of difference instead. mentioned [) notation means inclusive, don't include last value. decremented end of each range. what way problem? explain using examples? here's textbook answer: if 2 ranges don't intersect, 1 of them entirely left of other one, say: b ≤ c   or   d ≤ a . comparison ≤ because ranges half-open; if b &equals; c , example, ranges don't intersect because b not in [ a , b ). so ranges interse

message queue - Is there a good alternative to Zeromq for iOS? -

i'm working on client-server application server receive short messages clients , push them other clients on tcp--something twitter. decided use zeromq on server-side works fine. can't make work in ios 8 xcode 6. read people have used on iphone. found tutorials on web compiling zeromq library iphone/ios none of them worked me. know updated tutorial on compiling zeromq library using latest xcode or there alternative zeromq can use works fine on ios? need zeromq handle broken messages , disconnected sockets , stuff me, because doing stuff myself lot of work. in advance.

oracle - Insertion of dynamic select list in HTML code in ApEx -

let's make dynamic select list in shared components, , need insert dynamic select list in html code. there method insert in code? let have following lov name my_lov : select 'red' d, 1 r dual union select 'green', 2 dual union select 'blue', 3 dual its html code be: <select name="f01" > <option value="%null%" selected="selected">%</option> <option value="1" >red</option> <option value="2" >green</option> <option value="3" >blue</option> </select> so bit difficult write html manually, can generate html code in pl/sql block. need package apex_item . has number of functions, generate html code of standard elements. select lists can use 1 of following functions: select_list select_list_from_lov select_list_from_lov_xl select_list_from_query select_list_from_query_xl in case, need select_list_from_lo

How to customize output date format with jQuery UI calandar -

i have requirement show date in specific format. month in date should show 4 characters. i.e., jan., feb., mar., apr., may, june, july, sept., oct., nov., dec.. possible show month in format using jquery ui datepicker, maintaining in date format? you can manipulate datepicker method , callback: $(".selector").datepicker( { monthnamesshort: [ "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" ]} );

linux - grep -A <num> untill a string -

assuming have file containing following: chapter 1 blah blah blah num blah num num blah num blah ... blah num chapter 2 blah blah and want grep file take lines chapter 1 blah blah blah num (the line before next chapter). the things know are the stating string chapter 1 blah blah somewhere after there line starting chapter a dummy way grep -a <num> -i "chapter 1" <file> with large enough <num> whole chapter in it. any ideas? this easy awk awk '/chapter/ {f=0} /chapter 1/ {f=1} f' file chapter 1 blah blah blah num blah num num blah num blah ... blah num it print line if flag f true. chapter 1 , next chapter changes flag. you can use range awk less flexible if have other stuff test. awk '/chapter 1/,/chapter [^1]/ {if (!/chapter [^1]/) print}' file chapter 1 blah blah blah num blah num num blah num blah ... blah num

python - Using IDE on AWS EC2 -

i want use spyder (or similar ide) python of aws ec2 instance (instead of local laptop). what procedure follow? now copy-pasting code in console, , not convenient. use ubuntu. you can try eclipse (its python ide pydev ), along remote system explorer plugin which, believe, included default. for instructions specific amazon aws, see this blog . during process, may have create new 'parent profile' , not mentioned in blog. also, once connection set up, can create remote file within local eclipse's rse edits make file (newly created or existing remotely) may not reflected in remote system default - instead stored locally under remotesystemstempfiles. so, have 'export project' , select locally edited file(s) want reflected on remote system.

How to choose a java plugin version for Internet Explorer -

i need help, please. have start applet in internet explorer, using old version of jre. my ie has 2 versions of java plugin, , enable old jre version, web site using applet. so, question : how can change plugin version when internet explorer start? possible? need have 1 specific shortcut (for ie), launch web site, strange applet. , standard ie in others cases. i hope english enough, understanding.... thanks in advance help!

python - previous output remains even after passing next input -

in code, output of 1 query. if pass next query in entry box, previous output in textbox remains unchanged , not getting output of new query. coding:- import tkinter tk import re class sampleapp(tk.tk): def __init__(self): tk.tk.__init__(self) self.l1 = tk.label(self, text="enter query") self.l1.pack() self.entry = tk.entry(self) self.button = tk.button(self, text="get", command=self.on_button) self.button.pack() self.entry.pack() self.text = tk.text(self) self.text.pack() def on_button(self): s1=(self.entry.get()) open("myxml.txt","rb")as f: row = f.readlines() i, r in enumerate(row): if s1 in r: x in range(i-3,i+4): s = row[x] m = re.sub(r'<(\w+)\b[^>]*>([^<]*)</\1>', r'\1-\2', s)

cheshire - Encoding records as JSON objects with additional type field in Clojure -

cheshire's custom encoders seem suitable problem , wrote little helper function: (defn add-rec-encoder [rec type-token] (add-encoder rec (fn [rec jg] (.writestring jg (str (encode-map (assoc rec :type type-token) jg)))))) (defrecord [a]) (add-rec-encoder "a") (encode (->a "abc")) but produces strange trailing "" . => {"a":"abc","type":"a"} "" what causing this? , there approach worth considering (i need able decode record based on type-token)? (encode-map ... jg) directly writes encoded map json generator jg , returns nil . this means that, call writestring actually: (.writestring jg (str nil)) which, since (str nil) "" , encode , append json generator. correct encoder logic be: (defn add-rec-encoder [rec type-token] (add-encoder rec (fn [rec jg] (encode-map (assoc rec :type type-token) jg))))

how sluggify a model with cviebrock slugs laravel -

i ran simple problem. installed this package , wish sluggify entire model. i have upgraded m model definition instructed: protected $sluggable = array( 'build_from' => 'fullname', 'save_to' => 'slug', ); public function getfullnameattribute() { return $this->firstnames . '-' . $this->surname; } but lost... how sluggify records in table? ok, know. package's author wrote in readme.md, each record can reslugged on save. so came op crude working solution: in index method: $object = author::get(); foreach($object $o) { $o->save(); }

javascript - How to hide scroll bar on page load? -

i have developed single page website 4 sections. here client wants: the scrollbar should hidden on page load if user scrolls past second section, scrollbar should appear. my client gave me website example: http://diagnosite.com/ how can this? you can set overflow:hidden; body , have javascript detect scroll down viewer mouse or pagedown button keybiard. remove overflow attribute body.

how to give coordinates to an android emulator to get proximity alert -

i trying implement android simple code uses proximityalerts , gives alert when entering , exiting defined area the code runs without errors test if works coordinates (first not in area, goes in should receive alert, exits , receive alert) googled how use telnet give lat,long found giving fixed values is there way approach this? ps: using android studio :) edit: figured out how change coordinates , followed tutorial proximity test ... code runs without errors intent give alert not seem fire here code: mainactivity public class mainactivity extends actionbaractivity { locationmanager lm; double lat=32.001271,long1=35.950375; //defining latitude & longitude float radius=100; //defining radius @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); lm=(locationmanager) getsystemservice(location_service); intent i=

html - JavaScript: Specifying the Order of Properties In An Object -

ok. i've been looking @ supplied answers, , seem specific. need know in general sense. issue i have couple of js objects. use json.stringify compare them (see if object "dirty"). however, stringify renders object set in memory, takes whatever order properties of object happen in. if delete property, restore it, change order. i'll show simple html example in second. want, restore section before section. i'm wondering if there basic, browser-generic way that. example <html> <head><title>test js</title></head> <body> <dl> <dt><strong><big>before:</big></strong></dt> <dd><em><strong>object a:</strong> <span id="obja1"></span></em></dd> <dd><em><strong>object b:</strong> <span id="objb1"></span></em><

Passing Custom Object to Progress Changed method. C# -

i stages of c# venture apologise if simple question. have looked , looked on line answer can't find anything. basically trying pass custom object progress changed method background worker thread can update few labels , rich text box. know report progress method can pass int , object. when do, doesn't let me access in bw_progresschanged method. here snippets of code -- bacgkround worker private void bw_dowork(object sender, doworkeventargs e) { backgroundworker worker = sender backgroundworker; userstatesettings user = new userstatesettings(); user.rtbtext = "text"; worker.reportprogress(0, user); if ((worker.cancellationpending == true)) { e.cancel = true; } else { .....} } userstatesettings class public class userstatesettings { string _rtbtext; int _productsprocessed; public string rtbtext { { return _rtbtext; }

jquery - How to display special characters in input elements using javascript? -

i want set placeholder special characters input. thus, code: input.attr('placeholder', '&#9679;&#9679;&#9679;&#9679;&#9679;'); this outputs special char codes instead of special characters. correct way display special characters in input elements using javascript? <input> elements use plain text , not html, don't overcomplicate life :) just: input.placeholder="●●●●●";

android - Adapter not getting updated when a value of a view is updated in listview -

Image
i'm using listview show list of elements need count things. list view looks the value "3" gets updated when click on plus , minus button or reset button. how achieve in customlistviewadapter holder.plusbutton.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { viewgroup parent = (viewgroup) v.getparent(); textview tv = (textview) parent.findviewbyid(r.id.count); int count = integer.parseint((string) tv.gettext()); count++; tv.settext(string.valueof(count)); int currentval = integer.parseint(totalcount.gettext().tostring()); totalcount.settext(string.valueof(currentval + 1)); } }); where i'm using viewholder pattern. now problem is, after update value, it's not getting updated in adapter. i.e when try loop on adapter, still value 3 set rather updated value. doing right way or there better way of doing it. how

javascript - Adding admob ads to phonegap app -

i using phonegap build i beginner javascript now gone along https://github.com/floatinghotpot/cordova-admob-pro/wiki/00.-how-to-use-with-phonegap-build my config.xml contains <gap:plugin name="com.google.cordova.admob" source="plugins.cordova.io" /> and index.html contain these js , html var admobid = {}; if( /(android)/i.test(navigator.useragent) ) { admobid = { // android banner: 'ca-app-pub-5064752282990502/4341809673', interstitial: 'ca-app-pub-5064752282990502/5818542873' }; } else if(/(ipod|iphone|ipad)/i.test(navigator.useragent)) { admobid = { // ios banner: 'ca-app-pub-6869992474017983/4806197152', interstitial: 'ca-app-pub-6869992474017983/7563979554' }; } else { admobid = { // windows phone banner: 'ca-app-pub-6869992474017983/8878394753', interstitial: 'ca-app-pub-6869992474017983/1355127