Posts

Showing posts from May, 2015

javascript - How to place a div inside a bigger scrollable div at particular position -

i have div height = 10*screen-height. i want add smaller div height = screen height assuming can add 10 such smaller div's onto bigger div, want add div @ particular position on bigger div. starting 4*screenheight pixel. how do using jquery? presumably have screen height stored, , 2 divs created @ correct heights, so: $(inner_div).css('position', 'relative').css('top', 4*screen_height); you may not need position:relative in style if it's in css already

Paypal Adaptive Pay Error 520003 Authentication failed. API credentials are incorrect -

i have working version of paypal adaptive pay on domain. copied of code , put on new domain , receive error. exact same code , works on 1 domain fails on other. 520003 authentication failed. api credentials incorrect. it turns out lamp server running php 5.2 vs other 1 running 5.3

DNS Different IP for Different Port -

is possible assign different ip different port? such as: http://example.com:80 -> 123.456.789.012 http://example.com:90 -> 987.654.321.098 is there way this? you can use dns srv records associate hostname (and thereby address) and port number service name, virtually no web browsers or other http clients query srv records. so, in practice, no. even srv records, cannot solve problem in question stated. srv records won't resolve http://example.com:80/ , http://example.com:90/ different addresses, because specifying port number manually overrides srv record , queries address (a , aaaa) records directly. srv records (if browsers bothered query them!) resolve http://a.example.com/ , http://b.example.com/ different addresses (or same address) , different ports.

c# - windows form application "Find" -

Image
i have no idea "match whole word only" , "match case", can give me suggestion? thank you. below codes. match case: performs case sensitive search; exact matches found (e.g. "mystring" matches "mystring" not "mystring"). match whole word only: search strings match if whitespace occurs on either side of string. example, if search string "edit" , "word" selected, occurrences of word "edit" found. if not selected, "editing", "editor", "editorial" , "edited" found.

Regex to replace email address domains? -

i need regex obfuscate emails in database dump file have. i'd replace domains set domain @fake.com don't risk sending out emails real people during development. emails have unique match database constraints, want replace domain , keep usernames. i current have regex finding emails \b[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}\b how convert search regex regex can use in find , replace operation in either sublime text or sed or vim? edit: just note, realized replace strings found @[a-z0-9.-]+\.[a-z]{2,4}\b in case, academically still interested in how treat each section of email regex token , replace username / domain independently. sublimetext sublimetext uses boost syntax , supports quite large subset of features in perl regex. task, don't need advanced constructs. below 2 possible approaches: if can assume @ doesn't appear in other context (which quite fair assumption normal text), can search domain part @[a-z0-9.-]+\.[a-z]{2,4}\b , replace...

android - Testing for Resources such as Drawbles and Background -

i need see if there way can test background button has. example, here psueduo code: if (button background `r.drawable.black`) { button.setbackground(to r.drawable.white) } is there way if statement can done? know how set backgrounds, curious on test portion. in case, believe tags useful. try this: //when set button: btn.setbackgroundresource(r.drawable.black); btn.settag(r.drawable.black); //when re-set button: if(btn.gettag().equals(r.drawable.black)) { btn.setbackgroundresource(r.drawable.white); btn.settag(r.drawable.white); }

Actively tracking oracle query performance -

background: we have database environment views calling views calling views... logic has become complex , changes underlying views can have significant impact on top view being called client application. now while documenting logic , figuring out how unwind development continues on , performance continues degrade. currently manually run explain plan on client query , dig tuning it. slow , tedious process , changes may not examined ages. problem: i want generate report lists sql id , lists changes in actual time/discrepancy between estimated rows , actual rows/changes in buffers/changes in reads in comparison average computed on last month. i run following script manually , examine based on day's response. alter session set statistics_level=all; set linesize 256; set pagesize 0; set serveroutput off; -- query select * table (dbms_xplan.display_cursor (null, null, 'allstats last')); what trying see automating explain plan query , inserting statist...

php - Combine function that populates `select` elements with function that pre-selects options matching db values -

i want modify function checkselectedoption don't have hardcode array every time it's called. the 1rst function pre-selects option matching information in db, uses hardcoded arrays populate select elements. 2nd function creates arrays db values , dynamically populates select elements. how can combine these 2 functions can populate select elements dynamically, , pre-select option matching information in db? function checkselectedoption populates element values specified in array "$options", , pre-selects option matching information in "customer_info" table of db. function requires arrays hardcoded, , want replace part of function method function printselectoptions uses arrays created db values. function printselectoptions populates select elements values fetched db. creating array values in column fetched "form_fields" table. function checkselectedoption function checkselectedoption($dataarray, $currentselection) { foreach...

How to make web service tell request that SOAP header is required? -

i created web service, written in java , generated using eclipse & axis2. created ws-security policy in services.xml file , created authentication handler. new web services, forgive if statements wrong. after have generated web service , have wsdl, create soapui project , generates requests. soapui generated requests have soap header blank, when run request receive security exception authentication failed. when enter proper header: <soapenv:header xmlns:wsa="http://www.w3.org/2005/08/addressing"> <wsse:security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustunderstand="1"> <wsu:timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:id="timestamp-12468716"> <wsu:created>2008-06-23t13:17:13.841z</wsu:created> <wsu:expires>2008-06-23t13:22:13.841z</wsu:expires> </wsu:timest...

MySQL - Show duplicated data from columns in different tables, when only one column is duplicated -

i have such query shows me nicely product.model duplicated: select product.model, product_description.name, count( * ) count product, product_description product.product_id = product_description.product_id group product.model order count having count >1 however can't force query show content of product_description.name every duplicated product.model , compare product_description.name i trying make in on result, '#1241 - operand should contain 1 column(s)'. idea how can process result further? depending on desired results, if want see models have more 1 record in the product table, , want see associated product descriptions, use group_concat combine descriptions. select p.model, group_concat(pd.name), count( 1 ) count product p inner join product_description pd using (product_id) group p.model having count(1) > 1 order 3 sql fiddle demo there other ways return in different rows, depends on needs.

Excel VBA - Make multiple fields required based on value of another field -

i've created request form in excel vb uses submit button generate email in outlook based on values entered form. everything works fine. however, users fail complete necessary fields before submitting request. i need sure user completes required fields when specific value entered cell d7 before submit request here lost...i've tried approaching 2 different ways. hopefully can me this! approach 1: when submit button pressed... button_click() if range("d7").value = "special request" 'make cells b6, b7, b8, b9, d14 mandatory in order generate email on error resume next if thisworkbook.worksheets("request").range _ ("b6, b7, b8, b9, d14 ") nothing msgbox ("please confirm required fields have been completed!") 'do not generate email approach 2: when submit button pressed... button_click() 'if value of cell d7 other "special feature", 'execute code normal genera...

ruby on rails - Attempting to deploy to heroku, blows up when installing hoe -

i've got hoe commented out in gemfile , version of rubygems 2.0+. here's output when run git push heroku master : installing json (1.7.7) installing rdoc (3.12.1) installing thor (0.17.0) installing railties (3.2.12) installing coffee-rails (3.2.2) installing commonjs (0.2.6) installing formtastic (2.2.1) installing formtastic-bootstrap (2.0.0) installing hoe (3.5.0) gem::installerror: hoe requires rubygems version >= 1.4. try 'gem update --system' update rubygems itself. error occurred while installing hoe (3.5.0), , bundler cannot continue. make sure `gem install hoe -v '3.5.0'` succeeds before bundling. ! ! failed install gems via bundler. ! ! heroku push rejected, failed compile ruby/rails app git@heroku.com:limitless-river-5139.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed push refs 'git@heroku.com:limitless-river-...

Rails Overall Architecture Best Practices -

i'm interested see rails veterans on stack overflow have this. basically, rails newb, , no "formal" background in programming, 1 of biggest challenges has proper architecture. how know right or better build app are? i love see resources are. i know basic ones - lot of these don't give me high level architecture overview want: http://www.amazon.com/agile-development-rails-third-edition/dp/1934356166/ref=cm_lmf_tit_7 http://www.amazon.com/ruby-programming-language-david-flanagan/dp/0596516177/ref=cm_lmf_tit_3 railscasts here's quick example: say i'm building rails app has merchants , shoppers - each set of users has own authentication, different permissions, etc. proper build single app or multiple communicate through apis? there added benefit multi-app abstraction? thanks! this not easy question. complete answer largely depend on project. if starter i'd recommend keep in 1 app, have enough "separation" using models...

html - Input into site using Mechanize (Python) -

i'm trying make dictionary program using dictionary.com source can't find name of search box in source code from mechanize import browser inp = raw_input("enter word: ") word = (inp) search_page = "http://dictionary.reference.com/" browser = browser() browser.open( search_page ) browser.select_form( nr=0 ) browser['name of search form'] = word browser.submit() can me make work or me find name of search bar in html source? you can through forms method browser.forms(). each of these forms has variable called controls, list of controls in form. each control in list has "name" variable. can use these names index browser, know. from mechanize import browser inp = raw_input("enter word: ") word = (inp) search_page = "http://dictionary.reference.com/" browser = browser() browser.open( search_page ) form = list(browser.forms())[0] #the first form print form names = map(lambda n:...

python - Stacking Arrays in pylab using vstack -

i have following code stack arrays , solve system of equations: 1 import numpy np 2 numpy.linalg import solve 3 xi = np.array([-1., 1., -2]) 4 yi = np.array([0., 4., 3.]) 5 = np.vstack([np.ones(3), xi, xi**2]).t 6 b = yi 7 c = solve(a,b) then after have code execute graph, error on line 5. says: typeerror: 'function' object has no attribute '__getitem__' how can fix this? it looks you've got brackets confused. code printed above has mismatched brackets @ line 5: ([...)] gives syntaxerror. i'd guess version used [(...)] gives error report. problem you're trying call function using square brackets, when python syntax requires round ones. try putting brackets other way round: ([...]) code runs fine on system. edit: question edited while typed this, ignore first 2 sentences. still suspect ordering of brackets wrong in code run.

python - Turning my function into a class -

i have function works how want to, course work, have turn function class that: must have function called solveit , returns following 2 values: a boolean true if you've solved knapsack problem, and the knapsack object correct values in it. the class must have __str__() function returns string this. first line size, , second comma-separated list of elements: 10 4,1,9,2,0,4,4,4,3,7 i dont understand classes well, appreciated. here function have right now: from itertools import combinations def com_subset_sum(seq, target): if target == 0 or target in seq: print(target) return true r in range(len(seq),1,-1): subset in combinations(seq, r): if sum(subset) == target: print(subset) return true return false print(com_subset_sum([4,1,9,2,0,4,4,4,3,7],10)) one obvious way transform function class turn function parameters (or of them) object attributes. example: class knapsack(ob...

c# - Binding a combobox selected item content to an element -

i working wpf using entity framework , data binding managing product , brand in database. product includes brandid property. in order display in datagrid brand name instead of id, used datagridcomboboxcolumn this: c# gridproducts.datacontext = this.dbcontext.products; brandcolumn.itemssource = this.dbcontext.brands; xaml <datagrid name="gridproducts" issynchronizedwithcurrentitem="true" roweditending="dg_roweditending" itemssource="{binding}" > <datagrid.columns> ... <datagridcomboboxcolumn header="brand" x:name="brandcolumn" displaymemberpath="brandname" selectedvaluepath="id" selectedvaluebinding="{binding path=brandid}" /> </datagrid.columns> <datagrid> it works fine. need bind combobox selected value textbox text. tried this: xaml <textbox name="brand" text="{binding path=selectedvalue.content, ...

REST based web chat in java and eclipse -

i want create rest based chat application in java using eclipse, have no idea how start. how take care of resources, verbs, , heatos. check out link , or link , or link . recommend jersey. restelt powerful, might quite complicated. resteasy has more features jersey, can pain configure outside jboss, , community not 'active'. recommend jersey, startup tutorial easy follow. you can @ book , , book . sorry, can't provide hard answers have no knowledge, level of expertise on subject. hope helps.

android - Adding a Calendar to a SyncAdapter Account for API 10 (2.3.3) to API (14)? -

i have created syncadapter along authentication. able add synced account device, account able have calendars associated it. my syncadapter syncs custom calendar webserver i plan support android 2.3.3 4.x i know before api 14 android's internal calendar store wasn't officially supported developers , no contentprovider existed. calendar database schema same 2.3.3 , on? specifically, potentially write custom calendar contentprovider 2.3.3 , have function on 4.0+? is there anywhere obtain database schema android calendars 2.3.3 , 4.0 investigate this? additionally, calendar database stores syncadapter account given calendar associated to? try using tool -- http://www.cellobject.net/tools/cellobjectsqlitexmlbrowser.aspx visualize calendar db. this give schema of calendar db. specifically, potentially write custom calendar contentprovider 2.3.3 , have function on 4.0+? yes, can use contentproviders. (just check whether columns going use present in bot...

codeigniter - Fixing the Google API PHP client on hosting service -

i using google api's php client access gmail contacts. code working fine in localhost stopped working when moved hosting service. yes did verify oauth parameters , updated same in google api console too. there way debug it? using codeigniter 2.1. config.php - $config['uri_protocol']= 'auto'; , in controller method add parse_str(substr(strrchr($_server['request_uri'], "?"), 1), $_get); before if condition. then [blog][1]. config.php - $config['uri_protocol'] = "path_info"; , controller method parse_str($_server['query_string'], $_get); before if condiion. controller method function gmail_invite() { session_start(); $gmailcontacts = array(); $client = new google_client(); $client->setapplicationname('tets'); $client->setscopes("http://www.google.com/m8/feeds/"); $client->setclientid('222222.apps.googleusercontent.com'); $client->setclientsecret('secret'); $clien...

datetime - C code for date time format validation. specified format is "YYYYMMDDHHMMSSmmmmmm" -

i need validate date-time value " yyyymmddhhmmssmmmmmm " format. hoping need find out tested working c code validate date time value above format. further, have date-time value 201304011031000000 . need function verify whether valid date or not.[ isdatetime() ] below each parts of formats. yyyy : year mm : month dd : day hh : hour mm : minutes ss : seconds mmmmmm: micro-seconds if you're on posix system, looks should handled strptime() , 'milliseconds' (or microseconds) part not handled strptime() or other standard conversion function know of. assuming question asking microseconds, use variation on theme provided by: #include <stdio.h> #include <string.h> #include <time.h> int main(void) { const char datetime[] = "20130417221633012345"; // yyyymmddhhmmssffffff struct tm time_val; unsigned microsecs; const char *end = strptime(datetime, "%y%m%d%h%m%s", &time_val); if (end != ...

SQL ordering in XCode -

i want order data variables , select first record. doesn't work. here code: nsstring *s = [db stringforquery:@"select cardinfo.?, cardinfo.?, cardinfo.? cardinfo cardinfo.currentbalance > ? order cardinfo.? desc, cardinfo.? desc, cardinfo.? asc ", first, second, third, [nsnumber numberwithdouble:money], first, second, third]; if change ordering constants, works. nsstring *s = [db stringforquery:@"select a, b, c cardinfo cardinfo.currentbalance > ? order desc, b desc, c asc ",[nsnumber numberwithdouble:money]]; does know how correct it? lot. yep. order cardinfo.? attempts parameterize metadata, column name. prepared statements allow parameterize data only. you can say where tablename.colname = ? you cannot say where ?.colname = 'foo' hth.

Adding a search form to Docpad site -

is there way have native search form indexes search results in docpad. dynamic search page example doesn't work , looking @ code wasn't me. think search form example , basic contact form example noobs myself looking adopt docpad , workflow. thanks in advance help! depends mean not working. able kitchin sink skeleton install? search page in skeleton reads query term url , searches documents in website word "coffee" in title @getcollection('documents').findall({title:$like:query}) you should list of links documents "coffee" in title - not exciting on own. if mean trying implement search page within own project there seems bit of 'gotcha' in have make sure docpad plugin clean urls installed in project.

javascript - Duration of Video in Express.js: NaN -

i trying total duration of video, in express.js. below have shown code in jade. include video in webpage. video(width='320', height='240', controls='controls') source(src='/images/video.mp4', type='video/ogg', id='thevideo') then call folowing function on button click. function getcurrenttime() { var video = document.createelement('video'); var time = video.duration; document.getelementbyid('mytime').value=time; } 'mytime' text box. input(id='mytime', size='5') but when run video, duration nan. tried read posts on why happens, , apparently related "byte" problem, or sending headers or that. can please explain me reason why happening , how can fix it? thanks. try this: jade: video(width='320', height='240', controls='controls', id='thevideo') source(src='/images/video.mp4', type='video/ogg...

php - how to retrieve data in codeigniter without post it? -

i want session fname welcome admin site(crud), session username have because delclare $_session['username'] = $this->input->post('username'); , question how make session fname database? database sql create table if not exists `users` ( `id` int(11) not null auto_increment, `username` varchar(30) not null, `password` varchar(32) not null, `fname` varchar(30) default null, `lname` varchar(30) default null, primary key (`id`) ) controller <?php if(!defined('basepath')) exit('tidak ada akses!'); class c_login extends ci_controller{ function __construct(){ session_start(); parent::__construct(); $this->load->model('m_user'); } public function index(){ if(isset($_session['username'])){ redirect('crud'); } $this->form_validation->set_rules('username','username','required'); $this->form_validation->set_rules('passwor...

python - Getting vertical gridlines to appear in line plot in matplotlib -

Image
i want both horizontal , vertical grid lines on plot horizontal grid lines appearing default. using pandas.dataframe sql query in python generate line plot dates on x-axis. i'm not sure why not appear on dates , have tried search answer couldn't find one. all have used plot graph simple code below. data.plot() grid('on') data dataframe contains dates , data sql query. i have tried adding code below still same output no vertical grid lines. ax = plt.axes() ax.yaxis.grid() # horizontal lines ax.xaxis.grid() # vertical lines any suggestions? you may need give boolean arg in calls, e.g. use ax.yaxis.grid(true) instead of ax.yaxis.grid() . additionally, since using both of them can combine ax.grid , works on both, rather doing once each dimension. ax = plt.gca() ax.grid(true) that should sort out.

html5 - How to replace character from array items using javascript? -

i have got array items dynamically ["{text: "us"}", "{text: "mexico"}", "{text: "brazil"}"] . need replace char "{ char { , char }" char } . after replacing need output [{text: "us"}, {text: "mexico"}, {text: "brazil"}] . if single object means can replace. array list not getting. have tried below, 1 not working how can achieve one? great appreciated. thank you. dynamicsubregions =["{text: "us"}", "{text: "mexico"}", "{text: "brazil"}"]; var dynamicsubregionsfinal = dynamicsubregions[dynamicsubregions.indexof('"{')] = '{'; your array syntax wrong , double quotes arn't inside variable dynamicsubregions =["{text: \"us\"}", "{text: \"mexico\"}", "{text: \"brazil\"}"]; alert(dynamicsubregions[0]); http://jsfiddle.net/dftgy/ ...

Upload Image iOS to PHP -

i trying upload image ios application php backend. have followed samples online; however, receiving php error code of 3 (upload_err_partial). can me out? i'm using [nsurlconnection sendasynchronousrequest:queue:completionhandler]. i have read people disable connection header, isn't working either. there server side should check? <? $uploaddir = ''; //uploading same directory php file $file = basename($_files['userfile']['name']); $uploadfile = $uploaddir . $file; if ($_files['userfile']['error'] === upload_err_ok) { } else { die("upload failed error code " . $_files['userfile']['error']); } ?> you can upload/send data on php using post/get method of ios. for post method http post method php , ios for method http://codewithchris.com/tutorial-how-to-use-ios-nsurlconnection-by-example/ for both how send post , request?

Splitting array not working in android -

i splitting string sample text in middle. not splitting. please me went wrong string[] str; parts[1] = "loopstwatch out testingloopstthis makes difference"; str = parts[1].trim().split("loopst"); string[] arr; arr = "loopstwatch out testingloopstthis makes difference".trim().split("loopst"); log.e("data arr[0]",":"+arr[0]); log.e("data arr[1]",":"+arr[1]); log.e("data arr[2]",":"+arr[2]); output arr[0] :"" arr[1] :"watch out testing" arr[2] :"this makes difference"

hashmap - Objects in java. What happens with them after they are no more assigned to a variable? -

this question has answer here: what garbage collector in java? 17 answers i've been working hashmaps when came question couldn't solve myself or find on web. hashmap<string,hashmap<string,string>> m= new hashmap<>(); hashmap<string,string> t = new hashmap<>(); t.put("test1","1"); m.put("h1",t); t = new hashmap<>(); t.put("test2,"2"); m.put("h2",t); system.out.println(m); that gives me {h1={test1=1}, h2={test2=2}} big hashmap contains data of both hashmaps. question did copy data of smaller hashmaps, or both "t" hashmaps stay in jvm memory, , hashmap m links me them? whenever place t m , no copy of data made. instead, reference sub-map placed. you add t m twice. however, each time t points different object. end 2 separate, independent s...

Queue/Linked List in Java not setting properly -

i creating program complete "one tough puzzle" game using depth first search (irrelevant). have algorithm pretty complete. however, when poll() off queue, middle pieces same (explained below) i using 1d array length of 9 type piece state class hold current board, available pieces, parent node board gets set by: board = new piece[9]; for(int = 0; < 9; i++) board[i] = new piece(); this code adds each piece middle of board, , adds queue (puzzle) for(int = 0; < 9; i++) { piece[] b = board; b[4] = pieces[i]; piece[] p = removeelement(pieces, pieces[i]); // remove array puzzle.add((new state(b, p, null))); } just simple test me show myself wasn't going crazy, used code while((s = puzzle.poll()) != null) { string ss = getavailable(s.returnpieces()); system.out.println("middle:"+s.returnboard()[4].getpieceid() + " :::: "+ ss); } this returned mid...

java - create a global reference in JNA -

the native library want use have method this: extern unsigned long write(void); what going write, however, need defined in several global variable: short int addr; //the starting address write to; short int length; //the length of writing; void * data; //the data write; i know in jna, nativelibray have method load global reference defined in native library, seems not needed here. need declare above global variables , write them, write() method can work properly. any suggestion on how implement in jna? thanks. so many game hackers unwilling dirty details. nativelibrary provides access addresses of global variables exported shared library. nativelibrary lib = nativelibray.getinstance("mylib"); pointer paddr = lib.getglobalvariableaddress("addr"); paddr.setint(0, 1234);

canvas - How does Blur Filter work in HTML5 Kinetic.Filters.Blur -

how can use blur filter in html5? find this: kinetic.filters.blur(imagedata, config ) and parameters: imagedata {object} config {object} config.radius {integer} explain me example how can this. var image = new kinetic.image({ x: 10, y: 10, image: imageobj, filter: kinetic.filters.blur, filterradius: 20 }); checkout tutorial: http://www.html5canvastutorials.com/kineticjs/html5-canvas-tween-blur-filter-with-kineticjs/

keyboard - WPF enqueue and replay key events -

Image
i'm trying improve responsiveness of wpf business application when users "between" screens waiting new screen appear after server response, can still entering data. i'm able queue events (using previewkeydown event handler on background panel) i'm having difficulties throwing events dequeue @ new panel once it's loaded. in particular textboxes on new panel not picking text. i've tried raising same events (setting handled true when capturing them, setting handled false when raising them again) creating new keydown events, new previewkeydown events, doing processinput, doing raiseevent on panel, setting focus on right textbox , doing raiseevent on textbox, many things. it seems should really simple , can't figure out. here of things i've tried. consider queue of keyeventargs called eventq: here's 1 thing doesn't work: while (eventq.count > 0) { keyeventargs kea = eventq.dequeue(); tbone.f...

Regex for Visual Studio Find Replace "Using" statement -

i following link: find , replace regular expression c# in case, want replace following kind of code: using(some code here) { var result = method call... return result; } to: some code here var result = method call... return result; so getting rid of using statement. or link start me with.

httprequest - Best library for http request for iOS apps? -

in iphone app, use asihttprequest api make curl based http requests. heard api not being maintained , times crashes app. need go other api can make curl requests restful api gives json response. can 1 suggest me best alternative asihttprequest use in production app? a alternative asihttprequest afnetworking. there tutorials how integrate afnetworking code, below find one. http://www.raywenderlich.com/30445/afnetworking-crash-course

zend framework2 - ZF2: Get module name (or route) in the application layout for menu highlight -

how can in zf2 current (selected) module name in application layout? purpose: application layout include main menu of zf2 app, , every time module selected need highlight menu voice of module. need set correct route (url, action) when menu made for. every module has menu voice: <ul class="nav"> <?php foreach ($menu_modules $mod): $is_active = ($mod['name'] == $current_module_name)?'selected':'';//get module name ?> <!-- class="active" --> <li><a href="#" <?php echo $is_active;?> ><?php echo $mod['title']; ?></a></li> <?php endforeach; ?> <li><a href="<?php echo $this->url('login/process', array('action'=>'logout')); ?>"><?php echo $this->translate('logout') ?></a></li> </ul> <div class="row-fluid" id="main_container"> <?php e...

c# - Can I "block" a function until an asynch thread has finished? -

i have code on winform: private void buttonstart_click(object sender, eventargs e) { task.factory.startnew(() => threadfunction()) .continuewith(t => threadfunctioncomplete() , cancellationtoken.none , taskcontinuationoptions.none , taskscheduler.fromcurrentsynchronizationcontext()); threadfinished(); } and i'd start threadfinished() when threadfunctioncomplete() has been finished. well, put threadfinished() @ end of threadfunctioncomplete() , workflow of process won't. possible? sort of wait/lock maybe? basically, can call continuewith twice: task.factory.startnew(....) .continuewith(...) .continuewith(...)

memory - Do I need to manually dispose of a java tree structure when it is no longer needed? -

i construct lots of object trees in applications, each node typical tree node (reference parent , list of references children). these trees temporary, meaning might dispose of them before application terminates. so far i've added method tree node class able recursively traverse tree branch , "destroy it" (set parent reference null , clear children list, etc.). public void destroy() { (node node : children) { node.destroy(); } parent = null; children.clear(); } this made sense me, since null-ing reference root of tree have stored somewhere not enough - children might still have reference it, meaning stay in memory , cause memory leak. correct in assuming , providing such method? the reason why i'm doubting myself see such methods in apis provide tree structure support (at least not directly in tree node interfaces). proper pattern dealing such cases? you not need destroy or clean objects yourself. you need make sure there ...

android - Androip phonegap GPS accuracy -

in following code trying gps location phonegap example.iam trying on actual device , not on emulator time out every time.i never got on success alert.what doing wrong.i have enable gps , internet js document.addeventlistener("deviceready", ondeviceready, false); var watchid = null; // cordova ready // function ondeviceready() { // throw error if no update received every 30 seconds var options = { timeout: 30000 }; watchid = navigator.geolocation.watchposition(onsuccess, onerror, options); } // onsuccess geolocation // function onsuccess(position) { var element = document.getelementbyid('geolocation'); element.innerhtml = 'latitude: ' + position.coords.latitude + '<br />' + 'longitude: ' + position.coords.longitude + '<br />' + '<hr />' + element.innerhtml; } // onerror callback receives positionerror object // function onerror(error) { alert(...

PHP - Syntax [array / variable] -

i want use stripos() filter variable $background , if characters found return keys value $background ; if(stripos($background, $color) !== false) { $background = value of keys in $color } else { $background = 'no color found'}; $color = array ( 'r' => "red", 'y' => "yellow", '$bgcolor' => array ( '#ffffd0' => "yellow", '#ddffdd' => "green", )); the variable $bgcolor defined , returns hexadecimal color code. above syntax correct ? use double quotes variable key . strings single quotes ignoring variables. <?php header('content-type: text/plain;'); $x = 'check'; $str = "$x"; echo $str, php_eol; $str = '$x'; echo $str, php_eol; ?> shows: check $x for rest part of code you`ve provided, guess want this: <?php //header('content-type:...

excel - Update values of 2 Cells at the same time -

i have 7 worksheets containg information room project university, need search each sheet information, if computer pool or not. want copy pools worksheet , can update information sheet , auto updates orignal worksheet. my main problem don't know how update function called. attached code in bottom copies rooms dedicated sheet. in advance option explicit sub start() dim suche string dim blatt1 string dim blatt2 string dim blatt3 string dim blatt4 string dim blatt5 string dim blatt6 string dim blatt7 string dim result string blatt1 = "1. stock mzg" blatt2 = "5. stock mzg" blatt3 = "6. stock mzg" blatt4 = "7. stock mzg" blatt5 = "8. stock mzg" blatt6 = "1. stock oec" blatt7 = "2. stock oec" suche = "poolraum" if len(suche) result = "es wurde(n) " & auswahlkopieren(suche, true, blatt1) & " zeile(n) aus '" & blatt1 & "' kopiert!" res...

html - CSS block float left margin to full parent width -

html: <div class="main_block"> <div class="block"> <p>some title</p> <img src="some_image.png" /> </div> <div class="block"> <p>some title</p> <img src="some_image.png" /> </div> <div class="block"> <p>some title</p> <img src="some_image.png" /> </div> </div> css: div.main_block { width: 600px; } div.main_block div.block { width: 100px; margin-left: 100px; } div.main_block div.block:first-child { margin-left: 0; } div.main_block div.block:hover { border: 1px solid orange; } div.main_block div.active { border: 1px solid orange; } is there make automatically?, everytime main width changes, have change children margins , width, or how make more efficiently?, if add border blocks while hovering them, if on max margin ...

python + matplotlib: barh plot show incomplete YTick labels - how to dynamically move the plot area to the right to fit the given YTickLabels? -

Image
i'm using matplotlib plot barh plot file. unfortunate, yticklaels bit long , plot area won't move right automatically. there way move plot area right automatically won't have problems incomplete yticklabels? the code use following: import matplotlib mpl mpl.use('agg') import matplotlib.pyplot plt d = {u'label1':26, u'label2 longer others': 17, u'label3 not short either':30} fig = plt.figure(figsize=(5.5,3),dpi=300) ax = fig.add_subplot(111) ax.grid(true,which='both') bar = ax.barh(range(1,len(d)+1,1),d.values(),0.4,align='center') plt.yticks(range(1,len(d)+1,1), d.keys(), size='small') fig.savefig('d_bar.png') here output: how can fix this? thanks actually, there automatic way of doing now: tight_layout . in case: import matplotlib mpl mpl.use('agg') import matplotlib.pyplot plt d = {u'label1':26, u'label2 longer others': 17, u'label3 not short eithe...

android - set turkish language for text to speech -

this question has answer here: using text speech apis in android application 3 answers im working on text speech app , want set turkish language this: tts.setlanguage(locale.tr); but not available in android , wrong add way or there different way add turkish language text speech . any , advice appreciated text speech code : public class androidtexttospeechactivity extends activity implements texttospeech.oninitlistener { /** called when activity first created. */ private texttospeech tts; private button btnspeak; private edittext txttext; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); tts = new texttospeech(this, this); btnspeak = (button) findviewbyid(r.id.btnspeak); txttext = (edittext) findviewbyid(r.id.txttext); // button on click event ...

sql server 2008 r2 - How to access nested elements in xml with OpenXML -

i'm trying import data rather large xml file sql server. after online searching settled upon using openxml. query have far is declare @doc int declare @xml xml select @xml = evnt openrowset (bulk 'c:\archive.xml', single_blob) import(evnt) exec sp_xml_preparedocument @doc output, @xml select * openxml( @doc, '/events/eventdata/event', 2) ( id varchar(max) ) exec sp_xml_removedocument @doc in way i'm able elements listed inside 'event', how element 1 more level down 'event'. example how 'custid' tag below? <event> <custromattribute> <custid>... the items inside 'event' needed hence path cant changed. other approaches nice too. need run sql server can't use ssis or other similar external tools. xquery seems take lot of time. i'm using sql server 2008 r2 if interested solution above question simple enough. select * openxml( @doc, '/events/eventdata/event') (...

Printing to PDF in PHP using FPDF -

i trying make function on website whereby article can made pdf file download and/or printing. using fpdf library i'm struggling understand best way pdf page receive information. what thinking far make hidden form elements within article page , use them send information, take , insert pdf using $_post. like: <form action="pdf_printer.php" method="post"> <input type="hidden" name="title" value="<?php echo $title; ?>"/> <input type="hidden" name="body_text" value="<?php echo $body_text; ?>"/> <input type="submit" name="submit" value="print"> </form> and pdf_printer.php like: require('fpdf.php'); $pdf = new fpdf(); $pdf->addpage(); $pdf->setfont('arial','b',16); $pdf->cell(60,10, $_post['title'];,0,1,'c'); $pdf->ln(20); $pdf->cell(60,10, $_post['body_text'],0...

Creating a custom XCode project template with subfolders -

Image
i have been playing project templates in order create custom template. know how create subgroups, create empty folder represented group. problem comes when try create more complicated structure subfolders. closest approach got these lines of code inside templateinfo.plist: <key>definitions</key> <dict> <key>parent</key> <dict> <key>path</key> <string>parent</string> </dict> <key>parent/child</key> <dict> <key>group</key> <array> <string>parent</string> </array> <key>path</key> <string>parent/child</string> </dict> </dict> <key>nodes</key> <array> <string>parent</string> <string>parent/child</string> </array> but adding 2 references child, 1 pointing correct child folder, , other ...

Delphi Chromium Embedded - Refresh page with F5 -

i using delphi chromium embedded in application, , have following question: how can emulate f5 key refresh page ? in onkeyevent use following code: uses ceflib; procedure tform1.chromium1keyevent(sender: tobject; const browser: icefbrowser; event: tcefhandlerkeyeventtype; code, modifiers: integer; issystemkey: boolean; out result: boolean); begin if (event = keyevent_rawkeydown) , (code = vk_f5) begin result := true; chromium1.browser.reload; end; end;

perl - Getting Error while running PPM in command prompt in Windows -

using active state perl. getting following error while running ppm command. please let me know whats issue. c:\documents , settings\mishrade1\desktop>ppm can't log 'c:\perl\temp/ppm4.log': no such file or directory @ c:/perl/lib/a ctiveperl/ppm/logger.pm line 95. [ppm:13] can't log 'c:\perl\temp/ppm4.log': no such file or directory @ c:/p erl/lib/activeperl/ppm/logger.pm line 95. [ppm:81] ppm gui [ppm:13] defined(%hash) deprecated @ c:/perl/lib/activeperl/ppm/gui.pm line 1890. [ppm:13] (maybe should omit defined()?) [ppm:85] ppm gui: unable open key: system cannot find file specified. @ c:/perl/lib/activeperl/ppm/gui.pm line 57. compilation failed in require @ c:\perl\bin/ppm line 115. ppm gui failed: unable open key: system cannot find file specified.

how to call javascript function from jQuery ajax? -

i have jquery ajax call results server, , in success, code should call javascript function not in jquery region code, got error in firebug: call of function doesnt have reference. here code (see ajax call in function addgmarker): function test1234(res) { preinfo = res; popupcontenthtml = devicemoreinfo_callback_forgoogle(preinfo); var sum = '<p>please, select <b>[sensors reading list]</b> tab view vehcile sensors reading, , select <b>[device communication commands]</b> tab send commands device:</p><br/>'; var tabs = [ new maxcontenttab('sensors reading list', maxcontentdiv), new maxcontenttab('device communication commands', maxcontentdivforcommands)]; this.openmaxcontenttabshtml(map, popupcontenthtml, sum, tabs, { maxtitle: "sensors , features" }); var iw = map.gettabbedmaxcontent(); iw.id = this.id; gevent.addlistener(iw, 'selecttab', function (tab) { ...

java - Mockito pattern for a Spring web service call -

my class under test has method public somewebserviceresponse calldownstream(somewebservicerequest request) { return (somewebserviceresponse ) super.callservice(request); } the super method call spring ws make call - in simplified form response = getwebservicetemplate().marshalsendandreceive(this.getbaseurl(), request); return response; when write unit test tried make actual web service call. i'm not clear how mock or rather should mocking. should loading sample response filesystem , looking string in - in case i'm testing file loading. the actual call in base class , know can't mock method. pointers? spring provide facilities mocking web service servers requests clients. chapter 6.3 in spring ws manual shows how mocking. the spring ws mocking facility changes behaviour of web service template, can call method in super-class - method call spring mock service server. here sample unit test spring mock service server: @runwith(springjun...