Posts

Showing posts from May, 2012

asp.net - Regex for fixed number in javascript/jquery -

i want validate textfield user enter number like.. should start 'arrn' , upto 5 numeric fields. number can be.. arrn1 or arrn12 or arrn123 not arrn123456 5 numeric allowed. can have regex same in javascript validate? i tried regex ['arrn'@[5]] not sure regex syntax. you can use follwong code check pattern. check pattern in onblur event of input. $('input').on('blur',function(){ var val = $(this).val(); if(/^arrn\d{1,5}$/.test(val)) alert('val ok'); else { //$(this).val(''); alert('val not correct.'); } });​ working fiddle

d3.js - Javascript - function argument -

i learning javascript, , bit confused below usage. these question may more javascript d3 specific. http://mbostock.github.com/d3/ex/sunburst.html var arc = d3.svg.arc() .startangle(function(d) { return d.x; }) .endangle(function(d) { return d.x + d.dx; }) .innerradius(function(d) { return math.sqrt(d.y); }) .outerradius(function(d) { return math.sqrt(d.y + d.dy); }); so, startangle, endangle etc takes function argument. rationale being argument function rather number? in full code, no "d" defined.i see in of d3 programs. "d" for? how set or passed? thanks. to first question: the d3.svg.arc object used create slices inside pie diagram. each of these slices needs different start- , end-angle displayed properly. in d3.js not pass in both angles each slice, provide function, takes 1 argument d , corresponding data element slice , returns angles. same holds other parameters set here. another advantage is, datum can consist of multiple pr...

actionscript 3 - Adding array-items (Shapes) to the stage -

i'm programming flash as3 file now, in as3 file create shape using points on stage (which place yourself) , fill parts in between. think i've added shape array. i'm having problems getting shape on stage after cleared stage. code here: var numpoints:number = 0; // number of points placed. // no dragging work until 7 points placed. // set max & min stage coordinates points can dragged, , make point diameters settable. var xmax:number = 455; var xmin:number = 5; var ymax:number = 305; var ymin:number = 5; var circlewidth:number = 10; // boolean variables indicate dragging happening appropriate point follows mouse // on mouse_move event. var isdragging1:boolean = false; var isdragging2:boolean = false; var isdragging3:boolean = false; var isdragging4:boolean = false; var isdragging5:boolean = false; var isdragging6:boolean = false; var isdragging7:boolean = false; // drawboard rectangle on triangle drawn. colors sett...

javascript - Trying to capture signature on ruby on rails application using SignaturePad -

i'm trying set signature capture in ruby on rails application. i'm using signaturepad here, i'm getting javascript errors in firebug. here application.js file //= require jquery //= require jquery_ujs //= require bootstrap //= require bootstrap-datepicker //= require build/jquery.signaturepad.js //= require build/flashcanvas.js //= require build/json2.min.js //= require_tree . $(function(){ $('.sigpad').signaturepad({drawonly:true}); }) my views rendered using haml. = simple_form_for(@blah) |f| .form-actions %p.typeitdesc review signature %p.drawitdesc draw signature %ul.signav %li.typeit %a.current{:href => "#type-it"} type %li.drawit %a{:href => "#draw-it"} draw %li.clearbutton %a{:href => "#clear"} clear %div.sig.sigwrapper %div.typed %canvas.sigpad{:width=>"398" ,...

javascript - Chrome - Unexpected token Illegal. Firefox und. string literal -

i have following script: jquery('#content-page-<?php echo $post->id ?>') .data('content','<div class="page-content"><?php echo $post->post_content; ?>'); in '<div class="page- the ' symbol not understood correctly , the uncaught syntaxerror: unexpected token illegal and unterminated string literal error in chrome , firefox. what problem? update 1 the <?php echo $post->post_content; ?> how handle multiline text? problem seems in multiline. are there apostrphes in php output? if remember becomes "raw text" if echos "i'm bob" it'll render 'content',';i'm bob' (notice middle quote). should use addslashes($post->$post_content) http://php.net/manual/en/function.addslashes.php escape output.

android - Pass Context with Intent -

all, i have broadcast receiver start intent service work on separate thread. i have tried digging intent documentation find way obtain context used create intent: intent(context packagecontext, class<?> cls) however signature of on start command following , not allow context passed. did not see context public method intent, have missed something. public int onstartcommand(intent intent, int flag, int startid) is there way @ context used create intent without going route of second broadcast receiver access ui, or handler. thanks i have tried digging intent documentation find way obtain context used create intent since context may not in process, not possible. moreover, not necessary. is there way @ context used create intent without going route of second broadcast receiver access ui the broadcastreceiver cannot update ui. hence, if wanted possible (which not), no good. moreover, since kicking off intentservice , may not have ui. user i...

android - What SDK platforum is better to start learning with, 2.1 or 4.0.3? -

i want start programming android devices , have 1 question you. heard android forward compatible. so, if use 2.1, can i, @ later stage, update app works 4.0.3? suggest me do? thank taking time answer these questions. ofcourse start lower version 2.1

html - Using jquery equal height but need equal elements inside columns as well -

Image
i'm using jquery equal heights plugin columns designer wants price down add cart button equalized well. possible jquery? i've tried adding existing equal heights i'm not sure i'm doing. here jquery: (function($) { $.fn.equalheights = function(minheight, maxheight) { tallest = (minheight) ? minheight : 0; this.each(function() { if($(this).height() > tallest) { tallest = $(this).height(); } }); if((maxheight) && tallest > maxheight) tallest = maxheight; return this.each(function() { $(this).height(tallest).css("overflow","hidden"); }); } })(jquery); this way 1 of boxes laid out: <ul id="phones" class="clearfix"> <li class="phone"> <div class="top"></div> <img src="/_img/2012/accessories_product.jpg" alt="phone" width="192" height="120"/> <h2>blackbe...

javascript - how can i sync two Backbone fetch calls with JQuery WHEN and THEN -

i found out cool thing in jquery: can do: $.when([$.get(..), $.ajax(...), $.getjson(...)]).then(function(data1,data2,data3){ // code run when requests done }); this great when want sync many ajax calls. in backbone ajax call being issued every time fetch model or collection: cardscollection.fetch(); my question how can achieve similar syncing capabilities backbone model/collection fetching: i like: $.when([series.fetch(), cardscollection.fetch()]).then(function(){ cardslistview.seriesid = seriesid; cardslistview.seriesname = series.get('seriesname'); cardslistview.template = _.template(cardslisttemplate); cardslistview.render(); $('#loader').hide(); }); is possible? tnx. ;-) yes, it's possible. pass several deferred jquery.when : $.when(series.fetch(), cardscollection.fetch()).then(...)

jQuery-ui-dialog - Dropdowns dont stay open -

using dialog , adding different form elements. my dropdowns not stay open when click arrow button on dialog. can hold down button, click shows options , disappears. anyone seen this? http://jsfiddle.net/tvance929/7pvb6/ -- example of doing in small measure... however, unfortunately isn't displaying issue experiencing. i'm guessing has fact ajax'ing in info dropdowns , or adding styling...

Elements below Expandble listview in android -

i using expandablelistview in android application.the problem facing if have elements such textview below expandablelistview, hidden when group clicked , children displayed.this happends when use linearlayout.following code: <linearlayout android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent" > <expandablelistview android:id="@android:id/list" style="@style/liststyle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:groupindicator="@drawable/group_indicator" /> <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="textview below expandablelistview" /> </linearlayout> if replace linearlayout relativelayout, reverse happens. textview not hidden either chidren of open group or lower groups i...

Problems importing MySQL data into Access 2010 -

i have small database 10 tables in - of those, 6 import directly access via odbc connection mysql database without issue. however, 4 of them throw error: "could not open object" the mysql odbc driver 3.51 -- greater didn't work @ , suggested on mysql.com support site use 3.51 instead. i can import these excel without trouble... not sure if issue access or odbc driver.. i've seen issue happen mysql tables containing field types access/jet doesn't understand , mysql odbc driver doesn't translate enough access map known field type (to access). know it's been bit of time - think post description of table(s) having trouble? perhaps more mysql/access people in here answering issue (if can't, is).

Hybrid Multi Module Maven Project with Spring Roo - Multiple JPA Persistence Units -

i'm trying create hybrid multi-module maven project, projects managed spring roo , others independent. this project structure far: root project (root pom) | | -- commons    (maven module, spring roo managed, jpa persistence module) | -- core           (maven module, spring roo managed, jpa persistence module) | -- backoffice (maven module, spring roo managed, webapp) | -- frontoffice (maven module, webapp) maven dependencies: - backoffice < core < commons - frontoffice < core < commons so far, good. can build artifacts , manage above projects using spring roo. however, since i'm using spring roo in both persistence modules, have 2 jpa persistence units. delegate responsibility frontoffice or backkoffice web application, but, since persistence modules managed using spring roo, needs have jpa configuration. do have suggestions on how organize multi-module maven project when of modul...

c# - Type inference fails mysteriously -

why following fail infer r : static r foo<r>(func<action<r>, r> call) { ... } while pretty 'same', works: static r foo<r>(func<action, r> call) { ... } usage: var = foo(ec => -1); ways first sample 'must' called compile: var = foo<int>(ec => -1); -- or -- var = foo((action<int> ec) => -1); thoughts: can seen in second snippet, r determined return type of 'lambda'. why can't same apply first? usage of ec (which should compiler hint), fails infer. i think problem not compiler if failing infer r function callwithescapecontinuation , is failing infer type lambda: ec => { enumerable.range(0, 100).select(x => { // called here, compiler has no idea signature expect `ec` // action<int>, action<decimal> (for example). if (x == 40) ec(x); return x; }).tolist(); return -1; } whereas when provide int hint, can infer ty...

c++ - Detect BIOS from WinPE: Legacy or UEFI, using vbs // Outputting results from a .exe to .txt -

here scenario: i have server 2 possible configurations: 2-tb hdd require no special treatment or 3-tb hdd require uefi bios , gpt partition boot os. i trying create single installation usb key able detect whether bios 'legacy' or 'uefi' , execute deployment script accordingly. i looked hard wmi can make distinction no avail. the closest came solution post: http://social.technet.microsoft.com/forums/en-us/winservermanagement/thread/6cbb488d-3062-4aad-b712-7a9e4d045b13 detectefi.exe works in detecting bios type, can't output result don't know how use it. i have 2 questions: is there wmi can use distinguich between 2 set-ups. (if answer question 1 no) there way output results c++ compiled .exe file .txt or other form , make use of result (i have no c++ skills @ all) if interested how fixed problem. created vbs linking .exe set objshell = createobject("wscript.shell") set objwshscriptexec = objshell.exec("detectefi....

android - ICS gui error on view size -

i building app has pop appear @ time takes ove screen , pauses background activity. on older versions of android pop view works fine, on ics top of pop cut off. have tried many things fix it, serves mess view in older versions of android. has else had such error? seems ics miscalculates size of screen , sets top of screen farther up. viewgroup root = (viewgroup) parent.getwindow().peekdecorview(); viewgroup group = (viewgroup) root.getchildat(0); int title = 0; if (group.getchildat(0) instanceof viewgroup) title += group.getchildat(0).gettop(); this how figure out top of screen is. works in older android not ics. i there easier way create popup. top of activity @ y = 0.

How to tell what the Android menu color is -

i have seen questions ask changing android menu background color. not want this, want determine if menu dark or light , show different icon accordingly. how can tell if android menu background dark or light? this question has been described before. , here answers: this , this (by wiseman) edit: didn't try myself may following code: gettheme().obtainstyledattributes(android.r.attr.windowbackground); it returns typedarray can obtain value of attribute somehow.

How to use SUM IF() in MySQL without hard coding values in the query -

i have query uses sum if() cross-tab result set. in query have value sin sum if() hard coded. problem new values added database. there way write query without hard coding values in sum if()? here query: select storeid, sum(if(marketsegmentid = 6, 1, 0)) 6 , sum(if(marketsegmentid = 7, 1, 0)) 7 , sum(if(marketsegmentid = 12, 1, 0)) 12 , sum(if(marketsegmentid = 17, 1, 0)) 17 , sum(if(marketsegmentid = 22, 1, 0)) 22 , sum(if(marketsegmentid = 27, 1, 0)) 27 , sum(if(marketsegmentid = 32, 1, 0)) 32 , sum(if(marketsegmentid = 37, 1, 0)) 37 , sum(if(marketsegmentid = 42, 1, 0)) 42 , sum(if(marketsegmentid = 47, 1, 0)) 47 , sum(if(marketsegmentid = 52, 1, 0)) 52 , sum(if(marketsegmentid = 97, 1, 0)) 97 , sum(if(marketsegmentid = 102, 1, 0)) 102 , sum(if(marketsegmentid = 107, 1, 0)) 107 , sum(if(marketsegmentid = 112, 1, 0)) 112 , sum(if(marketsegmentid = 117, 1, 0)) 117 , sum(if(marketsegmentid = 122, 1, 0)) 122 , sum(if(marketse...

php - MySQLi insert into prepare error -

hi inserted lot of stuff mysql databse. but error in prepare statement. see database prepare error. doing wrong? this code: $sql = "insert contact (ip,to,name,email,subject,text) values ( ?, ?, ?, ?, ?, ? ) "; if (!$stmt = $db->prepare($sql)) { echo 'database prepare error'; exit; } $stmt->bind_param('ssssss', $ip_contact, $to_contact, $name_contact, $email_contact, $subject_contact, $text_contact); if (!$stmt->execute()) { echo 'database execute error'; exit; } $stmt->close(); my sql table looks this: contact: - id int(11) auto_increment primary key - ip varchar(15) - varchar(5) - name varchar(20) - email varchar(20) - subject varchar(20) - text varchar(600) for example to reserved word in mysql , should change code to: $sql = "insert `contact` (`ip`,`to`,`...

linker - How to prevent ld from combining writable and executable sections? -

when link object files, resulting elf executable has (only) following load segment: load off 0x00000000 vaddr 0x00008000 paddr 0x00008000 align 2**15 filesz 0x000010f0 memsz 0x000010f0 flags rwx the linker ld combined sections 1 rwx segment, instead of separating writable , executable parts. want prevent this. relocatable objects have sections marked writable or executable appropriate, problem appears @ link time. so, determines how ld assigns permissions segments? linker script not seem have related that. specified when toolchain built? i targeting arm, , toolchain arm-linux-gnueabi , binutils version 2.22. edit: linker script here . other linker options -bdynamic , --gc-sections , -z nocopyreloc , --no-undefined . usually linker scripts used define sections, order, whether keep them or trash them binary (release build linker script might chose remove debugging info). here example of linker script: system-onesegment.ld edit : modify section p...

jQuery trigger not firing with bind() or on() for custom events -

can tell me why code not working? $('body').on('test', function() { alert('test'); }); $('body').trigger('test'); i'm using jquery-1.7.2.min . not errors, nothing happens. i've tried putting code inside inline script, inside $(document).ready() , still nothing. i've tried both on() , bind() , neither result. see examples on showing same syntax, different this? it appears issue lies in dom being ready somehow. placing code within inline script not work. placing inside of $('document').ready() work anonymous function, reason not function call '( )'.. code worked $(document).ready(start); function start(){ $('body').on('test', function() { alert('test'); }); $('body').trigger('test'); } but did not... *notice function call parenthesis. $(document).ready(start()); function start(){ $('body').on('test', function() { alert('test...

c# - Serialize and Deserialize Property Based on DB Value -

i have simple class has bool property. 'get' logic property executes stored procedure return bit field database. i serialize class , save xml field in database. saves class , bool property fine, no problem. the problem seem having when deserialize class. class deserilizes fine, when data drives bool field has been updated, seems class recognizes serialized in xml, , not looking database new bool value (does not execute procedure newly update bit field). my solution has been add xmlignoreattribute attribute field isn't serialized begin with. i'm wondering if noticed and/or can me understand inner working of .net xmlserializer class. thanks! [xmlignoreattribute] public bool isupdated { { datatable dtresults = mclssqlservertool.loaddatatable("exec stp_rl_sel_nameisupdated '" + mstrname + "'"); bool blnisupdated = convert.toboolean(dtresults.rows[0]["ru_bitisupdated"]); ...

mysql - Search data from two table with joins how to handler null values -

i have write search query joining 2 different table. have putted left join on both. first table contains 60records while based on second table has 30. wanted if search query should return 60records. right returning 30. query same. select a. ,b. left join b on a.id=b.aid a.name=ifnull('tst',a.name) , b.class=ifnull('c',b.class). please guide me, thanks. it's wise remember join operations (all kinds of join operations, left, right, inner, outer) have purpose of creating new, virtual, table assembled tables joined together. what joined virtual table supposed have in it? in case, meaning of column a.id, , column b.aid? are there rows in table a.id column values occur no times in b.aid? are there rows in b table b.aid column values occur no times in a.id? if answer question 1 yes , question 2 no, left join give want want. simplify query. try this. select a.*, b.* left join b on a.id = b.aid if happen want rows there no corr...

help system - Need to generate and maintain user documentation -

need generate , maintain user documentation. recently user began asking user guide/manual of kind. think application easy use, believe users correct. so need easy enough tool generate , maintain user documentation. best solution? little upkeep possible. i think should editable user, can write notes, , improve documentation quality , keep up-to-date. thanks we're using 3 systems our documentation , keep date: dokuwiki edit documentation. tok keep date use doqua - eclipse plugin (all our projects java based). doqua helps keep high quality standards concerning layout , linking , on. in addition has tagging system tags can run out of date. tagged documents have reviewed time time - system tells when. our automated build system ( jenkins ) has copy of doqua , checks documentation regularly - @ least when there new version released. fetches current version of our documentation dokuwiki using site export plugin , check-in our svn repository.

android - Building multiple .apk artifacts for different customers with maven -

i have setup android maven build customer, based on ant. the base app white label implementation , app distributed several third party customers. each of customer versions uses same source code , set of shared resources. every customer has resources specific company (constants, assets, etc). the structure of android project looks this. included relevant files/folders , structure remained ant build: app |--src |--res |--res-customer1 |--res-customer2 |--pom.xml this means have build multiple .apk artifacts same source different resources. best approach this? the first thing tried use different profiles in main projects pom every customer. wrote shell script execute maven builds (1 per customer). then came using 1 release profile in main project , passing customer specific properties via command line. properties passed via shell script, similar first approach. but i'm not happy that, thought using multiple modules. 1 per customer. problem here is, how can build same...

Selectively include headers in Qt using preprocessors -

i trying include windows specific headers on cross-platform project in following way. #ifdef q_os_win #include "qt_windows.h" #include "shellapi.h" #endif for reasons, files not included properly. note: using mingw-gcc compiler. i don't think defined. should q_os_win32 or q_ws_win . see qt global . #include <qtglobal> #ifdef q_os_win32 #include "qt_windows.h" #include "shellapi.h" #endif

javascript - Wrapping a split string's substrings in an element -

how use javascript/jquery select $('td.created') , split html on <br> , wrap each section in span tags (so can add class span:first in order style it). the format of string returned $('td.created').html() like posted user123 <br> posted on 1/2/12 @ 4:15pm possible universal solution (works not 2 lines): $("td.created").each(function() { var text = this.innerhtml.split("<br>"); (var = 0; < text.length; i++) { var span = $("<span />").html(text[i]); if (i == 0) span.addclass("first"); span.appendto("#element"); } });​ demo: http://jsfiddle.net/7xqal/

android - App Engine Several Databases For Databastore -

i thinking using google app engine. for project need several data stored in different databases. i've been reading far appengine provides 1 database store , track users. my problem need have multiple databases store same data store data related criteria. is appengine way go this? android app using way. or should have own server? if need implement? can explain, why need more 1 database. can use namespaces create multitenancy environment. https://developers.google.com/appengine/docs/python/multitenancy/multitenancy

conditional - Multiple arguments for a PHP function -

follow this: apply specific class/id current page on menu (php) here's code i'm using: <div id="bottoni" style="float:right;margin-top:30px;margin-right:30px"> <?php // funzione per ottenere la class 'current' per la pagina che si sta visitando function get_current($name) { if (strpos($_server['request_uri'], $name) !== false) echo 'id="current"'; } ?> <a <?php get_current('biografia') ?> href="<?php echo esc_url( home_url( '/' ) ); ?>biografia/"><img style="width:120px;margin-right:25px" src="http://robertocavosi.com/beta/wp-content/themes/robertocavosi/images/bottone_robertocavosi.jpg"></a> <a <?php get_current('attore') ?> <?php get_current('regista') ?> <?php get_cu...

key bindings - How do I implement wpf keybinding -

i want able allow users change hotkeys @ runtime. does have concrete example on how bind key in codebehind c# accomplish this? i assume have keybinding routedcommand. assume want push button on ui hotkey. eg... let user push f5 click btngo on app. the way commands work bit different thinking. when press button doesn't fire click button in app. rather, define command (in case, have command called "go") , can assign command various elements in application (menu items, buttons, etc.) of these items fire command , command has "executed" function performs code. if add commandbindings main window can use hotkeys fire commands globally. can place command bindings in xaml such code as: <window.commandbindings> <commandbinding command="local:mycommands.go" canexecute="gocanexecute" executed="go" /> </window.commandbindings> to create own command can create "routeduicommand" in...

What is OrientDB's indexing scheme? -

just question says. there explicit indexes need add documents into? or automatic secondary indexes? there both kinds of indexes: automatic, created against schema , populated automatically. close rdbms offers manual, created , populated manually using java api, http rest protocol or plain sql using "index:" prefix instead of class name. for more information at: http://code.google.com/p/orient/wiki/indexes

Creating variable arrays with Javascript (dyamic, drop down) -

i've been searching board while (both here , google) , can't seem find i'm looking. (sorry if i've missed , qualifies annoying/redundant question.) i'm working on form have copious amounts of drop downs based on previous selected variable(s). trying come easier way having create individual fields , hide/show based on selection. ultimately, i'm aiming "tree" between 3-5 levels of menus. (clients doing, not mine.) what logic looks like: variables: type, offer1, offer2, insert1, insert2, insert3,... where [type] determines [offer1,2] has 3 variables each [insert1,2,3...] so if user selects type a: offer1 = array (insert1 = arraya1, insert2 = arraya2, insert3 = null) , offer2 = array b (insert4 = arrayb4, insert5 = null); , on , forth. so far, i've found seems handle first tier, , js isn't forte. pointing in right direction appreciated. in case else runs across issue, found solution uses jquery: http://www.appelsiini.net/proje...

image function in R -

Image
i'm trying little bit complicated beginner in programming. have matrix 16x16 , want plot values heatmap using image() in r. how can plot "0" (zeros) in blue when sum (row index + column index) <= 15? possible? example matrix: x <- c(3045, 893, 692, 830, 617, 155, 246, 657, 105, 60, 18, 7, 7, 4, 2, 11234, 2985, 2242, 2471, 1575, 366, 503, 1283, 170, 79, 32, 6, 4, 1, 3, 19475, 4756, 3233, 3251, 1810, 409, 575, 1210, 139, 41, 11, 4, 2, 0, 0, 20830, 4739, 2990, 2531, 1346, 298, 325, 612, 60, 17, 1, 0, 1, 0, 0, 15304, 3196, 1885, 1440, 610, 117, 115, 185, 14, 2, 0, 0, 0, 0, 0, 8026, 1535, 806, 539, 223, 33, 37, 39, 0, 0, 0, 0, 0, 0, 0, 3300, 562, 286, 141, 45, 14, 5, 12, 0, 0, 0, 0, 0, 0, 0, 1067, 160, 65, 40, 14, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 277, 47, 6, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 72, 6, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) xmat <- matrix(x, ncol ...

c# - Developing one solution with slightly different modules for every country -

currently i'm developing 2 solutions (first country a, second country b), similar. i'm using wpf, c#, mvvm, sql server. some of modules identical in every solution, of them partially different (ex. classes have additional fields or methods), , different (ex. vat module). me, developing independent solutions not best solution (time cost). so, thinking of creating 2 solutions (a , b) contain main screen prepare user interface. then, in third solution (c) have project (=modules) , link them or b. if module identical both version - no problem. if different - ok, must develop independently. but, question how design modules different? should use abstract factory design pattern , put in abstractproduct identical, , in concreteproducts put additional fields/methods? wpf forms can't use pattern - must develop form every version. thx. what want use dependency injection. first create interface have concrete impls implement interface per country. interface is...

javascript - Linux write to file from java jar -

i writing text file java jar executable. jar generates correct file permission of file set root, therefore other javascript cannot read file. returns "permission denied" when attempt read file via ajax. how can fix issue when creating file in java? running java 1.6. i did not have issue when running application within eclipse. once ported on jar permission changed root access. i running jar a exec('java -jar writetofile.jar'); the writing file standard public void writecontents(string fp,string contents){ try{ bufferedwriter write = new bufferedwriter(new filewriter(fp)); write.write(contents); write.close(); }catch(exception e){ system.out.println("failed write file " + fp + " error: " + e.tostring()); e.printstacktrace(); } } writing file works fine, creates file correct directory , desired data, difference between running in eclipse , running via jar file permission. jar set fil...

php - Email Tracking - Distinguishing Between Book Mark and Email Click Through -

if add link in email query variables such as... http://www.mywebpage.com/?email=person@email.com&page_visited=some_id to me track email 'click-throughs' , monitor accessing site via email campaign started, there way distinguish actual click mouse cursor vs bookmarking page after having clicked through once, , accessing page again via browser bookmark. so need monitor whether clicked through or accessing page again via bookmark. when user visits site via email link, redirect them page different url. way, bookmarked version not same emailed version. example: email link: http://www.mywebpage.com/?email=person@email.com&page_visited=some_id forwards user to: http://www.mywebpage.com/?page_visited=some_id and page gets bookmarked. can distinguish between types of visits filtering on 'email' parameter.

javascript - Using external mustache partials in a brunch.io project -

i working on project uses brunch.io , mustache templating. want add mustache partials main index (which serves 'shell') load in content. create mustache partials in own .mustache file , add tag on index page (ie: {{> somepartial}} ) seem missing how partial render... thats need with. i’m using handlebars.js implementation of mustache in brunch apps, it's simple: register partial via handlebars.registerpartial() .

perl - prepare_cached dbi inside a recursion -

ii using dbi call table on db recurisvly when use prepare function every thing works fine when use prepare_cached instead error message prepare_cached failed below snippet of code sub rec { $data = shift; $dbh = shift; if($x eq 'foo') { return 1; } $query="select x table z =?"; $sth=$dbh->prepare_cached($query); $sth= $dbh->execute($data); while(my ($x)=$sth->fetchrow_array) { $rec($x,$dbh); } } could problem ? the problem iterating on $sth , while doing this, recursing , executing again. since acts on same $sth can't work (prepare_cached call $sth->finish, see dbi docs). so if possible, fetch rows array, $sth->finish , recurse on array. or use normal prepare(). depending on dbs might performant enough.

c# - Entity Framework: field of composite key cannot be nullable? -

i have model composite key - row key: public class item { [key, column(order = 0)] public int userid { get; set; } [key, column(order = 1)] public datetime? date { get; set; } } running code below throws exception dbentityvalidationexception message: the date field required. : var = new item { date = null, userid = 2 }; m_entities.items.add(it); m_entities.savechanges(); // throws exception ( m_entities usual dbcontext descendant items defined dbset<item> ) why date required if can null (declared datetime? ) ? , how allow null valid value date ? answer raphael lead me search. here why not possible (answer cobsy): what's wrong nullable columns in composite primary keys? in short: null == null -> false wierd. solution me add id column model. btw: mysql allow me not define primary key, i'm allowed have such schema - ef complains not defining key :-(.

HTML5 Types in ASP.NET -

site exclusively used on mobile devices. fields requiring numeric input, want bring numeric keypad. can using html input element type set 'tel'. want add asp:requiredfieldvalidator field , based on msdn , need set input runat server. when this, "'tel' not valid type input tag." if remove runat = server, "unable find control id 'contract' referenced 'controltovalidate' property of ''" <input type="tel" runat="server" id="contract"></input> <asp:requiredfieldvalidator runat="server" controltovalidate="contract" validationgroup="ifonrent" text="*" errormessage="contract required"></asp:requiredfieldvalidator> am out of luck , have code own validations? you may want leave "type" undeclared in code "front". can set in code behind (maybe in page_init or page_load ): this.contract.attribu...

javascript - Sencha Touch Uncaught typeError: undefined is not a function -

i have began check out sencha touch. in following there tutorials have ran issues cannot seem resolve. some of basic code in app.js provided sencha runs fine. others seem errors. example: new ext.application({ name: "notesapp", launch: function() { console.log("app launch"); } }); with an: uncaught typeerror: undefined not function if rewrite code without new @ beginning like: ext.application({ name: "notesapp", launch: function() { console.log("app launch"); } }); i "uncaught typeerror: object # has no method 'application'" the second way see on place when looking sencha seems gining me issues. can 1 me understand doing wrong. thank . looks ext.application has capital a. remember javascript case sensitive. http://docs.sencha.com/touch/1-1/#!/api/ext.application

ios - Why does app work on iPhone, not iPad? -

Image
i started iphone-only app, worked fine on both iphone , ipad (it ran in small, iphone-sized window on ipad... fine). selected iphone/ipad target device family, , created blank myviewcontroller~ipad.xib. decided revert app former self, , deleted ~ipad.xib , set target device family iphone only. now, view displayed before on ipad, cannot interact view. works on iphone, on ipad, seems buttons not linked corresponding actions. but, there on nib now, buttons linked, because work on iphone. per @wrights suggestion, deleted of simulator files , clean project again. got new error: *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'could not load nib in bundle: 'nsbundle </users/hap/library/application support/iphone simulator/5.1/applications/83becbaa-2558-4927-9347-fac972168299/wxt.app> (loaded)' name 'mainwindow-ipad'' the app crashes @ point. i'd app working on ipad, before... single nib. appreciated!...

version - App is not working on Android 4.0.3 but on Android 2.3.4 it is -

i've app working on android 2.3.4 (emulator/phone). tried install on android 4.0.3 (emulator/phone) , when run not working. shows me message "unfortunately appname has stopped" when appears me error app executing these classes: public class empleadosact extends activity { private arraylist<string> datos; private listview list; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); actualizarvehiculos(); } public void actualizarvehiculos() { try { notescenter messagecenter = new notescenterimpl(); list<vehiculo> vehiculo = messagecenter.getvehiculo(); (vehiculo v : vehiculo) { androidopendbhelper androidopendbhelperobj = new androidopendbhelper( this); sqlitedatabase sqlitedatabase = androidopendbhelperobj .getwritabledatabase(); contentvalues contentvalues = new contentvalues(); contentval...

php - How to use mysql to find a field name of a record? -

pdo sql codes : while($r = $q->fetch(pdo::fetch_assoc)){ $gg = join('</td><td>', $r); echo "<tr><td>" . $no_count . "</td><td>" . $gg . "</td></tr>"; $no_count = $no_count + 1; } variable $r record, how can echo field name of $r ? let's $r carry records 2 different fields "product" , "price". value of $r "apple", "130". how can add "usd" "130"? i need like.... if $field_name == "$r['price']" { $r = join('usd', $r); }; thanks mike b, there : while($r = $q->fetch(pdo::fetch_assoc)){ foreach ($r $name => $value) { if ($name == "price"){ $r = "usd" . $value; // line got problem, how change value in array variable $r? } } $gg = join('</td><td>',...

bash - Using sudo with for loop -

i want run simple loop command sudo, isn't working: sudo -i -u user in /dir; echo $i; done i following error: -bash: syntax error near unexpected token `do' probably simple thing overlooking. help? sudo wants program (+arguments) parameter, not piece of shell script. can this, though: sudo -i -u user sh -c 'for in /dir; echo $i; done' note single quotes. if used double quotes, shell try expand $i before sudo (or, rather, shell run it) ever sees it.

javascript - Is there a working dojo tabContainer can successfully reload in a contentPane? -

i not lazy have tried many ways try reload div(id=refreshable) contains dojo tabcontainer(id=dojotabbedpane). each time after reloading page content in each tab show 1 stack(the tabs missing). i did research, ask questions, , use dijit.byid("dojotabbedpane").destroyrecursive(); before jquery load , call dojo.parser.parse(dojo.byid("dojotabbedpane")); after re load never works. so, please, can share simple snippet can show me tabcontainer can right container refreshed? swear try many theoretical way , should work can show me simple code let me see works? i don't know how paste big chunk of code here otherwise give base sample interested can revise, here have prepared tabcontainer dojo website, please me work out. !! <script type="text/javascript" src="dojo/dojo/dojo.js" djconfig="parseonload: true"></script> <script type="text/javascript" > function refresh_data(url, id) { j('#'+...