Posts

Showing posts from September, 2013

php - How to dynamically switch databases at loadtime in Wordpress? -

what i'd have 2 or more wp databses under same instalation, each own posts, , dynamically switch between them @ loading time. for example, instead of directly plugging wp when visitor loads site, first run php script geo-location , based on script's result tell wp database load up. i know switch_blog understand it's backend technique it's expensive run on front-end. thanks

file - python fcntl does not lock as expected (2) -

i'd use lock_ex prevent other processes modify file under modification. process a: from fcntl import flock, lock_ex, lock_nb time import sleep f=open("tmp.txt", "w") flock(f.fileno(), lock_ex|lock_nb) f.write("xxxx") f.flush() sleep(20) f.close() 5 seconds after starts, process b: f=open("tmp.txt", "w") f.close() and "tmp.txt" emptied process b... no ioerror raised in process b. how can 1 prevent "tmp.txt" modified 2 processes using exclusive access ? note: "innocent" process b not use flock(), fopen() create new file. what's use of exclusive lock on file if else can modify file ? of course, if b uses flock() well, raises ioerror, if not ??? by default, flock advisory locking mechanism. more details, see this question .

javascript - Change template for Kendo Mobile ListView on setDataSource? -

i changing datasource using setdatasource method, need change template too. changing template dynamically doesn't seems work though. below have , jsfiddle here: http://jsfiddle.net/mfsup . notice doesn't change "template 2" in "onfilter" event when clicking on button group. bug or doing wrong? new kendo.mobile.application(); var ds1 = new kendo.data.datasource({ data: [{ stagename: "ds1 a", b: "1b" }, { stagename: "ds1 b", b: "2b" }] }); var ds2 = new kendo.data.datasource({ data: [{ stagename: "ds2 a", b: "1b" }, { stagename: "ds2 b", b: "2b" }] }); var onfilter = function (e) { var lv = $("#stages_listview") .data('kendomobilelistview'); //change template doesn't work lv.options.template = this.selectedindex == 0 ? $("#stages

How can I assign HTML attribute values using handlebars.js? -

let's have following html code - <input type="text" placeholder="name" /> which want convert to <input type="{{type}}" placeholder="{{text}}" /> how can using handlebars.js?

Laravel custom helper class not found -

i've created custom php helper class use in laravel 4 project. the sashelper.php file in app/libraries/elf/sas , after adding libraries composer.json file i've done composer dumpautoload. autload_classmap (last line only): 'elf\\sas\\sashelper' => $basedir . '/app/libraries/elf/sas/sashelper.php', helper class (simplified brevity): <?php namespace elf\sas; class sashelper { static public function supportinttotext($status) { return 'supported'; } static public function lictypetotext($lic) { return '32-bit'; } } when attempt call either static method controller: $statustext = sashelper::supportinttotext($client->supportstatus); at point fiddler reporting: "class sashelper not found." did try global.php? doesn't need composer dump-autoload, , loads class – trying tobemyself rahul i've tried it: (app_path() .'/libraries' , app_path() .'/libraries/elf/sas

ios - Objective-C return subclass based on Xcode project target? -

i have xcode project compile 2 targets, sake of simplicity we'll call them 'foo' , 'bar'. have superclass , 2 subclasses, how can cleanly ensure variable returned different subclass based on project target? so example, have following... viewmanager.h //super class fooviewmanager.h //foo subclass barviewmanager.h //bar subclass ... viewmanager * viewmanager; #if target_foo viewmanager = [[fooviewmanager alloc] init]; #elif target_bar viewmanager = [[barviewmanager alloc] init]; #else viewmanager = [[viewmanager alloc] init]; #endif ... is there way can make code cleaner, in caller class dont need compiler #if statements, , have initialize superclass, , maybe superclass init method can take care of switching based on current project target, , return correct subclass within viewmanager variable? i'm sure there's standard pattern doing in objective-c i'm missing, appreciated! it possible locate required subclass d

mysql - PHP Loop with multiple rows -

i have php code: $number = substr_replace($_post["number"],"44",0,1); $sql="select * channel_did did '%".$number."%' , (client_id = '' or client_id null or client_id = '611') , (extension_id = '' or extension_id null) "; $rs=mysql_query($sql,$pbx01_conn) or die(mysql_error()); while($result=mysql_fetch_array($rs)) { $numbers_list = $result["did"].'<br>'; $email_body = '<font face="arial"> hello, here numbers have requested.<br><br> please aware these numbers in public pool , not reservered, therefore assigned client @ time.<br><br> please make choice possible guarantee number require.<br><br> '.$numbers_list.'<br><br> kind regards,<br><br> customer services<br> integra digital<br><br> tel: 01702 66 77 27<br> email: support@domain.c

c# - Panel and ScrollBar in Windows forms -

i using panel display image in windows forms drawing image in panel in panel_paint event follows: graphics g = panel1.creategraphics(); image im = new bitmap(@"../../data/#3_page2.png"); g.drawimage(im,new point(10,10)); now, image drawn expected, part of bottom of image not displaying height greater forms height. have added vscrollbar now. how make panel view rest of image of vscrollbar. this solution works, if image large enough, there little flicker when scroll (however it's acceptable). first have add vscrollbar right on right of panel , hscrollbar right under bottom of panel. demo requires have vscrollbar named vscrollbar1 , hscrollbar named hscrollbar1 , button named buttonopenimage allow user open image, panel named panel1 used main area draw image: public partial class form1 : form { public form1() { initializecomponent(); //to prevent/eliminate flicker, typeof(panel).getproperty("doubleb

activemq - How We can Store JMS Persistence in DIsk Using Wso2 -

i using wso2esb 4.7.0 , activemq or wso2message borker 2.1.0 <proxy xmlns="http://ws.apache.org/ns/synapse" name="message" transports="https,http" statistics="disable" trace="disable" startonload="true"> <target> <insequence> <log level="full"/> <property name="faisal" value="faisal" scope="default" type="string"/> <property name="target.endpoint" value="jmschecking" scope="default" type="string"/> <store messagestore="faisal5"/> </insequence> <outsequence> <log level="full"/> </outsequence> </target> <description></description> </proxy i wish store messages in system disk how can provide manual store message stor e active mq or mwso2 message brok

c# - Quartz.net setting the timezone for ITrigger? -

itrigger crontrigger = triggerbuilder.create() .withidentity("trigger1", "group1") .withcronschedule(0 0/1 * 1/1 * ? *) .build(); this code sets time run hour before want to, rather running @ 1:40 runs @ 12:40. can set timezone of itrigger work uk time ? there should timezone option when creating trigger. this: .intimezone(timezone.currenttimezone); the above take server's current timezone. if not uk based server, should work. timezoneinfo.findsystemtimezonebyid("gmt standard time"); here link: http://quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-06

jaxb - XJC xsd:any parsing -

i have element in xsd schema: <xsd:any processcontents="skip"/> is possible switch processcontents strict through xjb binding? without modifying schema file. may set global property. want get: @xmlanyelement(lax = true) protected object any; instead of: @xmlanyelement protected element any; you totally change annotation , attribut's type. beware if generate code xsd modifications crushed. could explain little bit more work context, needs , goals. why can't touch xsd, generate classes xsd jaxb? use xsd validation purposes?

iphone - Where to put native code for Phonegap 3.0 plugin? -

i upgraded 1 of projects phonegap 3.0 , wondering proper methodology developing custom plugin. i'm following echo plugin example developer docs. should echo.h , echo.m files go in plugins folder in project root, or within plugins folder specific platform being built? i tried echo plugin ios , it's working me. put echo.h , echo.m under platforms/ios/testproject/plugins/. root folder plugins keep plugins download command line. auto installed when make ios, android or other platforms.

ios - Editing UITableviewCell when table is inside scroll view not working -

i'm trying put uitableview inside uiscrollview . scroll view horizontal paging setup switch between few pages/views. 1 of views has table editable cells. the problem arises when try swipe horizontally on table edit them . scroll view captures swipe first , pages over. know tableview collecting touches because can scroll vertically on no problem. as disable scrolling on scrollview can swipe edit cells in table. is there anyway can swipe on table edit cells still scroll on view if don't swipe on table, or header of table isn't editable? thanks you should subclass uiscrollview , implement below method - (bool)touchesshouldbegin:(nsset *)touches withevent:(uievent *)event incontentview:(uiview *)view this make uiscrollview pass on touches content view uitableview.

listview - android:state_activated not found -

Image
my android project minimum api 10. support v4 included. in android doc found selector state "activated" but when try use it, ide mark missed. here https://stackoverflow.com/... , here https://stackoverflow.com/questions/92.. state looks solution problem, can not use it. it looks may bug in docs. shows screen showing if go r.attr class , @ corresponding variable greyed out api 10 selected , left shows requires api 11 sorry, graphic arts skills aren't great zoom in , see. here solution may or may not work need. didn't read through whole example can give look. and here answer dealing same issue.

bash - loss of data in 2nd insert into associative array -

in code below second insert associative array 'originator', makes first insert lost. check 1st insert succesfull, when put second associative item 'originators', first item empty, in other words, outputs , empty string. have no idea going on. declare -a originators while read -r line if [ "$count" -ge "2" ]; inner_count=0 #parse each line if [ "$debug" = "1" ] ; printf "%s\n" "$line" ; fi word in $line if [ "$inner_count" = "1" ]; tmp1="$word" ; fi if [ "$inner_count" = "5" ]; tmp1="$tmp1"" ---- ""$word" ;fi inner_count=$((inner_count + 1)) done originators=( ["$count"]="$tmp1" ) echo "$count ${originators["$count&q

javascript - Error: Unknown provider: translateFilterProvider <- translateFilter angularjs -

i'm working on angularjs app needs have translation functionality, i've checked angular-translate library , did that's in example. however when run code following error: error: unknown provider: translatefilterprovider <- translatefilter i've included code in following jsfiddle: http://jsfiddle.net/qyqw8/1/ loaded angular-translate javascript file before calling code in fiddle (which in portal.js) order in load files: <script src="js/lib/angular.js"></script> <script src="js/lib/angular-resource.js"></script> <script src="js/lib/jquery-1.10.js"></script> <script src="js/lib/angular-translate.js"></script> <script src="js/portal.js"></script> if can me out it's highly appreciated, in case wondered , since fiddle bit messed up, did bootstrap app <html lang="nl" ng-app="portal"> thx, j.

Socket program in C cannot compile -

hi guys reading book socket programming , there 2 codes client , server. here server code #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> void error(char *msg) { perror(msg); exit(1); } int main(int argc, char *argv[]) { int sockfd, newsockfd, portno, clilen; char buffer[256]; struct sockaddr_in serv_addr, cli_addr; int n; if (argc < 2) { fprintf(stderr,"error, no port provided/n"); exit(1); } sockfd = socket(af_inet, sock_stream, 0); if(sockfd < 0) error("error opening socket"); bzero((char *) &serv_addr, sizeof(serv_addr)); portno = atoi(argv[1]); serv_addr.sin_family = af_inet; serv_addr.sin_addr.s_addr = inaddr_any; serv_addr.sin_port = htons(portno); if(bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) <0) error("error on binding"); listen(sockfd,5);

php - What can I do to speed up Behat tests on a Selenium CI server? -

i've set jenkins ci server, , have suite of behat tests running. however, take age complete. i using rhel6 , have selenium, firefox, xvfb running default config. i'm assuming stuff can adjusted (more memory allocated?), no idea try tweaking. suggestions? yes more memory need allocated , if possible, if possible set jvm related parameters while starting jenkins garbage collection; http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

android - Handle exit application from Task Manager -

Image
as know samsung, htc have custom task manager menu below. menu can popup long press home button. if application working in background , if close task manager, can not handle it. activity ondestroy method not invoked. unfortunately there isn't answer handling situation. if app force-killed, ondestroy method isn't called. according documentation note: not count on method being called place saving data! example, if activity editing data in content provider, edits should committed in either onpause() or onsaveinstancestate(bundle), not here. if can, clean in onpause() method. in order user screen kill app, has have been backgrounded , onpause() called. ( see documentation ) it looks you're in similar situation question being asked in thread - https://stackoverflow.com/a/3856300/413254

asp.net mvc - Visual Studio 2012 crashing when called web service -

i added soap web service "web reference" in visual studio. working on mvc application. have working fine in console application not in mvc. can call methods when try create instance of web service, huge memory leak happens , visual studio crashes. reference.cs file contains 300k lines, commenting out not using. wondering if there better solution. 2 hours later + 250k lines commented out = problem solved!!

php - Laravel: paginating a fluent query -

i'm trying paginate page in view this: @foreach($tasks $task) {{ $task->user_id }} {{ $task->client_id }} {{ $task->description }} {{ $task->duration }} {{ link_to_route('clients.show', 'view client', array($task->client_id), array('class' => 'btn btn-primary')) }} @endforeach {{ $tasks->links() }} using following query in controller: $tasks = db::table('tasks') ->join('users', 'tasks.user_id', '=', 'users.id') ->join('clients', 'tasks.client_id', '=', 'clients.id') ->select(array('tasks.description', 'tasks.duration', 'tasks.client_id', 'tasks.user_id', 'users.email', 'clients.name')) ->where('tasks.group_id', '=', $usergroup) ->orderby('tasks.created_at', 'desc') ->paginate(20); return view::make(&#

Design for importing definition data from Excel into SQL Server -

we have restaurant inventory control system uses sql server 2008 r2. it takes long time add definition data: stock items, yields, packsizes, recipes, categories etc. so, our clients have asked if can upload excel. before jump in , start, want find out if there best practice way this. i know tools: ssis, stored procedures etc. i'm looking advice/resources can design process. how best setup spreadsheet, validate data, create child/parent relationships etc. this must common project -- must have standard design/approach , that's i'm looking for. i think design depend on technologies you're comfortable with. if you're comfortable ssis , stored procedures, general pattern use: excel template - wouldn't spend time on this, add headers , sheets necessary tables. can lock down things and/or implement rules, of validation done in stored procs. ssis - have package loads excel data staging tables, have rows errors added error log presented user al

xml - Discrepancy between docbook.dtd and docbook.rng on the DocBook 5.0 Distribution -

when validate document, using relaxng , docbook.rng schema provided on docbook 5.0 distrution turn errors this: error: attribute "title" not allowed @ point; ignored and offending xml element "informaltable". in fact, read o o'reilly site basic definition of informaltable table without title. however, docbook.dtd dtd provided on same distribution specified "title" attribute on informatltable. error in dtd? dtd snippet, included here, reference. if dtd indeed incorrect, there correct 1 around somewhere, or can generate somehow? <!element informaltable (info?, ((textobject*, (mediaobject+|tgroup+))|((col*|colgroup*), thead?, tfoot?, (tbody+|tr+))))> <!attlist informaltable xmlns cdata #fixed "http://docbook.org/ns/docbook" role cdata #implied %db.common.attributes; %db.common.linking.attributes; tabstyle cdata #implied floatstyle cdata #implied orient (land|port) #implied

tfs - How do I make Request Review available to everyone in Team Foundation Server 2012? -

when log tfs visual studio 2012 , go check in code can see "request review" option under actions. when others log in can not see option under same project. have looked through security permissions , can not find setting allow specific groups. do 1 know setting may be?

javascript - Magento setAttribute error on checkout page -

ok when "proceed checkout", gives list of : checkout method billing information shipping information shipping method payment information order review by default, checkout method suppose dropped down , when hit "continue", billing information drop down similar : http://www.plazathemes.com/demo/ma_musicgear/index.php/checkout/onepage/ however, when go page, checkout method isn't dropped down , whenever click on it, nothing happens. these js errors: uncaught typeerror: object [object object] has no method 'attachevent' prototype.js:5644 2 uncaught typeerror: object [object object] has no method 'attachevent' prototype.js:5653 uncaught typeerror: object [object object] has no method 'setattribute' clearchannel.halfoffdeals.com/index.php/checkout/onepage/:349 uncaught typeerror: object [object object] has no method 'attachevent' prototype.js:5644 uncaught typeerror: object [object object] has no method 'observe&#

python 2.7 - Plotting points on Mapnik -

i followed tutorial in mapnik github wiki make world map: https://github.com/mapnik/mapnik/wiki/gettingstartedinpython i modified example, , have embedded code pyside qt widget. question is, how 1 plot points on map using x , y coordinates, or latitude , longitude points? here code i'm using generate map , embed in widget: import mapnik m = mapnik.map(1200,600) m.background = mapnik.color('steelblue') s = mapnik.style() r = mapnik.rule() polygon_symbolizer = mapnik.polygonsymbolizer(mapnik.color('#f2eff9')) r.symbols.append(polygon_symbolizer) line_symbolizer = mapnik.linesymbolizer(mapnik.color('rgb(50%,50%,50%)'),0.1) r.symbols.append(line_symbolizer) s.rules.append(r) m.append_style('my style',s) ds = mapnik.shapefile(file='/home/lee/shapefiles/ne_110m_admin_0_countries.shp') layer = mapnik.layer('world') layer.datasource = ds layer.styles.append('my style

sql server - Is it good idea to batch multiple merge in a stored procedure -

i trying write stored procedure multiple insert/update/delete on different tables. so sp looks this. right way do? begin merge 1 end begin merge 2 end begin merge 3 end or should follow this begin merge 1 merge 2 merge 3 end help!! you should have follows: begin merge 1 merge 2 merge 3 end see @aaronbertrand's comments above further clarification.

sql server - Ordering a SELECT - Logical issue (SQL) -

Image
i'm stuck in logical issue , don't know how proceed. i have 2 columns: id , folderid. folder can subfolder too, want order result first selecting folders has no folderid (root folder), , subfolders , on. way not have problem "folder x doesn't exists". in example, can´t need simple ordering folderid asc and/or id asc. the correct result 3rd one: first, id 2 "teste" folder because has folderid 0 = root one. now want "controladoria" folder, because folderid 2, needs folder id 2 created first (teste) "pcp" folder, needs folder id 1 (controladoria) "pasta1" folder, needs folder id 3 (pcp) on , on... i've tried several ways multiple order , join/left join in same table can´t figure out how can this. any ideas? using simple recursive query can these results. ;with cte (select *, 1 rn table1 folderid = 0 union select t1.*,

java - Android WebView javascript support -

i using android's built in webview show user. insert custom javacsript page user is viewing, since it's rather complicated javascript (lets call userscript, because acts using example chrome's userscript on specific page only) im interested differences in chromes webview in different devices? i guess using stock "browser" rendering, javascript support, css3 support etc. on different devices. just clear. webview on android version of webkit customised android platform. it's not version of chrome. chrome android stays date as possible desktop chrome. on ios believe webview single core version of safari browser has differences. chrome ios uses webview display web content. regarding support best thing @ sites such http://caniuse.com/

delphi - TChromium How To Catch OnMiddleMouseClick Event? -

i need open link in new tab, if pressed middle mouse button, there no events in tchromium, onmousedown or else. there onprekeyevent , onkeyevent, not need. allmost tryed catch click events, this: procedure tform1.chromiumprekeyevent(sender: tobject; const browser: icefbrowser; const event: pcefkeyevent; osevent: pmsg; out iskeyboardshortcut, result: boolean); begin if(event.windows_key_code=13) showmessage('enter pressed pre key event : '+inttostr(event.windows_key_code)) end; but not working mouse buttons. can me ? thanks.

r - Convert from character to Date -

i running date issues when working dates in r. here's situation- i have data set based on dates , got date field converted character date in r using following code o1$date <- as.date(o1$date , "%m/%d/%y") (my dataset o1 , date name of date column) my date column has following values "1/1/2013" "1/1/2014" "1/10/2013" "1/10/2014" "1/11/2013" "1/11/2014" however when convert char date following dates "2020-01-01" "2020-01-01" "2020-01-10" "2020-01-10" "2020-01-11" any suggestions on problem , how work around it? look @ ?strptime see formatting options times , dates. need use %y rather %y 2 digit year.

Using codeigniter to execute code from another file -

i new codeigniter , used old school php scripting i'll need this: i want include captcha system in 1 of forms. according documentation , generate image, need this: <img id="captcha" src="/securimage/securimage_show" alt="captcha image" /> i downloaded files, put them? , how use codeigniter call securimage_show.php file? , output contents src attribute of image? when adding captcha in fuel (a codeigniter based cms), i've put php file generates captcha image in folder put images, link same way link image: <?php echo img(array('src'=>'image_show.php', 'alt'=> 'captcha image')); ?> perhaps not nicest solution, works. alternatively, use captcha plugin written codeigniter, such nucaptcha codeigniter plugin, http://docs.nucaptcha.com/plugins/codeigniter .

php - Must use set method -

i'm trying figure out why i'm getting error you must use "set" method update entry. when use following method. using jamie rumbelow's my_model this. $this->failed_login->insert_login_attempt($this->input->ip_address(), $post_username, gmdate('y-m-d h:i:s', time())); public function insert_login_attempt($user_ip_address, $username, $datetime_of_attempt) { $failed_attempt = array( 'user_ip_address' => $user_ip_address, 'username' => $username, 'datetime'); $this->db->insert($failed_attempt); } $this->db->insert needs know table want insert table into. how know put data if don't give table? :-p $failed_attempt = array( 'user_ip_address' => $user_ip_address, 'username' => $username, 'datetime' => $datetime_o

sass - False positive "undefined variable" error when compiling SCSS -

getting error message when compiling scss using ruby compass gem. run: /var/lib/gems/1.8/gems/compass-0.12.2/bin/compass compile out: unchanged sass/partial/grid.scss out: error sass/partial/catalog.scss (line 5: undefined variable: "$paragraphfont".) out: create css/generated/partial/catalog.css out: create css/generated/partial/base.css out: overwrite css/generated/screen.css my screen.scss imports partials this: @import "partial/base"; @import "partial/catalog"; in base partial have $paragraphfont defined. $paragraphfont: 'lucida sans', arial; $regularfontsize: 14px; and in catalog.scss use it: .product-view #price-block { p { font-weight: normal; font-family: $paragraphfont; .... } } weird thing css gets compiled fine, , $paragraphfont populated correctly. don't know why compiler complaining @ me error. you're generating files don't need generated. scr

HTML and CSS div not hitting the top of the browser viewport -

Image
the problem: ( http://i.imgur.com/mu5hboa.png ) as can see in image above maincontent floats below actual top op browser view port, cant make stick top , stay centered @ same time. also quick side question, how #maincontent, .rightcontentborder , .leftcontentborder height #contentbox id body { background-image:url(img/campusdjursland_tourneyhjemmeside_grafik/resten/bg_pattern.png); background-repeat:repeat; font-family:"trebuchet ms", arial, helvetica, sans-serif; } p { text-align:left; } li { text-align:left; } #contentbox { margin: 1px auto 1px auto; width:786px; height:auto; min-height:700px; max-height:none; } .leftcontentborder { width:27px; height:700px; float:left; background-image:url(img/campusdjursland_tourneyhjemmeside_grafik/resten/leftside_orangebar1px.png); background-repeat:repeat-y; } .rightcontentborder { width:27px; height:700px; float:right; background-image:url(i

timezone - how can I set db2 CURRENT_TIMEZONE? -

system timezone , db2 timezones not matching. current system timezone -5000 , db2 gives me -40000 following query select current_timezone sysibm.sysdummy1 how , can set value? i hope select dbname, tsname, dsnum, ictype, timestamp - current timezone sysibm.syscopy;

asp.net - SQL Statement - Select data from database with condition - MVC4 -

i have written sql statement select data database in mvc4 . what try select data compare value. here mean: @{ var db = database.open("defaultconnection"); var data = db.query("select * mag mytitle= model=>model.title"); } i want make condition filter data. and in html this: <ol> @foreach (var image in data) { <li> <img src="@url.content(image.picpath)"/> </li> } </ol> anyone knows how works?. have search lot can´t anything. any appreciated: first, move code out of view , put in controller. should avoid putting data access code in view because breaking mvc pattern. second, if move code action in controller, can this: public actionresult index() { var mymodel = getmymodel();//however var db = database.open("defaultconnection"); //don't use actual query below. exposes sql injection //use par

java - How do you create a title screen for an android app? E.g. When the app is loading like Facebook -

hi developing app , cannot find how create title/loading screens when app boots up? new activity or function? appreciated thanks. you want splash screen. there bunch of topics on google it.

android - make viewpagerindicator fragment startup just opened, clicked or swiped and do the loading? -

i use viewpagerindicator, @ startup activity, looks fragment loading. want when fragment startup opened, clicked or swiped , loading. , fragment has not been opened loading when opened, click or swipe later. how it? this code adapter viewpager import android.content.context; import android.support.v4.app.fragment; import android.support.v4.app.fragmentmanager; import android.support.v4.app.fragmentpageradapter; public class viewadapter extends fragmentpageradapter{ private context _context; string[] page_titles; public viewadapter(context context, fragmentmanager fm, string[] page_title){ super(fm); _context = context; this.page_titles = page_title; } @override public fragment getitem(int position) { // todo auto-generated method stub fragment f = new fragment(); switch(position){ case 0: f = contentactivity.newinstance(_context); break; case 1:

routing - CakePHP - How to make routes with custom parameters? -

my cake url this: $token = '9kjhf8k104zx43'; $url = array( 'controller' => 'users', 'action' => 'password_reset', 'prefix' => 'admin', 'admin' => true, $token ) i route prettier url like: /admin/password-reset/9kjhf8k104zx43 however, token @ end optional, in event doesn't provide token still routed to: /admin/password-reset so can catch case , redirect page or display message. i've read book on routing lot , still don't feel explains complex cases in way understand, don't know go this. like: router::connect('/admin/password-reset/:token', array('controller' => 'users', 'action' => 'password_reset', 'prefix' => 'admin', 'admin' => true)); i don't know how optionally catch token , pass url. you'll want use named parameters. example 1 of projects router::connect(

java - ImageIO.write freezes after a while -

i have following code generates image used src of image element in html document: bufferedimage iimage = (bufferedimage) camera.getimage(); servletoutputstream out = response.getoutputstream(); response.setcontenttype("image/jpeg"); imageoutputstream ios = imageio.createimageoutputstream(out); imageio.write(iimage, "jpg", ios); ios.close(); out.close(); the application deployed on apache tomcat. problem image freezing after while, think because of imageio.write, have tried use imageio.setusecache(false); but no success. my question is, there alternative?, why imageio freezing?, can prevent freezing?

exception - Laravel: Class 'CategoryModel' not found. How to access a model inside a sub-folder? -

my categorymodel works when place inside models folder. when place inside sub-folder user . throws above error. the model being called inside controller shown.. public function home() { // titling $data['title'] = "price soldier - home"; // controlling $data['current_category'] = "cellphones"; $data['current_brand'] = "all"; $data['current_sorting'] = "latest"; $data['categories'] = categorymodel::get_all_categories(); $data['brands'] = brandmodel::get_all_brands_by_category("cellphones"); $data['latests'] = productmodel::get_products("cellphones", "all", "latest"); $data['mvs'] = productmodel::get_products("cellphones", "all", "most viewed"); $data['plths'] = productmodel::get_products("cellphones", "all", "price low high")

c# - Is it possible to limit based on navigational property id's? -

my model looks like: city cityblocks houses so city can have many city blocks, , each city block can have many houses. on particular page, have list of house id's want display. the page expects city object, , loops , displays city blocks , houses. one thing afraid of because of lazy-loading, if load things based on list of house id's, show city blocks , houses because of lazy-loading. how can avoid situation page? (i can't disable lazy-loading globally use it). update so doing: var repository = new genericrepository<home>(); var homes = repository.get(home => homeidlist.contains(home.id), includeproperties: "cityblock, cityblock.city") .tolist(); city city = homes.select(h => h.cityblock.city).distinct().firstordefault(); but, isn't working. when loop on city loads everything: @foreach(var block in city.cityblocks) { foreach(var house in block.houses) {

drag and drop - jquery ui draggable element appears behind other elements? -

i using jquery ui draggable, , droppable make possible reorder pictures different boxes. when drag picture out of box appears under other elements once leaves direct container. while googling able found add: helper: 'clone', appendto: "body" this makes being dragged appears on top of elements, leaves original copy still in box , not want that. is there way can make element stay on top of when being dragged? have tried high z-index no avail. here jsfiddle shows first draggle element behind behind second. not issue other way around. not able change position relative on containing divs without breaking lot of other things. http://jsfiddle.net/cbwhx/6/ i found few issues code, think i've worked them out , got working. working example first fix html: <div id="container1" style="background-color:red;padding:20px"> <div class="draggablecontainer"> <div class="draggable&q

java - Building 2 jars with different source with Maven -

i trying build 2 jars 1 java project. 2 jars have exact same source except @ build time 1 build boolean variable set true , 1 build same boolean variable set false. example: jar 1 have same source except in 1 java file have: public static final boolean enable_toast = true; jar 2 have same source except in same java file have: public static final boolean enable_toast = false; i relatively new maven , ant , had idea of using maven-replacer-plugin. however, cannot find has done before. my approach create 3 properties files: app.properties app.properties.test.environment app.properties.prod.environment 2) , 3) have different settings each environment (i.e. enable_toast = false prod , true test) the application, of course, uses app.properties at build time, replace app.properties contents of correct environment (2 or 3) in ant, have 2 targets each copy file command overwrite flag set true. i'm sure maven has similar feature (too busy atm) hop

How can we create a dynamic sql query to run without considering if the parameters are passed or not in c# windows forms -

i using vs 2012 , sql express i trying build windows forms application search through database in c# , has different controls on form passed parameters query. the parameters in query not passed times i trying following code sample. select a.id 'dealid', a.tradedate, c.companyname 'seller company', a.sellcommission, h.broker_fullname 'seller trader', j.displayname 'seller broker', d.companyname 'buyer company', a.buycommission, g.broker_fullname 'buyer trader', i.displayname 'buyer broker', e.product_name, f.type_desc 'quantity type', f.nbr_of_gallons 'quantity multiplier', a.contractvolume, a.totalvolume, a.deliverypoint, a.price, a.contractstart, a.contractend confirmations (nolock) left outer join company c (nolock) on c.company_id = a.sellcompany left outer join company d (nolock) on d.company_id = a.buycompany left outer join bioproducttypes e

html - PHP include form trouble -

i having trouble php includes, , not entirely sure using them correctly. have far html page want add search bar to. php code in html page looks this. <?php include 'site/tools/search.php'; ?> the problem having search bar not displaying on html page. know search bar works, because have browsed file location , worked actual search bar. you cannot use php code in html documents. change extension of .html file .php , should work without affecting anything. mean links page have changed accordingly.

php - YiiBooster Select2Row Data/Tag Issues -

so i've been trying select2row work me forever , can't seem hang of it. i'm trying provide user tags list school/university name, while @ same time storing value of said tag when save form. i've noticed cannot use both data , tags, else drop down wont populate that's not option. tags seem want text, rather text , matching values. ideas? <div class="row"> <?php echo $form->select2row($model, 'school_id', array( 'asdropdownlist'=>false, 'options'=>array( 'tags'=>school::model()->schoolnames, //'maximumselectionsize'=>1, 'width'=>'297px', 'tokenseparators'=>array(','), ), )); ?> <?php echo $form->error($model,'school_id'); ?> </div> and here function schoolnames public function getschoolna

revert - Re Init() Zend Form after removing some Zend Form Elements -

how can reinitialize created zend form element object had of it's elements remove? $form = new my_header() //my_header class extends zend_form $form->removeelement('id'); $form->removeelement('first_name'); and after lines need $form have these fields added back. at simple level, try storing elements , adding them later. lose placement of form elements, can replace them if you'd too. example code time: $form = new my_header(); $storedelements = array(); $storedelements[] = $form->getelement('id'); $form->removeelement('id'); $storedelements[] = $form->getelement('first_name'); $form->removeelement('first_name'); // other stuff here... // add foreach ($storedelements $element) { $form->addelement($element); } hope helps.

css - Floating Basic jQuery slider -

i´m using basic jquery slider ( http://www.basic-slider.com ) on website: http://www.bizgamesstudios.com/ my goal float slider left bullet points beneath stand side side slider. however, when applying float: left slider collapses. any ideas on how without changing appearance of slider? thanks apply these properties .featurelist: float: right; margin-top: -300px; margin-right: -80px;

ruby on rails - Railscasts Episode #362 - Exporting to Excel: How to avoid the warning message given by Excel 2010 when opening the file? -

when using example app ryan bates' railscasts episode #362 exporting excel ( https://github.com/railscasts/362-exporting-csv-and-excel ), i've noticed excel 2010 (which on windows) gives me warning message when opening .xls file i've downloaded using "download excel" link. the warning reads: "the file trying open ... in different format specified file extension. verify file not corrupted , trusted source before opening file. want open file now?" i can open file fine when click 'yes.' , don't warning message when using excel 2011 (on mac). i'd able provide excel file won't prompt warning when user downloads such file site. note: i've tried replacing references in app .xls .xlsx, excel can't open file @ all. complains: "excel cannot open file. file format or file extension not valid. verify file has not been corrupted , file extension matches format of file." i aware of gems such axlsx ( https://github.co

osx - User assigned key equivalents -

i'm working on status bar app. i'd allow user modify menu item key equivalents own preferences. i've seen done before it's pretty common feature. prefs window has area textfields user enters keyboard shortcut specific menu items. how 1 setup textfield displays modifier key fonts? default nstextfield ignores modifiers. also have yet find example project showing functionality, if has link helpful. you may wish take @ shortcut recorder allows user record key equivalents using modifiers , retrieve them , set them nsmenuitem . once user has recorder shortcut/key combination can access srrecordercontrol 's objectvalue property has values key code , modifier flags. https://github.com/kentzo/shortcutrecorder

javascript - 'this' undefined in chrome, but works in IE -

below, function works in ie, good, need work in chrome, firefox, etc well... in chrome im getting error... heres code function loadlist(list_name) { var olist = context.get_web().get_lists().getbytitle(list_name); var camlquery = new sp.camlquery(); camlquery.set_viewxml('<view><query><where><geq><fieldref name=\'id\'/>' + '<value type=\'number\'>1</value></geq></where></query><rowlimit>10</rowlimit></view>'); this.colllistitem = olist.getitems(camlquery); ... says in chrome.. "uncaught typeerror: cannot set property 'colllistitem' of undefined.. i assuming "this" .. there difference on how chrome handles 'this' , ie handles 'this'?? what can ? thank you! your code involuntarily (or deliberately?) under strict mode due sloppy concatenation or such, means function calls without explicit receiver place u

openoffice.org - OpenOffice Eclipse plugin doesn't recognize OpenOffice SDK -

i've installed openoffice 4.0 (application , sdk) in ubuntu, because want develop ooo addons. when attempt create new uno project eclipse, asks both openoffice's , sdk's location. plugin correctly recognizes openoffice installation, complains "sdk version has @ least 2.0.4" when given sdk's path. same issue happens libreoffice. is there way make eclipse recognize openoffice 4 sdk create new uno project? openoffice install deb files apache openoffice download page. url used install openoffice plugin is: http://www.openoffice.org/api/projects/eclipseintegration/dev-update/site.xml searched lot , found alternate update site works. update site: http://drake79.users.sourceforge.net/ooeclipse/site reference: http://www.flattermann.net/2009/06/openofficeorg-extension-development-with-eclipse-ooeclipse/#more-369

javascript - Select and trigger click event of a radio button in jquery -

upon document load, trying trigger click event of first radio button.... click event not triggered .also, tried 'change' instead of click ...but same result. $(document).ready(function() { //$("#checkbox_div input:radio").click(function() { $("input:radio:first").prop("checked", true).trigger("click"); //}); $("#checkbox_div input:radio").click(function() { alert("clicked"); }); }); please follow below link question example: http://jsbin.com/ezesaw/1/edit please me out in getting right. thanks! you triggering event before event bound. just move triggering of event after attaching event. $(document).ready(function() { $("#checkbox_div input:radio").click(function() { alert("clicked"); }); $("input:radio:first").prop("checked", true).trigger("click"); }); check fiddle

php - LAMP Web Server: Executing Application on Server Side can't detect USB device -

i have set lamp web server , looking run application on server side when client clicks button on servers web interface. application usb device, serial number, open , send packet of bytes device. i have index.html, has button action call test.php file uses shell_exec() call application. when application invoked through web interface, application writes out error indicating couldn't open usb device (this built in error application, application works, can not locate usb device). but when invoke application via terminal, application finds usb device , writes no problem. i looking advice! i'm doing feasible? if so, how can application find usb device when invoked via web interface? have feeling has permissions, never know. test.php: <?php echo shell_exec("/home/pi/fdti_test/fdti_test_application"); ?> note: usb device connected, works great driver, , connected server via usb. the application works when invoked via terminal on server side, not when

c# - foreign culture XML text parsing -

i have released windows phone app while back. since then, bugsense reported problem causing crashes in foreign countries: system.argumentexception - character 'Ä°' (0x0130) not available in spritefont. if applicable, adjust font's start , end characterregions include character. parameter name: character and here stack trace: at microsoft.xna.framework.graphics.spritefont.getindexforcharacter(char character) @ microsoft.xna.framework.graphics.spritefont.internalmeasure(stringproxy& text) @ microsoft.xna.framework.graphics.spritefont.measurestring(string text) @ globalengine.visual.textbase.calculatespriteorigin(object sender, eventargs e) @ system.eventhandler.invoke(object sender, eventargs e) @ globalengine.visual.textbase.set_formattedtext(string value) @ globalengine.visual.textlabel.set_text(string value) @ fourwordslibrary.gameutils.letter..ctor(char letter, assetmanager assetmanager, spritebatch spritebatch, single width)

jQuery Servlet call returns error -

i make simplest jquery servlet call: jquery: $.ajax( "loginservlet" ) .done(function() { alert("success"); }) .fail(function() { alert("error"); }); servlet: protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { system.out.println("posting"); } on console, see posting , servlet called. however, still 'error' alert. somewhere else, mentioned possible 'cross site scripting' problem. problem? my servlet at: localhost:8080/test/loginservlet when request servlet nothing print in console, must manage response of cycle request/response. so try following: // obtain out writer stream response // object send response client (the web page) printwriter out = response.getwriter(); // print response of request posting out.println("posting"); // close out stream out.close(); now jquery request response.

powershell - Single Value Total Ram / Free Ram free memory / total memory -

i looking way find single cooked value output of total memory , memory in use. gwmi win32_operatingsystem | select totalvisiblememorysize, freephysicalmemory so far have this, need value output. for both of them. thanks in advance shay ;) try this: gwmi win32_operatingsystem | % { $_.totalvisiblememorysize $_.freephysicalmemory }

Azure websites & MediaWiki: how to enable emails sending -

for example, when user creates account, resets password etc. first step set mail server credentials in localsettings.php file, per document: http://www.mediawiki.org/wiki/manual_talk:$wgsmtp#example_using_google_mail but after this, "pear mail package not installed" error message. how solve this? turns out it's relatively simple: make sure mail server credentials correct ftp root folder , rename index.php index.php.old - otherwise gets overridden install pear manager, using " hosted website " workflow rename pear.conf pear.ini - otherwise won't able start web manager create .user.ini file in root folder , add physical path pear *include_path* variable - kudoz article: http://chrisrisner.com/using-pear-with-windows-azure-websites-and-php open web manager ( http://domain.name/index.php ) , install following packages in pear (not sure if of them redundant after installed them, able connect gmail server) auth_sasl mail mail_mime n

rails 4 locale switcher not working on heroku -

i have bilingual rails 4 application deployed in heroku - russian & english. worked until 1 day locale switcher broke no reason. it's working fine on development , production version - when point language link shows normal link 'localhost:3000/en' or 'localhost:3000/ru' param. in heroku shows 'abarskaya.com/%7b:locale=>' instead of 'abarskaya.com/ru' or 'abarskaya.com/en' . strange didn't change anything. here's application controller class applicationcontroller < actioncontroller::base protect_from_forgery before_filter :set_locale protected def set_locale i18n.locale = params[:locale] || session[:locale] || i18n.default_locale end # ensure locale persists def default_url_options(options={}) logger.debug "default_url_options passed options: #{options.inspect}\n" { locale: i18n.locale } end end and route.rb file is: scope "(:locale)", locale: /ru|en/ '

How to make an html id defined in an html accessable in another html file -

how can let id defined in html or jsp file accessable in file? the reason doing used ajax content defined in file. , want id of content accessable first file. i tried way change scope of id couldn't find. normally can't. create iframe html page , load file want access. either make iframe hidden or of no size. here post mentions how access id's that: access child iframe dom parent page

regex - face font in c-mode when adding new keyword -

i trying customize added words colored differently default face-font colors. this doing: (defconst lconfig-font-lock-faces (list '(font-lock-function-name-face ((((class color)) (:foreground "darkblue" :bold t)))) '(font-lock-constant-face ((((class color)) (:foreground "black" :bold t)))) '(font-lock-builtin-face ((((class color)) (:foreground nil)))) '(font-lock-preprocessor-face ((((class color)) (:foreground nil)))) ) ) (autoload 'custom-set-faces "font-lock" "set color scheme" t) (autoload 'font-lock-fontify-buffer "font-lock" "fontify buffer" t) (progn (apply 'custom-set-faces lconfig-font-lock-faces) (add-hook 'c-mode-common-hook 'font-lock-fontify-buffer) (add-hook 'emacs-lisp-mode-hook 'font-lock-fontify-buffer) ) (global-font-lock-mode t) (font-lock-add-keywords 'c-mode '( ("