Posts

Showing posts from March, 2013

jquery - Stripping content from HTML page returned through ajax -

is there way display specific text out of html page returned ajax call? specific text, mean first paragraph/div of html page returned. by using $.load in jquery, able fetch page. how proceed here. is possible implement using jquery alone, without parsing html @ end , , returning selected text response server. .load() accepts selector can used specify fragment of page appended $('#x').load('page.html div:eq(0)') demo: plunker

android - how to run my service once in 30 minutes? -

can body me simple way run service once in half hour? this not atall working can body how run once in half hour pls. i use start app on system boot not working..? i doing : autostart.java public class autostart extends broadcastreceiver { public void onreceive(context arg0, intent arg1) { intent intent = new intent(arg0,back_process.class); arg0.startservice(intent); log.i("autostart", "started"); } } back_process.java public class gps_back_process extends service { private static final string tag = "myservice"; @override public ibinder onbind(intent intent) { return null; } public void ondestroy() { toast.maketext(this, "service stopped ..!", toast.length_long).show(); log.d(tag, "ondestroy"); } @override public void onstart(intent intent, int startid) { i

c# - Best practices to Manage Database project in TFS and visual studio -

currently , don't have our stored procedures , , else related proj in tfs , managing on server ( adding , fixing , removing stored procedured , tables etc) start manage via tfs , visual studio. is there best practices on how manage stuff ? didn't read sql server 2005 visual studio template , doesn't know , there way create project in vs , connect existing database , , able track changes of procedures , in tfs ? thanks. yes, can create database project , import objects database want manage. can start with msdn article .

jquery - How to insert LESS mixin in to JavaScript code -

is there option insert less mixin in js code? i have border-radius mixin: .border_radius(@radius: 5px) { border-radius: @radius; -moz-border-radius: @radius; -webkit-border-radius: @radius; } so there possible add mixin in jquery code? var less = require('less'); $('.circle').css({ width: width, height: width, less.border_radius(10px); }); you define javascript equivalent of less mixins require: html <div class="circle"></div> css .circle { border: 1px solid #ff0000; } jquery function border_radius(radius) { radius = radius || '5px'; return { 'border-radius': radius, '-moz-border-radius': radius, '-webkit-border-radius': radius } } var styles = border_radius(), width = '20px'; styles.width = width; styles.height = width; $('.circle').css(styles); jsfiddle

groovy - Do grails' getter methods return COPIES of attributes objects, or the attributes objects themselves? -

for instance: class person { def stuff } class toilet { public void main(string... args){ person person = new person() person.getstuff() //null, point } } does getstuff() returns copy of stuff ? or stuff itself? i'm concerned modifiability of returned stuff object. groovy (used grails) returns object itself, objects ( def , object , person , etc). can modify object. and copy primitives ( int , long , etc). it's same java.

android - How to change the default disabled EditText's style? -

Image
it isn't looking nice when using edittext enabled="false". how can change automatically of controls? i've added image reference. can me? thanks. in color file define color: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:color="@color/disabled_color" /> <item android:color="@color/normal_color"/> </selector> in layout: <edittext android:text="whatever text want" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textcolor="@color/example" /> </edittext>

javascript - length of data in Ajax call -

in application getting json data through ajax call .aspx page json data format this { "table": [ { "id": 911, "source": "vishakhapatnam", "dest": "goa", "capacity": 24000, "h1": 400, "h1at": 7, "h1dt": 8, "h2": 401, "h2at": 9, "h2dt": 9.3, "h3": 402, "h3at": 12, "h3dt": 12.3, "h4": 403, "h4at": 14.3, "h4dt": 15, "h5": 404, "h5at": 16, "h5dt": 17, "h6": 405, "h6at": 18, "h6dt": 19, "h7": 406, "h7at": 19.3,

http status code 404 - Redirect to old website version when not found -

i have website (ex. @ chamthi.net). lance new version of website, , old version (articles) has been moved /old directory ( chamthi.net/old ). want each time user go url not available (404), website redirect user old version. there solution that? thanks. you need make custom 404 error page, dynamic content adding /old referrer address , redirecting it...

What does -> mean in Ruby -

this question has answer here: what -> (stab) operator in ruby? [duplicate] 1 answer i've seen in spree commerce. go_to_state :confirm, if: ->(order) { order.confirmation_required? } so what'll symbol? it lambda literal . check example: > plus_one = ->(x){x+1} => #<proc:0x9fbaa00@(irb):3 (lambda)> > plus_one.call(3) => 4 a lambda literal constructor proc . proc way have block of code assigned variable. after this, can call block of code again, different arguments, many times wish. this how can pass "function" parameter in ruby. in many languages, pass reference function. in ruby, can pass proc object.

postgresql - Currency/monetary values -- How to store in a DB & transfer using JSON? -

what best practices storing currency/monetary values in db, processing them in server-side app, , sending them down browser via json api? i've figured 2 approaches, i'm not sure how weigh out pros & cons: store values integers in smallest monetary unit basically means database store monetary value in cents / paise / shillings / etc. the server side app map value regular integer variable. the json api represent value regular json number. the downside of approach have divide 100 before displaying monetary value user , multiply 100 before storing user input. possible gotchas: how define smallest monetary unit? on basis of 2 decimal points or four? there currency not have 100:1 ratio, i.e. 100 cents = 1 dollar. store values decimal/numeric fixed precision & scale the db stores monetary value decimal/numeric type fixed precision & scale, eg. numeric(10,2) the server-side app maps these special objects can preserve precision & scale across comput

ruby - Why are these routes missing from rake routes? -

rails 3.2.13 i trying follow deployment using screencast: http://railscasts.com/episodes/335-deploying-to-a-vps i have app works in development when pushed production capistrano 1 of controllers actions result in 404 pages. when run 'rake routes' notice controller's actions missing output: routes.rb wagmantechnology::application.routes.draw root :to => 'static_pages#home' resources :users resources :sessions, only: [:new, :create, :destroy] resources :tasks resources :assets match '/signup', to: 'users#new' match '/signin', to: 'sessions#new' match '/signout', to: 'sessions#destroy', via: :delete match 'tasks/mjhartman' => "tasks#mjhartman", :as => "tasks_mjhartman" match 'tasks/ejmcfadden' => "tasks#ejmcfadden", :as => "tasks_ejmcfadden" match 'tasks/ctkahler' => "tasks#ctkahler", :as

c# - Stored procedure is failing when one of the values contains specials characters -

i have problem special character. because when there ' character code fail. how can make work special characters using stored procedure below. internal bool addrecord() { string sql = "exec sqlinsert "; sql += "'" + _sqlcomputer + "', "; sql += "'" + _lastupdatedby + "', "; sql += "'" + datetime.now + "', "; sql += "'" + _softwarename + "' "; return sqldatabase.overig(sql); } like this sqlcommand cmd = new sqlcommand("sqlinsert", sqlcon); cmd.commandtype = commandtype.storedprocedure; cmd.parameters.add("@param1", sqldbtype.varchar, 25).value = _sqlcomputer ; cmd.parameters.add("@param2", sqldbtype.varchar, 50).value = _lastupdatedby ; cmd.parameters.add("@param3", sqldbtype.datetime).value = datetime.no

c++ - Boost error: not found boost_date_time-vc80-mt-1_41.dll -

i need run examples of software uses boost libraries vs2008, following error occurs: application can not started because not found boost_date_time-vc80-mt-1_41.dll i have set path variable: set path=c:\opt\boost-1_41_0\lib; what's causing error? thanks. you can follow link work boost libraries vs 2008: http://smolsky.net/index.php/2009/12/08/building-boost http://www.codeproject.com/articles/11597/building-boost-libraries-for-visual-studio hope resolve problem.

hibernate - Making Sum result As Distinct In mysql? -

here code select count( model.voter.voterid), sum( case when model.voter.age between :age18 , :age25 1 else 0 end) agecount , sum( case when model.voter.age between :age26 , :age35 1 else 0 end) agecount , sum( case when model.voter.age between :age36 , :age45 1 else 0 end) agecount , sum( case when model.voter.age between :age46 , :age60 1 else 0 end) agecount , sum( case when model.voter.age > :age60 1 else 0 end) agec user model model.voter.voterid in(:voterids) i passed 21 objects showing 22 result 22 when make select count( distict model.voter.voterid) 21 toal result still 22 can make sum condition distinct? how? select count(uservoterd0_.voter_id) col_0_0_, sum(case when voter1_.age between 18 , 25 1 else 0 end) col_1_0_, sum(case when voter1_.age between 26 , 35 1 else 0 end) col_2_0_, sum(case when voter1_.age between 36 , 45 1 else 0 end) col_3_0_, sum(case when voter1_.age between 46 , 60 1 else 0 end) col_4_0_, sum(case when vote

html - How to set up width percentage basis? -

i have following problem: i'd create html page #sidebar spans constant 27px , #content spans remaining part of screen. #content divided 2 areas splitting @ 40% - 60%. <html> <body> <div id="sidebar"> </div> <div id="content"> <div id="forty-percent"> </div> <div id="sixty-percent"> </div> </div> </body> </html> i have tried make following css: #sidebar{ width:27px; } #content{ position:absolute; padding-left:27px; width:100%; } but cannot divide content 40%-60%, because percentages calculated width of #content , not area inside. what doing wrong? can please help? update: the demo of not working version: http://jsbin.com/iseqon/1/edit ideally dashed boxes should side-by-side, inside blue box. this may suit more needs. if want have better control of #sidebar & #content vertical alignm

java - retriving stock quote with yahoo finance -

i have form button upon submit retrieve stock info yahoo finance api, , use display onto 3 textviews the url use http://download.finance.yahoo.com/d/quotes.csv?s=goog&f=sl1p2 and button event handler is url url; try { url = new url("http://download.finance.yahoo.com/d/quotes.csv?s=goog&f=sl1p2"); inputstream stream = url.openstream(); bufferedinputstream bis = new bufferedinputstream(stream); bytearraybuffer bab = new bytearraybuffer(50); int current = 0; while((current = bis.read()) != -1){ bab.append((byte) current); } string stocktxt = new string(bab.tobytearray()); string[] tokens = stocktxt.split(","); string stocksymbol = tokens[0]; string stockprice = tokens[1]; string stockchange = tokens

html - Twitter Bootstrap - mobile version only? -

i'm creating website client needs have mobile version. have site right want keep, want totally different mobile version - so, wondering if twitter bootstrap can chopped down, uses mobile aspect of framework? apologies if question doesn't make sense, if doesn't, feel free ask more questions , i'll try better explain myself. to summarize, want design mobile version of site using twitter bootstrap, mobile version - no desktop version needed because 1 exists on clients domain. as robin2k mentioned, 'bootstrap-responsive.css' / 'bootstrap-responsive.min.css' file make website work on mobile devices. if want chop down script decrease load times, best advice can give is: make sure use .min.css , .min.js files, they're considerably smaller try cloudflare , cache , compress bootstrap files make site load considerably faster

ruby on rails - How to approach aggregating actvities in feeds and then handling comments -

Image
i'm working on developing activity stream running club i'm working with. runners able see fun , things , friends have been on past few weeks. obie fernandez gave great talk on how approach using redis @ railsconf 2012 ( the videos on youtube here ) , i've adapted work within our app. having run few days, it's clear next challenge build aggregated items list now. take example following feed: here it's clear top story better collapse " shaun, alexander , ivo completed group run...", poses interesting question when thinking comments. comment associated individuals action of going on run. comment on ivo's attendance on run directed @ him. in collapsing story, i'm not entirely sure how handle commenting. comment gets distributed amongst people you're friends went on run, can see becoming messy when people have different sets of friends. comments instead link directly run itself, lose value of being able reference particular user&

iphone - Saving Twitter Streaming APIs results -

hi after lot of hassle managed work way around achieving , delimiting json returned twitter streaming apis. how store data returned [nsjsonserialization jsonobjectwithdata:options:error:] array in appending mode??? here codes call streaming api self.twitterconnection = [[nsurlconnection alloc] initwithrequest:signedreq delegate:self startimmediately: no]; and in delegate method (which did receive data method) nserror *parseerror = nil; self.datasource=[nsjsonserialization jsonobjectwithdata:[string datausingencoding:nsutf8stringencoding] options:nsjsonreadingallowfragments|nsjsonreadingmutablecontainers error:&parseerror]; want store nsjsonserialized output in static array(preferably in append mode) can pass table view display. how go it? thanks in advance edit `self.datasource1=[[nsmutablearray alloc]init]; nsstring *string = [[nsstring alloc] initwithdata:data encoding:nsasciistringencoding]; string = [nsstring stringwithformat:@"[%@]&quo

django - passing CSRF credentials as url parameters? -

how handle csrf credentials sent django url parameters? i ask because is, evidently, the way submit file upload via form in iframe . most online examples show pass csrf credentials headers, xhr.setrequestheader("x-csrftoken", csrftoken ); but not option iframe transport in ie/opera. i can use csrf_exempt , leaves site vulnerable. you create middleware takes csrf_token params , places on request before csrfviewmiddleware attempts validate class csrfgetparammiddleware(object): def process_request(self, request): request.meta['http_x_csrftoken'] = request.get.get('csrf_token') return none place middleware above csrfviewmiddleware middleware_classes = ( 'csrfgetparammiddleware', 'django.middleware.csrf.csrfviewmiddleware', ) this save validating or subclassing csrfviewmiddleware

post - Another way of doing GET -

i have seen on varias different websites when forum post or doing have different urls make in different directories, sure cannot make different directories each post. if @ website: https://oc.tc/forums/topics/5181a374ba6087261f000c59 the number @ end (5181a374ba6087261f000c59) changes each post , looks liek different directory sure not! could please explain how this? in advance! rob use apache .htaccess file handle redirect php script

how can I get the POST body when using apache mod_auth_form -

i'm trying use mod_auth_form using mode described in documentation "inline login body preservation". in documentation mention using mod_include or cgi errordocument in order generate login form, e.g.: errordocument 401 /cgi-bin/login.cgi the scenario if user wants post either non-authenticated page, or authenticated page timed-out session. the post hits target url, intercepted mod_auth_form, invokes errordocument 401, user enters credentials. on login form page, "special" hidden form variable httpd_body can added (and httpd_method) processed authentication handler create post body original target. the problem the login.cgi doesn't post data since (apparently) apache doesn't pass post data errordocument. alternative errordocument use directive authformloginrequiredlocation plain 302 redirect , of course post data lost. it seems feature httpd_body impossible use, impossible capture original post data. in case of get, 1 have parse referrer g

osx - How to open external application and run specific function of that application in Objective-c -

i new mac developer , want following things: i created simple application, , want click button in application open external application located on mac (like open disk utility) (i know how part using launchapplication) besides open application, want execute specific functions (like erase function in disk utility) automatically after open disk utility application. (i have no idea how this) possible show me demos new in mac ? thanks !! the external application should scriptable application. a scriptable application 1 makes operations , data available in response applescript messages, called apple events. apple event kind of interprocess message can specify complex operations , data. apple events make possible encapsulate high-level task in single package can passed across process boundaries, performed, , responded reply event. you can find more details in related apple documentation: cocoa scripting guide

asp.net - GridView to Excel using EPPlus -

Image
i'm trying create excel sheet using epplus's library. however, output excel file not relate cells of representing numbers. the code i'm using is: using (var pck = new excelpackage()) { excelworksheet ws = pck.workbook.worksheets.add(string.isnullorempty(spreadsheetname) ? "report" : spreadsheetname); ws.cells["b2"].loadfromdatatable(gridviewtable, true, officeopenxml.table.tablestyles.light1); (int = 1; <= gridviewtable.columns.count; i++) { ws.column(i).autofit(); } // ************** // header // ************** //prepare range column headers string cellrange = "b2:" + convert.tochar('b' + gridviewtable.columns.count - 1) + 2; //format header columns using (excelrange rng = ws.cells[cellrange]) { rng.style.wraptext = false; rng.style.horizontalalignment = excelhorizontalalignment.center; rng.style.font.bold = true; rng.style.

sql - MySQL add and subtract to a total sum, based on content of a second column -

is possible summation of column considers second columns content? what want second statement: select * thetable; +------------+-------------+ | type | value | +------------+-------------+ | plusitive | 11 | +------------+-------------+ | negative | 7 | +------------+-------------+ | negative | 3 | +------------+-------------+ select sum_based_on_whether_type_is_plusitive_or_negative(value) thetable; +----------------------------------------------------------------+ | sum_based_on_whether_type_is_plusitive_or_negative(value) | +----------------------------------------------------------------+ | 1 | +----------------------------------------------------------------+ so string 'plusitive' mean multiply value 1 , 'negative' mean multiply value -1 before adding sum. anyone know how it? know table layout not optimal task, altering not option. solution

iis 7 - IIS 7 smtp cant send email -

my application needs send out emails users, somehow can't make work. have installed smtp server , in iis have set smtp use localhost, port 25 without authentication. when try send email, allways getting error no connection made because target machine actively refused 127.0.0.1:25 when choose option store email in directory, works fine, problem isn't in app. why happen? thing thinking about, if need have port 25 opened or not? this happen if don't have smtp server listening on port 25.

sockets - PHP socket_recv() does not receive the entire response from the server. -

i'm trying receive http response using socket_recv. i'm having trouble responses larger 5000 bytes. stops receiving; without throwing errors; @ 7000 bytes though content-length says response larger (25000 bytes). i'm doing wrong or php sockets unstable? here's relevant part of code: while((socket_recv($this->socket, $buf, 1024, msg_waitall)) > 0){ $this->fullresponse .= $buf; } if(!$this->fullresponse){ $errno = socket_last_error(); $errmsg = socket_strerror($errno); echo $this->state = "{$errno} {$errmsg}"; return; } php sockets ignore content-length headers, because in http response section, , sockets work on lower level. trying http resources? use curl: http://php.net/manual/en/book.curl.php , or if need file that: file_get_contents("http: //www. example.com/ somefile.ext"), work allow_url_fopen must true. found socket_recv comments section on php.net: http://www.php.net/manua

osx - Troubleshooting 404 received by python script -

i have python script pings 12 pages on someexamplesite.com every 3 minutes. it's been working couple months today started receiving 404 errors 6 of pages every time runs. so tried going urls on pc script running on , load fine in chrome , safari. i've tried changing user agent string script using , didn't change anything. tried removing ['if-modified-since'] header didn't change anything. why server sending script 404 these 6 pages on same computer can load them in chrome , safari fine? (i made sure hard refresh in chrome , safari , still loaded) i'm using urllib2 make request. there multiple reasons this, such server rejecting request based on missing headers, or throttling. you try , record request header in chrome using http headers use python requests library adding browser headers in request. try either changing or removing headers see happening.

Issue with moving list items with jQuery -

i've been trying figure out day, haven't been making progress. want have 2 lists, , move list items between them double-clicking. can work if have 1 event "click", , other "dblclick", that's not want. if attach "dblclick" events in both methods, list items won't move , reorder in current list. here's jsfiddle demonstrates problem. have setup 1 event "click" , other "dblclick". if change parameter in live function "click" matches other handler you'll see issue i've been having. html <div id="orig"> <ul> <li class="original">one</li> <li class="original">two</li> <li class="original">three</li> </ul> </div> <div id="moved"> <ul> </ul> </div> css #orig { width: 40%; height: 300px; overflow: auto; float: left; border: 1

PHP array to string conversion -

i'm trying access php array. throwing me array string conversion error. this code if(isset($_post['category'])){ $category = array($_post['category']); if(sizeof($category) > 0){ foreach($category $key){ $categ = $categ.$key.', '; } } } do this.. if (isset($_post['category'])) { if (!is_array($_post['category'])) { $category = array($_post['category']); } else { $category = $_post['category']; } $categ = ''; foreach ($category $value) { if (!is_string($value)) { // anything, not autocast string! continue; } $categ .= $value . ', '; } }

c - How to set timeout in recvmmsg()? -

i build simple application using c used recvmmsg() , , fifth parameter passed timeout of type struct timespec . set timeout 5 seconds, it's not working, gets blocking infinity. the code following: struct timespec timeout; timeout.tv_sec = 5; timeout.tv_nsec = 0; result = recvmmsg(fd, datagrams, batch_size, 0, &timeout); as alternative, use setsockopt so_rcvtimeo option set timeout on socket. affect read operations performed on it.

filesystems - Files.move(Path, Path) in Java -

by reading this tutorial, have come across part not quite clear me. empty directories can moved. if directory not empty, move allowed when directory can moved without moving contents of directory. i thoroughly understand empty directories can moved. second part of quote seems me little confusing. able express same concept in other words? in advance. on unix systems, moving directory within same partition consists of renaming directory. in situation, method works when directory contains files. this next sentence in link posted, provides example when possible use move if directory not empty.

html - Aligning elements in an embedded mailchimp signup form -

Image
i trying embed signup form in page using code generated in mailchimp, results different trying obtain : signup button doesn't appear, width doesn't respect 960px css, , fonts close signup field. here code : <div id="mc_embed_signup" align="center"> <form action="http://pmwd.us5.list-manage.com/subscribe/post?u=228830d2daf74d54c2935571c&amp;id=f5f28b80a2" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>recevez toutes nos offres et promotions avec la newsletter! <div align="center"> <input type="email" value="" name="email" class="email" id="mce-email" placeholder="votre adresse e-mail" required></div> <div class="clear" align="center"> <input type="submit" value="je m'

Detecting JUnit "tests" that never assert anything -

we used have technical director liked contribute code , enthusiastic adding unit tests. unfortunately preferred style of test produce output screen , visually check result. given have large bank of tests, there tools or techniques use identify tests never assert? since that's 1 time operation would: scan test methods (easy, junit report xml) use ide or other search references assert.*, export result list of method awk/perl/excel results find mismatches edit: option references system.out or whatever preferred way output stuff was, tests won't have that.

data.table - Create a table for N, Min/Max, SD, Mean, and Median in R -

i'm new r , please bear me on basic question. have dataset, data, created using data.table package. created 200 random numbers between 0 , 1, did 10000 times, creating data table descriptive statistics each iteration. code looked this: rndm<-runif(200, min=0, max=1) reps <- data.table(x=runif(200*10000),iter=rep(1:200,each=10000)) data <- reps[,list(mean=mean(rndm),median=median(rndm),sd=sd(rndm),min=min(rndm), max=max(rndm)),by=iter] the data looks this: mean median sd min max 1 0.521 0.499 0.287 0.010 0.998 2 0.511 0.502 0.290 0.009 0.996 . ... ... etc. what want create table finds n, mean, median, standard deviation, minimum, , maximum of accumulated sample means (not of each column above). need output this: n mean median sd min max 10000 .502 .499 .280 .002 .999 how can accomplish this? you define function. approach allows make same table different variable. summaryf

ruby on rails - will_paginate can't convert Fixnum into Hash error -

everything pretty simple: makes me crazy ( controller: @p = product.paginate(:page => 1, :per_page => 10) view: <%= will_paginate @p %> error: showing d:/sites/stockox/app/views/catalog/index.html.erb line #1 raised: can't convert fixnum hash extracted source (around line #1): 1: <%= will_paginate @p %> trace: ctionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:589:in `merge!' actionpack (3.2.9) lib/action_dispatch/routing/route_set.rb:589:in `url_for' actionpack (3.2.9) lib/action_dispatch/routing/url_for.rb:148:in `url_for' actionpack (3.2.9) lib/action_view/helpers/url_helper.rb:107:in `url_for' will_paginate (3.0.4) lib/will_paginate/view_helpers/action_view.rb:115:in `url' will_paginate (3.0.4) lib/will_paginate/view_helpers/link_renderer.rb:93:in `link' will_paginate (3.0.4) lib/will_paginate/view_helpers/link_renderer.rb:45:in `page_number' will_paginate (3.0.4) lib/will_paginate/view_helpers/link_r

drag and drop of images using opengl c++ -

i want create game similare 1 http://www.sciencekids.co.nz/gamesactivities/movinggrowing.html 1-how move image according coordinates mouse? know how translate object drow polygon not images? 2- how check if in right plce , make stuck there used gltranslate image didn't move , , tried copypixl kept copying image every mouse hits . #include <windows.h> #include <gl/glut.h> #include <gl/glaux.h> #pragma comment(lib,"glaux.lib") aux_rgbimagerec *image ; glsizei wh = 600, ww = 800; //----------------------------------------------------------------------------------------------- void display(void){ image = new aux_rgbimagerec(); glpixelstorei(gl_unpack_alignment, 1); image = auxdibimageload(l"boy.bmp"); gldrawpixels(image->sizex, image->sizey, gl_rgb, gl_unsigned_byte,image->data); glflush(); } //----------------------------------------------------------------------------------------------- void mouse

python - Django session lost due to calling another server via iframe -

i have 2 development servers written python/django - 1 api server(it's not solely api server; has ui , etc.), , 1 demo app used serve data communicating api server. invoke demo app iframe in api server. after getting response demo app, original user session of api server lost(supposed have 2 sessions -- 1 user of api server, 1 communication between demo app , api server) . any idea happened? if running both on same server, session cookie might overwritten since both expect sessionid cookie. if sessionid doesn't exist new 1 generated, when access outer app, sessionid cookie, , gets passed iframe app doesn't recognize , generates new one. try giving each app it's own unique session_cookie_name

java - Center the content of a GridView -

Image
my gridview centered the content of not centered within it. here screen, light blue on bottom , right background color set of gridview . you can see content pushed top , left. content, game board, centered in middle of gridview , light blue background color surrounding sides equally. here xml: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/textfieldfu" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".mainactivity" > <gridview android:id="@+id/gridview" android:layout_margintop="0dp" and

php - Hybridauth in a new Window -

i've switched hybridauth on cakephp-site offer users social-logins. right now, main window loads social-page , redirects site. i'm wondering, if there way authentication in new window: user clicks on login button (main window) -> new window opens social-login page -> users loggs in -> window closes -> main window refreshes logged in user any idea how done? thanks in advance! i know question old, looking answer myself. found in "widget_authentication" example included hybridauth. look in index.php file inside widget folder. if don't want use widget, can still see how author opened either new window or intermediate plus new window, depending on provider.

java - OnDraw bug on listview -

i have created listview custom ondraw method. want make item of listview appear "focused/selected" draw red line on it. on android 2.3 phone when scroll listview created ondraw method appears under textviews listview contains. if touch listview without scrolling selecting item , release finger ondraw method works fine again. on android 4 phone enverything works ok. this annoying , makes application unusable on 2.3 android phone. know why happens? tell me if want me post sample code. i have had similar problem before , solved using dispatchdraw method. add following listview class: @override protected void dispatchdraw(canvas canvas) { //do drawing on under views children super.dispatchdraw(canvas); //do drawing on top of views children }

matlab - Find Overlapping Region between 3-Dimensional Shapes -

i'm plotting 2 separate 3-dimensional amorphous blobs overlap each other. have created blobs deforming unit circle (as can see in code provided below). question is: there easy way isolate overlapping region? need isolate overlapping region , color differently (as in turn region green, example) show overlap is. actual program has many shapes overlap, sake of simplicity, have produced following code illustrate trying do: % create sphere 100 points n = 100; % sphere grid points [x,y,z] = sphere(n); % x,y,z coordinates sphere num=size(x,1)*size(x,2); % total amount of x-coordinates (m*n) % loop through every x-coordinate , apply scaling if applicable k=1:num % loop through every coordinate value=x(k); % store original value of x(k) value if value<0 % compare value 0 x(k)=0.3*value; % if < 0, scale value end end % loop through every z-coordinate , apply scaling if applicable k=1:num % loop

python - change key to lower case for dict or OrderedDict -

following works dictionary, not ordereddict. od seems form infinite loop. can tell me why? if function input dict has return dict, if input ordereddict has return od. def key_lower(d): """returns d d or od od keys changed lower case """ k in d.iterkeys(): v = d.pop(k) if (type(k) == str) , (not k.islower()): k = k.lower() d[k] = v return d it forms infinite loop because of way ordered dictionaries add new members (to end) since using iterkeys , using generator. when assign d[k] = v adding new key/value end of dictionary. because using generator, continue generate keys continue adding them. you fix in few ways. 1 create new ordered dict previous. def key_lower(d): newdict = ordereddict() k, v in d.iteritems(): if (isinstance(k, (str, basestring))): k = k.lower() newdict[k] = v return newdict the other way not use generator , use keys ins

javascript - AngularJS - stopPropagation -

i'm struggling implement stoppropagation. i'm working multiple drop down menus. set when open menu, click anywhere outside of it, menu toggles off. ideally 1 menu should open @ time, when open 1 , click on another, first toggles off. perhaps i'm approaching in way wrong. if so, i'd appreciate nod in correct direction! thanks! here how i'm handling open , close of drop menus: <a ng-click="popout.isvisible = !popout.isvisible">drop menu #1</a> <ul ng-show="popout.isvisible"> <li>this text.</li> <li>this text.</li> <li>this text.</li> </ul> <a ng-click="popout.isvisible = !popout.isvisible">drop menu #2</a> <ul ng-show="popout.isvisible"> <li>this text.</li> <li>this text.</li> <li>this text.</li> </ul> here code found creates stopevent directive, isn't working quite wa

Changing User Permissions Via Rally API -

our workspace has created new project wish add of our 1,000+ users to. seems done via script interfacing api, rather making edits hand, since rally doesn't seem offer batch update function user permissions. question is, user permissions editable via api? i've made changes user records in past, not permissions. for context, i'm using pyral interface wsapi. thanks! you can batch script user permissions via wsapi. while it's not written in python, there open-source set of ruby scripting tools built this: https://github.com/rallytools/rally-user-management you might want check out - if nothing else, user management scripts provide hints how accomplish user updated/edits in pyral well. pyral mechanics differ in ruby rally_api used rally-user-management.

java - How to check that the value of column in particular row is not null and is also tab delimeted -

i parsing .csv file tab delimited. can see, there arrows in place of tabs; because have enabled "show characters" option in notepad. aaa->bbb->ccc->crlf agf->jui->kje->awecrlf bvg->qaz->plm->yhbcrlf now am using csv beans 0.7 parser parse .csv file , getting objects each columns if(f.getaaa() && f.getbbb() && f.getccc() && f.getddd()) // getting value of row1 agfjuikjeawe { } now .csv file received backend, it's possible value of column null, shown below aaa->bbb->ccc->crlf agf->->kje->awecrlf bvg->qaz->plm->yhbcrlf i putting condition check null values, but, can see, if value not there tab is, condition check correct if(f.getaaa()!=null && f.getbbb()!=null && f.getccc()!=null && f.getddd()!=null) { } i don't know library you're using, plain java use split(string) method of string in each of lines of csv file this: final strin

java - Why won't my HashSet allow me to add two of the same instance, if their equals() says they're false? -

the documentation hashset.add says adds specified element set if not present. more formally, adds specified element e set if set contains no element e2 such (e==null ? e2==null : e.equals(e2)). if set contains element, call leaves set unchanged , returns false. since code below return false e.equals(e2) , i'd expect let me add same instance twice. set contains instance once. can explain why? package com.sandbox; import java.util.hashset; import java.util.set; public class sandbox { public static void main(string[] args) { set<a> = new hashset<a>(); oneinstance = new a(); system.out.println(oneinstance.equals(oneinstance)); //this prints false as.add(oneinstance); as.add(oneinstance); system.out.println(as.size()); //this prints 1, i'd expect print 2 since system.out printed false } private static class { private integer key; @override public boolean equals(o

testing - Instruments: Can I run an iOS App using Instruments command line mode? -

i read question: can ui automation instrument run command line? that can test simulator builds instruments command line. cannot find info whether or not work on real device too. the command line seems need argument of full path app on device. used real devices? if so, how can path. or if has more detailed description how work real device, it'd great! it seems ok give local (mac) ipa path, make sure -w [device identifier] parameter correct. instruments try find app on device , run it.

c++ - llittle endianness of a structure in a structure -

given hypothetical structure struct outer { uint_16 x; struct inner{ uint_16 y; uint_16 z; } inner_struct; } outer_struct; and little endian machine, how bytes flipped, i.e. bytes outer_struct like? suppose x,y,z = ox1234; assume alignment of 2 bytes. i'm confused between 34 12 34 12 34 12 // x y z and, 34 12 12 34 12 34 // x flipped-little_endian_inner_struct the thing little endian flips order of bytes in builtin data types. compiler not free re-order attributes in structure, , endian-ness doesn't apply aggregate data structures (only components). you'll see 34 12 34 12 34 12 result in memory.

python - Accepting only integers for TIC TAC TOE -

here's tic tac toe game have created using python.. import os os.system('cls') = 0 #exiter def exithoja(): import sys raw_input sys.exit() #displays win or draw def diswin(name,grid): = checkwin(grid) os.system('cls') viewgrid(grid) if ==1: print name, " has won game !!" elif == -1: print "this match draw !!" exithoja() #checking win or draw function def checkwin(grid): = 0 result = 0 extra=0 in range (1,9): #this part checks full grid. if (grid[i] == 'x' or grid[i]=='o'): += 1 if (grid[1] == grid[2] , grid[2] == grid[3]): result = 1 #this part checks win. elif(grid[4] == grid[5] , grid[5] == grid[6]): result = 1 elif(grid[7] == grid[8] , grid[8] == grid[9]): result = 1 elif(grid[1] == grid[4] , grid[4] == grid[7]): result =