Posts

Showing posts from August, 2015

java - QueryDSL - Sum where a join is involed -

given following classes: class user { @onetomany set<transaction> transactions } class transaction { bigdecimal money; } i'm stumped how perform aggregate, functions don't appear available on following query: quser $user = quser.user; qtransaction $transaction = qtransaction.transaction; query().from($user) .innerjoint($user.transactions, $transaction) .where($user.eq(myuser)) // what? as bonus -- possible if money persisted joda money type, rather bigdecimal? (i'm using usertype's joda money support facilitate persistence) something should work quser $user = quser.user; qtransaction $transaction = qtransaction.transaction; query().from($user) .innerjoint($user.transactions, $transaction) .where($user.eq(myuser)) .singleresult($transaction.money.sum()); querydsl doesn't have (yet) direct support joda money, using joda money sum() method won't available directly.

c# - ObjectQuery, passing Time in Where clause -

how can construct clause of objectquery querying time part of datetime column? i've tried following it's not working. invalid exception on convert. objectquery<item> _query = itementities.createquery<item>("item"); _query = _query.where("convert(varchar,it.start_time,114) > '{0}'", starttime.timeofday); also, i'm using oracle database. tried to_char instead of convert , still same error. thanks. you should able time portion date using to_char , subsequently converting system type e.g. to_date(to_char(it.start_time,'hh24:mi:ss'), 'hh24:mi:ss') dual if objectquery doesn't support to_char try using extract , build time manually e.g. to_date(extract(hour it.start_time) || ':' || extract(minute it.start_time) || ':' || extract(second it.start_time) dual, 'hh24:mi:ss');

java - Get Active Shell in SWT, even if the Shell is not on focus -

display.getactiveshell() seems consider shell active if it's focused. if @ moment application has focus means display.getactiveshell() returns null . i need method tell me shell on focus on swt application, when swt application not on focus. i've hacked piece of code together, although assertionexception : public static shell getactiveshell() { display display = display.getdefault(); shell result = display.getactiveshell(); if (result == null) { shell[] shells = display.getshells(); (shell shell : shells) { if (shell.getshells().length == 0) { if (result != null) throw new assertionexception(); result = shell; } } } return result; } is there standard way approach issue other writing own method? recently, had similar problem , though found solution in meanwhile i'd share mine future reference. the shellactivationtracker adds disp

android - PhoneGap Connection Error -

am working on android using jquerymobile , phonegap. i left app idle on screen, found "application error" when picked again. said connection server unsuccessful. had force close app in order open again. i mentioned code in activity: super.setintegerproperty("loadurltimeoutvalue", 60000); but still problem exists! use bigger value 60sec, emulator can extremely slow. super.setintegerproperty("loadurltimeoutvalue", 360000); i have laptop i5 processor , requires more 60sec sometimes.

database - Linq DataContext.CreateDatabase() force SQL Server 2005 -

i'm using linq datacontext.createdatabase() generate database. it's generating sql server 2008 database. know if it's possible make createdatabase() generate sql server 2005 database? thank you i did quick check of datacontext object in visual studio , doesn't appear sql version specific. assume if point datacontext object @ sql 2005 instance create database fine on sql 2005.

css - How to show content under a left-sided bootstrap tab -

Image
i'm using bootstrap show left-sided tabs, , nice if show content under tabs. my html looks this: <div class="tabbable tabs-left"> <ul class="nav nav-tabs"> <li class="active"><a href="#">tab 1</a></li> <li><a href="#">tab 2</a></li> <li><a href="#">tab 3</a></li> <li><a href="#">tab 4</a></li> </ul> <div class="tab-content"> tab content </div> </div> screenshot: you add li bottom of nav-tabs ul : <ul class="nav nav-tabs"> <li class="active"><a href="#tab1" data-toggle="tab">tab 1</a></li> <li><a href="#tab2" data-toggle="tab">tab 2</a></li> <li><a href="#tab3&

iphone - ios - How to decode XML document? -

this question has answer here: parsing local xml file in ios sdk 1 answer i'm new iphone development,i'm trying access token google,when logged in,i'm getting html content,in html content want token contained in binarysecuritytoken node. how in below html content? <head> <title>working...</title> </head> <body> <form method="post" name="hiddenform" action="http://localhost:26298/loginsuccess.aspx"> <input type="hidden" name="wa" value="wsignin1.0" /> <input type="hidden" name="wresult" value="<t:requestsecuritytokenresponse xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust"> <t:lifetime><wsu:created xmlns:wsu="http://docs.oa

r - Adding legend to venneuler -

i'd add legend venneuler ven diagram based upon generated colors in diagram. how can generate corresponding legend? possible plot values in ven? list1 <- c("102","148","211","293","296","405") list2 <- c("102","148") lists <- list(list1,list2) items <- sort(unique(unlist(lists))) mat <- matrix(rep(0,length(items)*length(lists)), ncol=3) colnames(mat) <- c("a","b") rownames(mat) <- items lapply(seq_along(lists), function(i){ mat[items %in% lists[[i]],i] <<- table(lists[[i]]) }) mat library(venneuler) v <- venneuler(mat > 0) plot(v,main='r simple plot')

actionscript - Guess function in Flash -

i stuck flash game. need syntax in action script below logic. game pretty large , complex explain , explain quick simple example. i have 2 buttons. first 1 button1 , second 1 button2. when click on button1 there should guess , response guess right or wrong. it's random guess function guess right or wrong. there 2 buttons either button1 or button2 should correct per instance. can tell me syntax in action script check random guess? thanks in advance. if understood question correctly should work: button1.addeventlistener(mouseevent.click, randomguess); // event listeners button2.addeventlistener(mouseevent.click, randomguess); function randomguess(event:mouseevent):void { var guess:boolean = boolean(math.round(math.random()));//random value var input:boolean; // define input value if (event.target.name == "button1"){ input = true; // set input value } else if (event.target.name == "button2"){ input = false;

(Geoserver + OpenLayers) Search item by coordinates (lat/long) or id -

i'm using geoserver (2.3.0) + openlayers(2.12), no previous experience on geo systems :(. i need locate in map item located in lat/long, or primary key. have found inverse situation, in other words, if user clicks on item, possible recover lat/long. someone knows how find item? []'s you may send coordinates getfeatureinfo wms query geoserver (with ajax) , parse response. as of id, may write simple page access database , returns info.

c# - Error evaluating embedded expressions: How to get just the date part from the datetime in telerik report -

i want printing date in telerik report bind : printing date{format("{0:mm/dd/yyyy}", now())} but face run time error : error evaluating embedded expressions: unexpected token inside expression @ index 23 how date part datetime in report ? set expression follows: = "printing date "+ now().tostring("mmdd/yyyy")

c - "free(): invalid pointer" error and core dump -

i got unwanted output @ end of successful execution of program while freeing dynamic memory allocated dynamically. *** glibc detected *** /home/ahor/desktop/project work/node: free(): invalid pointer: 0xb7fda000 *** ======= backtrace: ========= /lib/i386-linux-gnu/libc.so.6(+0x75ee2)[0xb7e93ee2] /home/ahor/desktop/project work/node[0x8048cf9] /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb7e374d3] /home/ahor/desktop/project work/node[0x8048561] ======= memory map: ======== 08048000-0804a000 r-xp 00000000 08:06 786473 /home/ahor/desktop/project work/node 0804a000-0804b000 r--p 00001000 08:06 786473 /home/ahor/desktop/project work/node 0804b000-0804c000 rw-p 00002000 08:06 786473 /home/ahor/desktop/project work/node 0804c000-0806d000 rw-p 00000000 00:00 0 [heap] b7deb000-b7e07000 r-xp 00000000 08:06 2228253 /lib/i386-linux-gnu/libgcc_s.so.1 b7e07000-b7e08000 r--p 0001b000 08:06 2228253 /lib/i386-linux-gnu/libgcc_s.so.1 b7e08000-b7e09000 rw-p 000

php - Yii Role Based Acces Controle -

question quite newbie. generated entity , model, crud using gii. default acces rules delete action can users admin role. default have 2 users defined in useridentity.php: admin/admin , demo/demo. demo common user , admin admin user. authenticating demo have "403 forbiden" on delete page. question set role these default users??? in access rules array, need specify users not roles. until start using rbac module, have no roles assigned. tutorial rbac shows how define roles , assign them users. doesn't tell populate files. read data migrations. populated files.

xor - Shortest hamiltonian path with dynamic programming and bitmasking -

i've read article how find shortest hamiltonian path using dynamic programming here http://codeforces.com/blog/entry/337 . while pseudocode works, not understand why have take use xor operator on set , 2^i. why wouldn't substract current visisted city bitmask? xor set in order make algorithm it's magic? to clarify here piece of pseudocode written in java: public int calculate(int set, int i){ if(count(set) == 1 && (set & 1<<i) != 0){ return 0; } if ( dp[set][i] != infinity){ return dp[set][i]; } (int city=0;city<n;city++){ if((set & 1<<city) == 0) continue; dp[set][i] = math.min(dp[set][i], calculate(set ^ 1<<i, city) + dist[i][city]); } return dp[set][i]; } found solution problem, ^ bitflip. if have bitmask , use xor operator on mask, flip bit on place. e.g. 1010 ^ (1<<1) results in 1000. same goes 10

jquery - Return a value from custom (modal) alert box -

please find below code... var res = confirm("are sure?"); alert(res); in above confirm box when click 'ok', returned value of 'true', , 'false' clicking 'cancel'. how return value (0 or 1) jquery custom modal box plugin, above confirm box? find following fiddle sample , plug-in script in http://jsfiddle.net/yesvin/n2qu7/ complete html code <!doctype html> <html> <head> <title>custom modal</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv=”content-type” content=”text/html; charset=utf-8> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /> <script src="http://code.jquery.com/jquery-1.8.0.min.js"></script> <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile

c++ - What is the difference between locale and Encoding ( Terminal ) -

i have tried few ways set terminal 'encoding' c++ program. change locale. or lang variable. still able enter characters of different encoding lang ( , output of nl_langinfo(codeset) ) but , if go terminal > set character encoding > iso-8859-15 ( or ) allowing iso-8859-15 . can achive same thing ( setting gui ) c++ program ? i used setlocale(lc_ctype,"") set encoding terminal encoding , uses lang variable.and allows other characters too. ( after terminal > set character encoding > iso-8859-1 ( latin1 ) ) >setenv lang en_us.iso885915 --> latin9 >./a.out current locale : c lang info : ansi_x3.4-1968 trying change locale c "" current locale : en_us.iso885915 lang info : iso-8859-15 enter string :¤¦¨´¸¼½¾ dfsafas --> these latin1 charaters !! entered string : ¤¦¨´¸¼½¾ dfsafas --> printed !! so , brought me down question if understanding locale , encoding correct or not. can please clarify difference? encodi

find - How to add header to huge amount of files (empty/non-empty) -

i need add header (single line) huge (>10k) number of text files. let assume variable $header contain appropriate header. command find -type f -name 'tdgen_2012_??_??_????.csv' | xargs sed -i "1s/^/$header\n/" does work well. problem face of data files (tdgen_2012_?? ?? ????.csv) empty. sed(1) cannot address non exist line of file. decided manage empty files in separate way: echo $header | tee $(find -type f -name 'tdgen_2012_??_??_????.csv' -empty) > /dev/null due amount of empty files command above not work. tee(1) cannot write unlimited count of files. number of command line arguments can exceeded. i not want use for-cycle due low performance (the tee(1) can write many files @ once). my questions: does exist 1 solution both kind of data files (empty/non-empty) @ once? if not: how manage empty files effectively? echo $header > header find -type f -name 'tdgen_2012_??_??_????.csv' \ -exec sh -c '{ echo $h

diff - Strange conflict on git -

i read article three-way merges (diff3). gives example how detects conflict. example : a=[1,4,5,2,3,6] o=[1,2,3,4,5,6] <<< origin b=[1,2,4,5,3,6] in first time computes diff between o-a , after o-b: a=[1,4,5,2,3, ,6] o=[1, ,2,3,4,5,6] and o=[1,2,3,4,5, ,6] b=[1,2, ,4,5,3,6] after makes diff3 parse : a=[1,4,5,2, 3 ,6] o=[1, ,2, 3,4,5 ,6] <<< origin b=[1, ,2, 4,5,3 ,6] and after detects conflict : 1 4 5 2 <<<<<<<<<a 3 |||||||o 3 4 5 ======= 4 5 3 >>>>>>b 6 following method detect conflict, try simple example : have document : a; b; i make updates user 1 update "a;" , "a=0;" user 2 update "b;" , "b=0;" obtain result : xx <<<<<<< int a=0; int b; ||||||| o int a; int b; ======= int a; int b=0; >>> when merge these 2 documents have conflict if don't change @ same position ( a , b not @ same positi

django - Tastypie - Linking to a "ForeignKey" -

i have 2 legacy models listed below. library.libtype_id effectively foreign key librarytype when libtype_id > 0. want represent foreignkey resource in tastypie when condition met. can me out? have seen this i'm not sure it's same thing? much!! # models.py class librarytype(models.model): id = models.autofield(primary_key=true) name = models.charfield(max_length=96) class library(models.model): id = models.autofield(primary_key=true) name = models.charfield(max_length=255) project = models.foreignkey('project.project', db_column='parent') libtype_id = models.integerfield(db_column='libtypeid') here api.py class librarytyperesource(modelresource): class meta: queryset = librarytype.objects.all() resource_name = 'library_type' class libraryresource(modelresource): project = fields.foreignkey(projectresource, 'project') libtype = fields.foreignkey(librarytyperesource,

single sign on - WSO2 SingleSign ON -

i new wso2 , follow this post enable single sign on (sso) following scenario: virtual machine running centos (ip: 192.168.0.18) wso2 identityserver 4.1.0 installed https port: 9443 wso2 applicationserver 5.1.0 installed https port: 9443 here problem: when access application server console management, redirected identity provider login page expected , can login. i redirected initial request (application server mgt console) message appears telling me authentication/authorization fails. in log files can see following error: tid: [0] [as] [2013-05-14 16:13:32,128] info {org.wso2.carbon.identity.authenticator.saml2.sso.common.builders.authenticationrequestbuilder} - building authentication request {org.wso2.carbon.identity.authenticator.saml2.sso.common.builders.authenticationrequestbuilder} tid: [0] [as] [2013-05-14 16:13:32,388] error {org.wso2.carbon.identity.authenticator.saml2.sso.util.util} - content not allowed in prolog. {org.wso2.carbon.ident

mysql - Many facebook like-buttons - same page -

i have interesting question - see there way have many buttons on same page making manually link every button. thing i´m programming page menu restaurant , owner wants each meal on menu have "like-button" - each meal in box arrange on page can have 2 meals or 100 meals on same page. the info in menu comes mysql table select menu order id desc (no limit) - multiplies on page making special url each like-button not option is do-able? its use ajax, in case.

sql - Return records from a table which have a match on all records of another table -

having following 3 tables in dbms: customer(id, name, city), product(id, name, price), orders(cust_id, prod_id, date) what query fetches customers (if any) have ordered all products? select c.id customer c inner join orders o on o.cust_id = c.id inner join product p on p.id = o.prod_id group c.id having count(distinct p.id) = (select count(id) product)

ajax - how to pass checkbox values into .load page using jquery -

i have form checkboxes on want post page (data.php) , want load page inside page using .load function jquery can check checkbox , update query without page have reload. can jquery code i'm new jquery , can't work out code need. appreciated. in advance. updated: i have following jquery works, have 2 problems first 1 page im loading data.php has pagination , when links clicked returns no results because page reloading , returning default have 2 groups checkboxes each submit button both same id name ect , top button submits form loads data in page reason bottom submit button loads actual data.php page , don't understand why. if can or point in right direction greatful. thanks here java script <script type="text/javascript"> $(document).ready(function() { $("#submit").click(function() { var action = $("#criteria").attr('action'); var form_data = $('#criteria').serialize(); $.ajax({ typ

c# - Getting values from database in an item databound -

i looking solution following scenario using asp.net & sql server. i have repeater control ,i need display image within repeater control , based on range of values stored in database table. database table : level1 min max 1 100 100 2 50 99 3 1 49 i used itemdatabound event repeater control. & hard coded min , max values . values database. 1 thing write stored procedure , call within item data bound event, concerned effect performance. i know if there way min , max values database without effecting performance? protected void rptmonitorsummary_onitemdatabound(object sender, repeateritemeventargs e) { if (e.item.itemtype == listitemtype.item || e.item.itemtype == listitemtype.alternatingitem) { int x = convert.toint32(databinder.eval(e.item.dataitem, "x")); int y = convert.toint32(databinder.eval(e.item.dataitem, "y")); float percentage

regex - Regular expression match only if followed by something else -

Image
i wanna match string contains ';' , ; must between words " bla ; bla" match "bla" match "bla . bla" or "bla;" wont match. in other words ; appears if not end of string. hope clear wanted :p try \w\s*?([;])(?=\s*?\w) match ";" preceded , followed white space , word character

Android WindowManager.updateViewLayout behaving weird -

this part of code in view: params.width = myactivity.getwidth(); params.focused.height = myactivity.getheight(); wm.updateviewlayout(this, windowlayoutparams.focused); i'm trying re-size window touch messages. when call updateviewlayout() translates coords (0,0) , resizes it. problem can see happening. flickers. how update view without happening? (i have tried handler , doesn't work)

regex - greedy block ()* contains wildcard -

i building grammar in antlr4 , , getting warning tl4.g4:224:12: greedy block ()* contains wildcard; non-greedy syntax ()*? may preferred here line of code referring block : ( statement | functiondecl )* (return expression ';')? ; what warning mean, how can correct ? the warning telling block ()* greedy, meaning try match maximum occurrences of statement or functiondec1 which, depending on situation, might not expect. changing ()*? makes non-greedy, suggested warning. means match minimum occurrences of statement or functiondec1 . expression examples strings: samples: foofoobar foobarbar foofoobarbarbar expression: (foo|bar)*bar will give result: foofoobar foobarbar foofoobarbarbar expression: (foo|bar)*?bar will give result: foofoobar foobar foofoobar for last one, result stop @ first bar

c++ - What does :: mean after declaring an object? -

Image
i trying hello world stuff after completing the standard c++ tutorial . first thing tried doing drawing directly on screen without window. found this , works. #include "stdafx.h" #include <windows.h> #include <iostream> using namespace std; int _tmain(int argc, _tchar* argv[]) { hdc screendc = ::getdc(0); ::rectangle(screendc, 200, 200, 300, 300); int exit; cin >> exit; return 0; } but in standard c++ tutorial cover this hdc screendc = ::getdc(0); ::rectangle(screendc, 800, 200, 300, 300); what rectangle member of? if don't mind have other questions might simple. if not don't worry it. as rectangle has window move on it, disappears. there callback let me know can repaint? how change color of rectangle? where can go learn this? every tutorial have found has been sparse , have been out of date. can book if that's need do. have tried following (sometimes success , not): http://msdn.microsoft.com/en-us/libra

c++ - Read array of custom metatype from QSettings -

i have problem reading custom metatype data qsetting. have class: class musicowner { public: musicowner() : songs_count(0), id(0) {} explicit musicowner(const song &owner_radio); song toownerradio() const; static qlist<musicowner> parsemusicownerlist(const qvariant &request_result); private: friend qdatastream &operator <<(qdatastream &stream, const vkservice::musicowner &val); friend qdatastream &operator >>(qdatastream &stream, vkservice::musicowner &val); friend qdebug operator<< (qdebug d, const musicowner &owner); int songs_count; int id; qstring name; qstring screen_name; qurl photo; }; q_declare_metatype(vkservice::musicowner) with overloaded: qdatastream &operator <<(qdatastream &stream, const vkservice::musicowner &val) { stream << val.id; stream << val.name; stream << val.songs_count;

c - one-producer and multiple consumer : should I use N semaphore if there are N consumers and N types of products -

i have program 1 producer thread , n consumer threads. there n types of producet, set n fifo queues(products should delivered consumer in sequence). like: fifo_queue_t* fifo_queque[n]. the consumer threads blocked/waiting if there no products on fifo queue. consumer thread i , do: for(;;) { sem_wait(&sem[i]); product = fetch_one_product(queue); process(product); } and producer, call sem_post(&semp[i]) when put product thread i fifo queue i . it seems me have use n semaphores in case, , if n big, resource consumption big. there missing in thinking? update : system proxy, , original design this: i have tcp server listening on port, listen(listenfd, 20) ; the producer libpcap instance, capture tcp packets port, products capture packets(including ip/tcp header); for each connfd=accept(listenfd). create thread responsible connfd. these threads consumers. i create lookup table, fields in each entr

ios - CIDetector give wrong position on facial features -

Image
now know coordinate system messed up. have tried reversing view , imageview, nothing. tried reverse coordinates on features , still same problem. know detects faces, eyes , mouth, when try place overlaying boxes samples codes, out of position (to exact, on right off-screen). im stumped why happening. ill post code because know of guys specificity: -(void)facedetector { // load picture face detection // uiimageview* image = [[uiimageview alloc] initwithimage:mainimage]; [self.imageview setimage:mainimage]; [self.imageview setuserinteractionenabled:yes]; // draw face detection image // [self.view addsubview:self.imageview]; // execute method used markfaces in background // [self performselectorinbackground:@selector(markfaces:) withobject:self.imageview]; // flip image on y-axis match coordinate system used core image // [self.imageview settransform:cgaffinetransformmakescale(1, -1)]; // flip entire window make right side // [self.vi

c++ - ld: library not found after unzipping -

i have zipped xcode project source sharing friend. after unzipping error ld: library not found please help. let me know if need additional details. most 1 of libraries added project relative path goes outside of zipped folder, or absolute path isn't included archive.

dcg - Prolog, Definite Clause Grammar -

some code wrote definite clause grammar followed book "learn prolog now" closely lex(the,det(single)). lex(the,det(plural)). lex(a,det(single)). lex(some,det(plural)). lex(at,det(single)). lex(student,n(single)). lex(students,n(plural)). lex(assignment,n(single)). lex(assignments,n(plural)). lex(teacher,n(single)). lex(teachers,n(plural)). lex(lecture,n(single)). lex(lecture,n(plural)). lex(school,n(single)). lex(home,n(single)). lex(does,v(single)). lex(do,v(plural)). lex(corrects,v(single)). lex(correct,v(plural)). lex(writes,v(single)). lex(write,v(plural)). lex(gives,v(single)). lex(give,v(plural)). lex(his,pro(single)). lex(her,pro(single)). lex(their,pro(plural)). lex(and,conj). lex(while,conj). s--> s, conj, s. s--> np(x),vp(x). np(x)--> det(x),n(x);pro(x), n(x). vp(x)--> v(x), np(x). vp(x)--> v(x). det(x)--> [a],{lex(a,det(x))}. pro(x)--> [a],{lex(a,pro(x))}. v(x)--> [a],{lex(a,v(x))}. n(x)--> [a],{lex(a,n(x))}. below query aske

c# - Do I need to specify add or attach -

in case of needed add new row 1-1 relationship, need specify add or attach? , how do if need to? //one tblcontent 1 tblcontentdata //updating tblcontentdata corresponding particular id in tblcontent int id = 12345; tblcontent entity = db.tblcontents.where(con => con.id == id) .firstordefault(); if (entity == null) throw new exception("id bad"); if (entity.tblcontentdata == null) entity.tblcontentdata = new tblcontentdata(); //proceed updating foreign keyed table add new rows. add not updates. in code posted, relationship between entity , context should preserved need call: db.savechanges(); to preserve updates. in cases relationship broken can update item entry : db.entry(entity).state = entitystate.modified; db.savechanges();

json - How do I pass AJAX JSONP data into a function? -

i asked similar question already, discovered needed use ajax , jsonp, opened whole new world of hurt. a company working has api privacy policy , terms of use. need create 2 different pages: privacy policy terms of use so need search data them, find correct term in "tags" ('ext_privacy' , 'ext_member_terms', respectively), , use html code array rest of page. the problem is, can't figure out how pass data ajax function, , @ point, don't know how drill down sections appropriately - thought external.data.results.tags , doesn't seem work. here's site code: <!doctype html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <title>privacy policy</title> </head> <body> <div id="data"> </div> <script> $.ajax({ type: 'get', url: 'http://guywhogeeks.com/t

spring - How to add an xml of a dependant project in eclipse -

i having applicationcontext.xml of existing project. created new junit -java project in kept previous project dependent project. created xml - applictioncontextjunit.xml junit project.the question is- how can reuse existing applicationcontext.xml in new xml this junit class entry- @runwith(springjunit4classrunner.class) @contextconfiguration("classpath:applicationcontextjunit.xml") public class testjunit { private customerservice cust; } this applictioncontextjunit.xml-- <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context

objective c - Calculate the sum of numbers between 1 and 100 that end in 5 -

i'm trying calculate sum of numbers between 1 , 100, numbers end in 5: 5, 15, 25, , on. i have no idea how this; know how calculate sum, not how deal "ends in 5" condition. here's have far int sum = 0; (int = 1; <= 100; i++) { sum = sum +i; } nslog(@"%i", total); you don't need loops solve this: int sum1 = 5 * 20 * 21 / 2; // find sum of multiples of 5 int sum2 = 10 * 10 * 11 / 2; // find sum of multiples of 10 int sum = sum1 - sum2; // remove multiples of 10

Accessing Device camera on Android phone and iPhone using javascript or php or some other language -

how can access device camera browser using button on website on android phone , iphone. not sure if possible if website made in php please me if has solution this. thanks it's rather done through javascript, it's unfortunately not possible website access camera on mobile device right now, things may change if android/ios browsers start provide support html5 getusermedia api . you may able use file picker asks user take photo or select gallery (at least on ios). see https://web.archive.org/web/20130520232826/http://www.aaronlumsden.com/articles/ios6-the-benefits-for-html5-web-app-development/ more information.

jquery - Toggle Function open by default -

i have function toggle(open , hide div ) clicking : " show / hide filter " text . here function : <script type="text/javascript"> $(document).ready(function(){ $(".slidingdiv").hide(); $(".show_hide").show(); $('.show_hide').click(function(){ $(".slidingdiv").slidetoggle(); }); }); </script> what wanting make div default open click open or hide . default hidden . there solution ? remove line $(".slidingdiv").hide(); hides sliding div shown default.

c - How do I use libdb-4.2 in a FreeBSD 9.1 system? -

i'm attempting write small program in c open , read berkeley 4.2 hash db on freebsd 9.1 system testing, can't compile. first time i've written in c , compiled command line i'm missing 1 thing that'll working, don't know. after searching on , looking @ documentation , source code on github, i've got far: #include <sys/types.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <db.h> int main() { db * mydb; u_int32_t open_flags = db_rdonly; int ret; ret = db_create(&mydb, null, 0); if (ret != 0) { printf("error creating db structure!"); return 1; } ret = mydb->open(mydb, null, "bsddb-py", null, db_hash, open_flags, 0); if (ret != 0) { printf("error opening db file!"); return 2;

Ember.js Action error: "Nothing handled the event" -

i'm working on first ember.js app, , though have template loading, when attempt invoke action i've defined in controller, i'm getting error: "uncaught error: nothing handled event 'shownew'." i'm not sure if i've set route , controller incorrectly, or if i'm missing else. ./router.js: seanchai.router.map(function(){ this.resource("stories", function(){ this.route('new'); }); }); seanchai.storiesroute = ember.route.extend({ model: function(){ seanchai.story.find(); } }); seanchai.router.reopen({ location: 'history' }); ./controllers/stories_controller.js: seanchai.storiescontroller = ember.arraycontroller.extend({ shownew: function() { this.set('isnewvisible', true); } }); ./templates/stories/index.hbs: <table> <thead> <tr> <th>id</th> <th>name</th> </tr> </thead> <tbody> {{#each st

Flex mobile: waiting view is rendered before pushing the new view -

this big problem have, non-embedded images: after navigator.pushview elements rendered during , after transition occurring. causing transition jittering , page re-composing after transition. simple example <s:bitmapimage source="xxxx" /> renders after transition complete. heavy code may cause transition jitter. is there way hold new view , push when conditions satisfied? i know images can embedded, there lot of other situations wish push new view when tasks done. thanks help alfonso

web applications - How do I prevent page from shifting up when soft keyboard appears over text field on Android device? -

i developing web app, nothing more javascript, html , css. have textbox near bottom of page , when clicked in bring soft keyboard on android, shifts entire page up, outside viewport, make visible while entering text on keyboard. after, entire page stays shifted , cannot brought down it's original position. it client side code adding attributes xml suggested in previous posts don't seem feasible. appreciated. the android keyboard works differently ios keyboard respect javascript events. think of android keyboard sliding , squeezing contents of page. when happens causes javascript 'orientationchange' event. if have javascript event listener doing things might not want. 1 way work around adjusting css using @media screen. @media screen , (max-aspect-ratio: 13/9) { // put portrait settings here } @media screen , (min-aspect-ratio: 13/9) { // put landscape settings here } with ios, can think of keyboard sliding on top of page not cause 'orientat

python - Gravity in pygame -

i'm making platform game pygame, , add gravity it. right have picture moves when press arrow keys, , next step gravity. here's code: import pygame, sys pygame.locals import * pygame.init() fps = 30 fpsclock = pygame.time.clock() displaysurf = pygame.display.set_mode((400, 300), 0, 32) pygame.display.set_caption("jadatja") white = (255, 255, 255) catimg = pygame.image.load("images/cat.png") catx = 10 caty = 10 movingright = false movingdown = false movingleft = false movingup = false while true: #main game loop #update event in pygame.event.get(): if event.type == keydown: if event.key == k_right: #catx += 5 movingright = true movingleft = false elif event.key == k_down: #caty += 5 movingdown = true movingup = false elif event.key == k_left: #catx -= 5 movingleft = true movingright = false elif eve