Posts

Showing posts from June, 2013

java - global object for returning spring singletons -

is there wrong design point of view having global object returns singletons spring context? i started work @ new place, , daos accessed via global object called daoutils, each dao gets singleton dao bean spring context. if want save purchase order, example, say daoutils.getpurchaseorderdao().savepurchaseorder(po); or that. i've been used injecting daos required each class needs them, , shocked me little. there wrong design point of view, , if can explain why bad idea? i can see makes unit testing difficult, because there's no way stop code calling actual daoutils class..? guess described problem caused tight coupling? this bad design pattern since cannot substitute daoutils else e.g. testing purposes. spring uses dependency injection , that's best way retrieve dao instance.

oop - How to catch any method called on an object in python? -

i'm looking pythonic solution on how store method called on object right inside object. because in python, if want catch example abs() method, overload operator like: catcher(object): def __abs__(self): self.function = abs c = catcher() abs(c) # c.function stores 'abs' called on c if want catch function, have other attribute in it, example pow() , i'm going use this: catcher(object): def __pow__(self, value): self.function = pow self.value = value c = catcher() c ** 2 # c.function stores 'pow', , c.value stores '2' now, i'm looking general solution, catch , store kind of function called on catcher , without implementing overloads, , other cases. , can see, want store values ( maybe in list, if there more 1 of them? ) attributes of method. thanks in advance! a metaclass won't here; although special methods looked on type of current object (so class instances), __getattribute__ or __get

python - Request an url not allowed for get status code from the response -

i'm looking solution making request on not allowed domain checking outbound links. but function "parse_outboundlinks" never called. i must modify allowed domain ? thanks help my code : name = "myspider" allowed_domains = ["monsite.fr"] start_urls = ["http://www.monsite.fr/"] rules = [rule(sgmllinkextractor(allow=()),follow='true',callback='parse_item')] def parse_item(self, response): xlink = sgmllinkextractor(deny_domains=(self.allowed_domains[0])) link in xlink.extract_links(response): request(link.url, callback=self.parse_outboundlinks) def parse_outboundlinks(self, response): print response.status parse function called if yield specified. change request(link.url, callback=self.parse_outboundlinks) yield request(link.url, callback=self.parse_outboundlinks) similar problem in other threads. scrapy's request function not being calle

combobox - Vaadin - Multiple filters for Tree table -

i'm doing project in vaadin 7. in need implement filters treet able. i quiet successful in applying filters 1 value. mean, have 4 comboboxex 'c1', 'c2', 'c3', 'c4' , treetable 'tt'. load values 'tt' using hierarchicalcontainer 'hc'. i implemented filters comboboxes using valuechangelistener & addcontainerfilter(). when select value 'c1' filters , displays rows accordingly in 'tt'. then, when select value 'c2'. ignores filter set 'c1' , filters value based on value set @ 'c2' , same in rest of filters. all need is, when set value in both comboboxex 'c1' & 'c2' tree table 'tt' should display rows based on values in both 'c1' & 'c2'. filterlogic = c1 , c2 (correct) not filterlogic = c1 or c2 (wrong) i tried lot , studied lot of codes. but, can't done. appreciated.! i did same job in project using vaadin 6,

objective c - Why is my hitTest in UIView not identifying CALayer touched -

i have uiview in 2 calayers added [self.layer addsublayer:sublayera]; //... giving following view hierarchy: uiview subclass - backing layer (provided uiview) - sublayera - sublayerb if override touchesbegan in view controller presents uiview correctly identifies calayer touched: // in view controller #import <quartzcore/quartzcore.h> //..... - (void)touchesbegan:(nsset *)touches withevent:(uievent *)event { uitouch *touch = [touches anyobject]; cgpoint touchpoint = [touch locationinview:self.view]; calayer *touchedlayer = [self.view.layer.presentationlayer hittest:touchpoint]; // returns copy of touchedlayer calayer *actuallayer = [touchedlayer modellayer]; // returns actual calayer touched nslog (@"touchpoint: %@", nsstringfromcgpoint(touchpoint)); nslog (@"touchedlayer: %@", touchedlayer); nslog (@"actuallayer: %@", actuallayer); } however , if override touchesbeg

java - native generator class in hibernate -

i have part of hibernate mapping xml file, , looking example native mean. <hibernate-mapping> <class name="com.hib.task" table="tasks"> <id name="id" type="int" column="id" > <generator class="native"/> </id> i know it's related unique identifier property, have example. sorry newbie question, i'm new hibernate , programming in general :) thank you! native means generator use identity or sequence columns according current database support. native : generation strategy default. chooses primary key generation strategy default database in question, quite typically identity, although might table or sequence depending upon how database configured. native strategy typically recommended, makes code , applications portable. for example: in mysql if have primary key column auto_increment, db updated using strategy

Unterminated string constant in Google Map API using PHP -

i have problem unterminated string constant. here code in php: 'html' => '<div><table><td><tr><img src="' . "http://www.simbawave.com/_lib/file/img/hotel/$folderhotel/$namafile" . '"width="200" height="200" /></tr><tr><p><b>'.$hotel."</b></p></tr></td><td>$alamat</td></table></div>", and here html source (result, not all, long) markers[8] = new google.maps.marker({ icon: "http://www.simbawave.com/mapblueicon/villa.png", title: "bali dynasty resort", position: new google.maps.latlng(-8.747509, 115.16764), map: map }); infos[8] = new google.maps.infowindow({ content: "<div><table><td><tr><img src=\"http://www.simbawave.com/_lib/file/img/hotel/ho-00009/depan2web.jpg\"width=\"200\" height=\"200\" />

javascript - Autoscrolling after page refresh doesn't work -

i'm trying automatic scrolling left side of horizontal website after refresh (like pressing f5). trying scrollleft() , got nothing. window.scrollto(0,0) working button this: function scrollwindow() { window.scrollto(0,0); } and <input type="button" onclick="scrollwindow()" value="scroll" /> this works, doesn't $(document).ready(function()); : <script> $(document).ready(scrollwindow()); </script> i found in question top answer: $(document).ready(function(){ $(this).scrolltop(0); }); but didn't work me. can me problem? try this: $(document).ready(function(){ scrollwindow(); });

php - Getting posts from your friends -

Image
what trying accomplish fill news feed full of posts friends of $username session username. the problem have if user not following or not being followed (is not in follow table) not see own posts in news feed. everything else seems work fine. user can see post , people follows post. user can see posts if following or being followed. user cannot see own post if not following nor being followed. select p.* posts p join follow f on p.by in (f.person_being_followed, '$username') '{$username}' in (f.person_following, p.by) order p.id desc this code page echo information <? $get_posts = mysql_query("select p.* posts p join follow f on p.by in (f.person_being_followed, '$username') ### ,$username' shows logged users posts, if in follow table ### '{$username}' in (f.person_following, p.by) ## p.by shows person posted logged in, if in follow table ## order p.id desc") or die(mysql_error()); while ($post_row = mysql

plsql - How to limit the data entered within a stored procedure? -

i have stored procedure prompts user input , stores/updates table. issue when trying add limitations when entering number not work planned. here table: drop table incident; create table incident (icd_id varchar2 (8) not null primary key, plr_id varchar2 (11), m_id varchar2 (10), pp_id varchar2 (10), i_points number (8)); insert incident values ('icd01', 'che01', 'm01', 'pp01', null); insert incident values ('icd02', 'che03', 'm07', 'pp02', null); insert incident values ('icd03', 'che03', 'm04', 'pp03', null); insert incident values ('icd04', 'kln04', 'm07', 'pp02', null); insert incident values ('icd05', 'che01', 'm04', 'pp03', null); when prompted, enter icd_id (for example 'icd03') *

Sending/Passing local variable from one procedure to another in Delphi 7? -

how can send/passing local variable in procedure procedure in delphi? procedure tform1.button1click(sender: tobject); var a,b:integer; c: array [o..3] smallint; begin a:=1; b:=2; end; i want send 1 or more local variable(a,b,c) has value procedure use them there like: procedure tform1.button2click(sender: tobject); var d:integer; begin d:=a*b; end; i want send 1 or more local variable(a,b,c) has value procedure use them there. this shows misunderstanding lifetime of local variables. local variables have scope duration of function owns them. since 2 event handlers have disjoint lifetimes, local variables never in existence simultaneously. so when "that has value", mistaken. local variables exist when button1click executing not exist when button2click executing. you'd need variables members of class rather local variables. way variables' lifetimes span separate execution of event handlers. type tform1 = class(tform) .... pr

codeigniter - Sql statement with multi ANDs querying the same column -

Image
i don't know if title of post appropriate. have following table and array in php items, parsed_array . want find supermarketids have items of parsed_array . for example, if parsed_array contains [111,121,131] want result 21 id of supermarket contains these items. i tried that: $this->db->select('supermarketid'); $this->db->from('productinsupermarket'); ($i=0; $i<sizeof($parsed_array); $i++) { $this->db->where('itemid', $parsed_array[$i]); } $query = $this->db->get(); return $query->result_array(); if there 1 item in parsed_array result correct because above equal to select supermarketid productinsupermarket itemid=parsed_array[0]; but if there more 1 items, lets two, equal select supermarketid productinsupermarket itemid=parsed_array[0] , itemid=parsed_array[1]; which of course return empty table. idea how can solved? you can use where_in in codeigniter below, if(count($pa

android - get week number of a date -

select strftime('%w', day) week, sum(amount) mytable group week order week desc this query useful amount week. 1 gives week number in year, may know how week number in month. have googled lot. results related week number in year not in month. thanks in advance. you can manipulate strftime() answer. apply strftime() on given date , first date of given dates month , subtract them week number of month eg select strftime('%w','2013-05-04')-strftime('%w','2013-05-01') +1; sql fiddle demo

asterisk - Call duration during the call via AMI -

how can call duration during call via ami? status() or coreshowchannels() seconds needs after answering call you have following options: 1)you can collect "link" events , store info calls start in application. ami not designed got call info. 1 correct way. 2) issue command http://www.voip-info.org/wiki/view/asterisk+manager+api+action+command "core show channel channel_name_here" have info duration 3)other option variable cdr(billsec) http://www.voip-info.org/wiki/view/asterisk+manager+api+action+getvar

replace - Instagram API: $value->location->latitude outputs comma separated value, whereas Google Maps accepts dot -

$value->location->latitude , $value->location->longitude output respectively 41,90693866 , 12,414128943. have link points to href="http://maps.google.com/maps?q='.htmlentities($value->location->latitude).',+'.htmlentities($value->location->longitude).'" problem google maps accepts values 41.90693866 (notice dot instead of comma), doesn't work 41,90693866, 12,414128943 input (it 41.90693866, 12.414128943). how can output latitude/longitude comma instead of dot? the json data see instagram api uses periods , not commas lat/lng data. sure in code not transforming formatting? check code this.

jQuery - preventDefault() loading page -

i thought had stuck on last thing. i have updated jsfiddle here - http://jsfiddle.net/q73nd/8/ i want to load thumbnails. start slideshow. stop , start buttons stop , start slideshow. click thumbnail , slideshow loads image. i'm stuck on last point - if click thumbnail loads image in new window. $('thumbs a').click(function(e){ bigimg.attr('src',$(this).attr('href')); e.preventdefault(); }) why load image in new window. you missed # target div id thumbs : $('#thumbs a').click(function(e){ bigimg.attr('src',$(this).attr('href')); e.preventdefault(); }) updated fiddle

How to scale points in R plot? -

Image
i have 40 pairs of birds each male , female scored colour. colour score categorical variable (range of 1 9). plot frequency of number of males , female pairs colour combinations. have created 'table' number of each combination (1/1, 1/2, 1/3, ... 9/7, 9/8, 9/9), converted vector called 'colour_count'. use 'colour_count' 'cex' parameter in 'plot' scale size of each combination of colours. not work because of order data read table. how create vector frequency of each colour combination scale plot points? see data , code below: ## dataset pairs of males , females , colour classes pair_colours <- structure(list(male = c(7, 6, 4, 6, 8, 8, 5, 6, 6, 8, 6, 6, 5, 7, 9, 5, 8, 7, 5, 5, 4, 6, 7, 7, 3, 6, 5, 4, 7, 4, 3, 9, 4, 4, 4, 4, 9, 6, 6, 6), female = c(9, 8, 8, 9, 3, 6, 8, 5, 8, 9, 7, 3, 6, 5, 8, 9, 7, 3, 6, 4, 4, 4, 8, 8, 6, 7, 4, 2, 8, 9, 5, 6, 8, 8, 4, 4, 5, 9, 7, 8)), .names = c("male", "female"), class = "dat

r - Error when writing list to text file -

i'm trying write r package bibtex entries text file, error: pkgs <- unique(installed.packages()[,1]) bibs <- lapply(pkgs, function(x) try(citation(x))) lapply(bibs, write, "bibs.txt", append=true, ncolumns=1000) error in cat(list(...), file, sep, fill, labels, append) : argument 1 (type 'list') cannot handled 'cat' what doing wrong? the output of citation list error makes sense. can use tobibtex format more handled write pkgs <- unique(installed.packages()[,1]) bibs <- lapply(pkgs, function(x) try(tobibtex(citation(x)))) lapply(bibs, write, "bibs.txt", append=true, ncolumns=1000)

php - facebook js signed_request -

i using facebook js allow user's login. login part on js works want catch signed_request facebook sends (with use of server-side language such php or java). reading documentation ( https://developers.facebook.com/docs/facebook-login/using-login-with-games/ ) on how catch signed_requests not informative. state "the signed request sent via http post url set canvas url", went exact url (mywebsitenamehere.com/login.php stated canvas url , added code catch post['signed_request'] (i assume it, can't find anywhere on facebook tells name of variable). problem nothing happens, added code in login.php page redirect website if post variable set testing purposes, , nothing happens. appreciate concrete example of supposed do. searching internet able find examples, people using php login, using js. it´s in text of link posted: "when run game on facebook.com, can access signed request parameter" so, signed_request available in canvas apps

ios - Saving images in core data using app's default global queue leads to freeze? -

i working on application app fetches images facebook. using core data save image. use dispatch_asyc function save image in core data. use dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_background, 0) to save image main thread doesn't block. but times observed app freezes , doesn't respond. use same way of saving image core data @ different places in app, if user goes signed user profile, app saves album photos in same way. if user goes full screen of image, starts fetching of comments, likes , saves in same way. if use private queue , use same saving app doesn't freeze. since using global queue @ many places in app, reason freeze of app? thanks. you should read core data programming guide section concurrency here . sounds you're accessing managedobjectcontext outside of thread created illegal. better off using child context performblock perform task. this: nsmanagedobjectcontext *context = [[nsmanagedobjectcontext alloc] in

css - margins and alignment in input element in bootstrap -

Image
i having trouble getting input element , button align correctly. looks like: this comes following code: <div class="row"> <div class="offset1 span6"> <input type="text" class="l_input" placeholder="enter city"></input> </div> <div class="span3"> <button class="l_button btn btn-primary" type="button">search</button> </div> </div> i want input height same button, not case currently. assume because of margins/padding, tried set them 0 px in css: has no impact. .l_input { padding: 0px; margin: 0px; } what need height of input aligned height of search button? you right, margins , padding in other element. try: .l_input, .l_button { padding: 0px; margin: 0px; } updated demo

machine learning - Scikit-learn: BernoulliNB, v0.10 vs v0.13: very different results -

this of follow-up this thread , getting erroneous results gaussiannb classifier, turned out because had scikit-learn v0.10 on linux vm doing experiments on. ended using bernoulli , multinomial nb classifiers instead, when (finally) got scipy installed on macbook, scikit-learn version grabbed 0.13, latest of writing. presented new problem: on v0.10, getting on 90% accuracy bernoullinb classifier on 1 of feature sets, notable improvement i've gotten far. on v0.13, it's coming in @ 67% using same code does know changed between versions? had @ repo history didn't see account kind of change in accuracy. since i'm getting results bernoullinb v0.10, i'd use them, i'm hesitant without little more understanding of conflicting results between versions. i've tried setting (newer) class_prior property didn't change results 0.13. edit: short of coming worked example (which will, well, work on), 0.13 outcomes heavily biased, not expect bayesian cl

making exe form HTML and Javascript -

i wondering have php based server side stuff accepts ajax requests , sends json js. , have html , js based "client" create exe(windows aplication) same "client" in browser without browser. preferably somehow grab html , js , "compile it" regural client still send out ajax calls , procesing json data. edit: clarify things: server(on webserver) php procesing incoming ajax calls , diplaing json result. client(what want convertt exe) html , js(jquery) page(application). i want user have option 2 dowload client windows he/she dont have use browser. i don't think can make desktop application markup languages. newbie in stuff think need develop gui in programming language java example swing docs.oracle.com/javase/tutorial/uiswing/ mimic apearance of webpage. connect server socket programming.

sql server 2008 - Trouble with the IN keyword in transact sql -

this question has answer here: parameterize sql in clause 38 answers sql server - in clause declared variable [duplicate] 8 answers i creating script querying table using in keyword. when type data inside in clause, query performs should. when create variable exact same data in , use variable inside in clause, not. ideas??? here query works select * scpcommandeventlog messageid = 3 , param1 in('11416407','11416410','11416413','11416417', '11416419','11416421','11416423','11416427', '11416432','11416433','11416434','11416435', '11416438','11416443','11416446','11416448', '1

python - how to access a nested comprehensioned-list -

i have working solution creating list of random numbers, count occurrencies, , put result in dictionary looks following: random_ints = [random.randint(0,4) _ in range(6)] dic = {x:random_ints.count(x) x in set(random_ints)]) so for, [0,2,1,2,1,4] {0: 1, 1: 2, 2: 2, 4:1} i wondering if possible express in 1 liner, preferably without use of library function - want see what's possible python :) when try integrate 2 lines in 1 dont know howto express 2 references same comprehensioned list of random_ints ..??? expected like: dic = {x:random_ints.count(x) x in set([random.randint(0,4) _ in range(6)] random_ints)) which of course not work... i looked (nested) list comprehensions here on so, not apply solutions found problem. thanks, s. there couple ways achieve that, none of them want. can't simple binding of name fixed value inside list/dict comprehension. if random_ints not depend on of iteration variables needed dic , it's better way did it, , crea

Delphi XE3 EXE file size 25 times larger than Dephi 7 -

Image
as test decided create simple "hello world" app in delphi using delphi 4, 5, 6, 7, 2005, 2010 , xe3. app nothing more tform, tbutton onclick event calls showmessage('hello world'). below results of each final exe debugging turned off: can explain why xe3 version 26 times larger average of previous versions of delphi? here project settings xe3: you may have done compile after changing 'release' configuration. try rebuild (not recompile). activate release configuration on executable, , perhaps smaller file size. for me (delphi xe2), size reported windows same app (release configuration) is: 1.52 mb (1,600,512 bytes)

android - Box2d Collision Detection with Arrays -

i'm developing in andengine have completed game, unfortunately, suffers low fps due fact checking .collideswith lot in update loop. understand problem, , have been trying change using box2d bodies , such in theory, need, can't grasp around it! basically, have 4 arrays; 1 cars, 3 enemies. cars drive left right, , if make contact of these enemies, it's speed changes depending. have allocate body each 1 of cars , enemies when loading arrays? , how check? run loop, , 'isbodycontacted(carbody, icebergbody);' in update look? it's bit cofusing! for reference, loading car: private void loadcar() { (int = 0; < rmanager.getinstance().cararray.length; i++) { rmanager.getinstance().cararray[i] = new car(new sprite( rmanager.getinstance().spawnpoint[i].getspawnpos().x, rmanager.getinstance().spawnpoint[i].getspawnpos().y, rm

android - Zoom GoogleMap to my location -

i have sherlockfragmentactivity displays googlemap using google maps android api v2 . want map zoom current location fragment launches. couldn't find such method in documentation . how achieve this? private googlemap mmap; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.ui_settings_demo); setupmapifneeded(); } @override protected void onresume() { super.onresume(); setupmapifneeded(); } private void setupmapifneeded() { // null check confirm have not instantiated map. if (mmap == null) { // try obtain map supportmapfragment. mmap = ((supportmapfragment) getsupportfragmentmanager() .findfragmentbyid(r.id.map)) .getmap(); if (mmap != null) { setupmap(); } } } private void setupmap() { mmap.setmylocationenabled(true); //how zoom current location? } like this camerapositio

java - Difference between procedures/functions and objects in Oracle PL/SQL -

i stumbled upon concept of objects in pl/sql , started pondering on difference between oracle pl/sql procedures/functions , objects. need know functional difference. ps: familiar java. function allows value return return statement. procedure has no such return value. possible return values declaring parameter out rather default in . there in out . object in oracle other concept , has nothing procedure , function , more class definition know java. though comparison bit weak. there useful documentation on oracle objects, e.g. link http://docs.oracle.com/cd/b28359_01/appdev.111/b28425/obj_types.htm package though have not asked it, should mentioned. oracle package contains collection of functions , procedures (and more). package consists of declaration , package body. defined in package declaration can accessed outside rest private.

c# - Free IDE for Windows 8 app development -

i student hobby app creation. therefore don't have hundreds spend on vs2012. looking ide create windows 8 applications. if has heard of 1 appreciated. prefer using vb.net although if find 1 c\c# happy. advice appreciated. thanks. use express version of visual studio http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products

jquery - In hidden part of div :hover still works and is visible -

i have simple coding: http://jsfiddle.net/8ama4/20/ (the stupid colors indication ;)) basically work, glitch don't know how fix. in div there picture "pages", slide side press buttons , 1 visible @ time. when hover visible picture fading in appears. problem fading in on hover appears in supposed-to-be-hidden part of div too. (you can see in jsfiddle example, if move mouse right side of man div). can hep me solution? should change either of 2 "effect" (the hover , sliding)? html: <div class="tab-box"> <div class="tabs"> <div class="tab">1</div> <div class="tab">2</div> <div class="tab">3</div> </div> <div class="items"> <div class="item" style="background: red;"> <a href="#"><span class="rollover"></span><img class="thumbnail"

how to use perl references correctly -

i have noob-ish question here regarding refs, though still confounding me @ least... in code example below, i'm trying create hash of arrays: #!/usr/bin/perl use strict; use warnings; use 5.010; use data::dumper; $data::dumper::sortkeys = 1; $data::dumper::terse = 1; $data::dumper::quotekeys = 0; @a1 = ( 'a1', 1, 1, 1 ); @a2 = ( 'a2', 2, 2, 2 ); $a1_ref = \@a1; $a2_ref = \@a2; @a = ( $a1_ref, $a2_ref ); %h = (); $i ( 1 .. 2 ) { $h{"$i"} = \@a; } dumper \%h; the dumper output is { '1' => [ [ 'a1', 1, 1, 1 ], [ 'a2', 2, 2, 2 ] ], '2' => $var1->{'1'} } the question here is: why $h{'2'} refe

jquery - Prevent 'caret' jumping on focus -

so, i'm trying replicate html5 'placeholder' attribute functionality. one thing i'm stuck on is, upon focus of element, caret appearing @ start of input. as stands, caret appears in position user clicks , jumps start when use jquery move it. look here: http://www.dollmode.com/test - click on "desired username" field , see mean. any workarounds? edit 1 idea had placing empty input on top of either text or input. way, when user typed empty input, text in background wouldn't select-able , hidden upon entering text empty input. there cross-browser (back ie6) doing this? 1.you have remove text inside textbox when gets focused $("input[type=text]").focus(function(){ $(this).val(''); }); 2.then when focus lost have check whether user filled textbox if textbox empty should assign placeholder value $("input[type=text]").blur(function(){ if($(this).val()=='') $(this).val()= $(thi

xcode - How do you make a simple Cocoa/Objective-C text editor -

i want know how make very, simple text editor xcode. want able save, load, , write text files. doing out of curiosity. here's complete project textedit text editor comes os x: https://developer.apple.com/library/mac/samplecode/textedit/introduction/intro.html#//apple_ref/doc/uid/dts40011741 if want start scratch , yourself, take @ nstextfield class, or saving, take @ nsarchiver. pretty have create new project, add nstextfield window, , write code load , save file. get book cocoa programming mac os x aaron hillegass. show how started, or check out developer.apple.com. lots of documentation there.

ajax - Calling multiple Jquery plot using tab -

i have 2 jquery plot real-time graphs, once first loaded, if click on "graph 2" tab, second graph called but, not being loaded in div first graph loaded. help? jquery <script> var page = baseurl+'/ajaxcall.php'; function get_data(vara,div) { $(div).css("display","block"); $.post(page, { posta : vara }, function(data) { $(div).html(data); },'text'); } </script> html <div class="toolbar"> <a href="javascript:void(0)" onclick="get_data('callgraph1','#divid')">graph 1</a> <a href="javascript:void(0)" onclick="get_data('callgraph2','#divid')">graph 2</a> </div> <div id="divid"></div>

not able to persist username using twitter omni-auth in ruby on rails application -

i trying implement omniauth twitter authenticate user using twitter in application. when try "login twitter", takes me "authorize app" twitter page. when click "authorize app" button, tries redirect me app , shows me as logged user in twitter.( logged in twitter in tab of browser). display me registration page without persisting username. following ryan http://railscasts.com/episodes/235-devise-and-omniauth-revised devise omniauth. how persist username when log in twitter. please suggest me. i have attached application code on below link. app code please let me know if need more code pasted. i had same problem. devise looking email. can't persisted without. you can : - change email field null=>true using migration - generate dummy email when provider twitter

javascript - How do you store an image with other data from a form? -

i'm trying use firebase store list of events. each event has typical info name, date, location, , image. tried using file api store dataurl rest of data in reference, can't seem image under same key other data. how add upload image via form other data under name id in firebase. this handler change event on file. function onfilechanged(theevt) { var thefile = theevt.target.files[0]; // check see if text if (!thefile.type.match("image.*")) { return; } var reader = new filereader(); reader.onload = function (evt) { var resultdata = evt.target.result; var file = thefile.name.replace(/\.[^\.]+$/, ''); nameref = new firebase('https://firebaseio.com/events/' + file); var f = nameref.child('image'); f.set(resultdata); } reader.readasdataurl(thefile); } that snippet should work, long file represented data url (base64 encoded). here's example of how

php - how to change image URL for each image of 4 products on each row? -

i have dynamic product table 4 product on each row. i'm using css , not html table. i'm looking way change 4 images on each row different urls , same on other rows. the reason use 4 sub domains cdn allow faster downloads. is possible? i'm still junior need assistance. below code , image section <img class="lazy" src="/images/loading.gif" data-original="<?=resize($i['image'],$settings)?>" width="170" height="250" alt="" /> notice i'm using data-original i'm using lazyload, $settings used creating cached version of image. here's code... if($viewing=='retailer'){ if($i['category']!=$categorycheck){?> <div id="sub-sub"><?=$i['category_name']?></div> <? $categorycheck = $i['category']; $y=1; }?><? } ?> <div class="package"<?=$y==4?' style="margin-right:0;"&

python - PTVS or something similar in visual studio 2012 express -desktop -

hey have visual studio 2012 express desktop , tried installing ptvs 2.0 , said couldn't find visual studio 11, needs arent high wanna use vs ide python, how install it? vs express editions don't allow plug-ins installed (such ptvs). however, can create own python express by: install integrated shell + isolated shell install ptvs details: https://pytools.codeplex.com/wikipage?title=ptvs%20installation

ios - Referring to buttons by their tag but not in its action -

so, i'm new this. anyway, have 36 buttons connected 1 action references them tag . later in application, when button not 1 36 pressed, want disable 36 buttons. possible? yes, possible. use enabled property. since have tags, can reference each 1 [self.view viewwithtag:tag] so example let's tags 1 thru 36. then: for (int = 1; < 37; i++) [[self.view viewwithtag:i] setenabled:no]; if want omit particular button being disabled you'll need modify logic. i'm showing general idea.

php - PDO not inserting into database but has correct values -

i trying create basic blog , i've followed syntax of previous project insert mysql database not add. echo'd values see if passing correctly , when check database nothing added. there wrong can see code? thank in advance answers regardless if able or not. edit: checked database , working correctly , named, connect.php works login since information same should work here. edit2: database table follows postid int(10) auto_increment title text author text date date content text tag1 text tag2 text <?php // make sure user logged in session_name('blog'); session_start(); if (empty($_session['username'])) { header("location: loginhome.php"); exit; } // connect database , add message include("connect.php"); $one = $_post['title']; $two = $_post['author']; $three = $_post['content']; $four = $_post['cat1']; $five = $_post['cat2']; echo $two; $add_message_que

c - Why am I getting the error "Break statement not within loop or or switch."? -

this simple program asks use's age , based on displays message.at end if it,the user asked if repeat whole thing again.but getting error break statement not within loop or switch when compile it. mean , how correct it? #include <stdio.h> #include <string.h> static int prompt_continue (const char *prompt) { printf("%s", prompt); char answer[5]; if (scanf("%1s", answer) != 1) return 0; if (answer[0] == 'y' || answer[0] == 'y') { int c; while ((c = getchar()) != eof && c != '\n') ; return 1; } return 0; } int main(void) { /*creates simple program using if else example. */ int age; while (printf("welcome, program designed if else statements.\n")); printf("please enter age.\n"); scanf (" %d", &age); /*enters age.*/ if (age < 18){ printf("you young!\n"); } else if (age > 18){

c# - Datagrid ValueConverter based on Min or Max Value -

i'm trying change colour of datagrid cell based on if it's min or max value in observablecollection value of cell part of. now have following datagrid , style template: <grid itemssource="{binding mydata.myobscollection}"> <datagrid.resources> <style targettype="{x:type datagridcell}"> <setter property="foreground"> <setter.value> <multibinding converter="{staticresource myvalidconverter}"> <binding path="mdtime" /> //myobscollection doesn't work here <binding path="mdisvalid" /> </multibinding> </setter.value> </setter> </style>... the collection, simplified, consists of following: public class myclass : inotifypropertychanged { ... public observablecollection<mydata> myobscollection { get; set

java - JFreeChart CombinedXYPlot with Time Series -

i able plot date against price, date on x-axis , price shown in y-axis. later want plot volume-date graph in same chart, i've used combinedrangexyplot purpose. common data here both graphs date. ideally want graphs displayed 1 below other (horizontal orientation) common x-axis being date , each having own y-axis, 1 being price , other being volume but issue facing is, when orientation horizontal dates displayed in y-axis graphs appeared tilted @ 90 degree angle. if orientation vertical, x-axis consists of dates , y-axis handles both price , volume. since price movement in 100's , volume movement in millions, not able spot price movements in graph. ideally want x-axis common both graphs containing dates when orientation horizontal, require 2 y-axis values 1 each graph. final xyplot priceplot = new xyplot(dataset, new dateaxis("date"), null, new standardxyitemrenderer()); numberaxis numberaxis = (numberaxis)priceplot.getrangeaxis(); numberaxis.setr

PHP regex find and replace url attributes in DOM -

currently have following code: //loop here foreach ($doc['a'] $link) { $href = pq($link)->attr('href'); if (preg_match($url,$href)) { //delete matched string , append custom url href attr } else { //prepend custom url href attr } } //end loop basically i've fetched vial curl external page. need append own custom url each href link in dom. need check via regex if each href attr has base url e.g. www.domain.com/mainpage.html/subpage.html if yes, replace www.domain.com part custom url. if not, append custom url relative url. my question is, regex syntax should use , php function? preg_replace() proper function this? cheers you should use internals opposed regex whenever possible, because authors of functions have considered edge cases (or read really long rfc urls details of cases). case, use parse_url() , http_build_