Posts

Showing posts from February, 2012

python - mysql issue while using concurrent.futures -

my code follows. for in self.parent_job.child_jobs: futures.append(executor.submit(invokeruncommand, i)) future in concurrent.futures.as_completed(futures): print("future exception: %s" %future.exception()) executor.shutdown(wait="true") def invokeruncommand(self): db_connect, db_cur = connect_to_database_pl() self.setjobstatus(db_cur, job_running) ... def setjobstatus(self, db_cur, job_status, run_status=run_passed): self.job_status = job_status sql = """update jobs set job_status=%d job_id=%d""" \ %(job_status, self.job_id) db_cur.execute(sql) def connect_to_database_pl(dict_cursor=1): database = sql_db db_users = { 'employee' : {'user' : 'test', 'password' : 'test123'}, } user = db_users[database]['user'] password = db_users[database]['password'] try: ...

version control - Manipulating repositories for specific Monticello packages programatically? -

i want automate monticello tasks. purpose have first choose monticello packages , able to: add repositories, remove repositories, add user , password information (smalltalkhub) repositories. i saw there small paragraph on "programmatically adding repositories" in upcoming monticello chapter of "deep pharo". can gofer used automate tasks this? gofer supposed used programmatically hand monticello ui. if find things missing, please discuss them on mailing lists.

batch file - wait statement in python -

i have python code looks this: os.system("...../abc.bat") open("test.txt") ..... where abc.bat upon complete run creates test.txt. problem since there no "wait" here code directly goes open("file.txt") , naturally not find , hence problem. is there way can find out status if bat run has finished , python can move open("test.txt")? note: have used idea in bat file has command- type nul>run.ind , file deleted bat file @ end indicator bat run has finished. can somehow make use of in python code : os.system("...../abc.bat") if file run.ind exists == false: open ("test.txt") this seems crude. there other methods in simpler way? or in other words possible introduce "wait" till bat run finished? maybe try put on while loop. import os import time os.system("...../abc.bat") while true: try: o = open("test.txt", "r")...

android - Nullpointer exception when starting another activity -

my program contains 2 activities.i called second activity method showevent .but error occured, nullpointer exception.why ? program contains 2 activities.i called second activity method showevent .but error occured, nullpointer exception.why this firstactivity.java public class firstactivity extends fragmentactivity implements onitemselectedlistener { /** called when activity first created. */ public final static string extra_message = "com.example.myfirstapp.message"; public final static string extra_message1 = "com.example.myfirstapp.message"; classdbopenhelper eventsdata; textview userselection; button okbutton; button addbutton; button change_date_but; textview date; textview show; edittext edittext; public static final int date_dialog_id = 1; private int myear; private int mmonth; private int mday; private static final string[] items={"yalahanka","rajaji n...

Mysql converting TIMESTAMP to INTEGER - timezones -

i need convert timestamp fields int in our mysql (innodb) db. realize converting timestamp int unusual, still need :) it seems straight-forward enough do, there timezone , daylight saving errors. i have script generates sql code per column. example, generates: alter table alarmlog add column started_tmp int unsigned; update alarmlog set started_tmp = unix_timestamp(started); alter table alarmlog drop started; alter table alarmlog change started_tmp started int unsigned null default 0; if compare before , after data using select from_unixtime(1291788036); , result looks good. the idea change client-side software convert utc , use int when storing it. when retrieving, int converted current time zone. but docs warn me scenario (daylight savings in cet): mysql> select unix_timestamp('2005-03-27 02:00:00'); +---------------------------------------+ | unix_timestamp('2005-03-27 02:00:00') | +---------------------------------------+ | ...

How to show errors for multiple object forms - Play Framework 2 with Java -

i’m having trouble displaying errors of form containing multiple objects of class, in case productmilestone. i’m showing form milestones in table, displaying , updating works well. error template can’t displayed anymore error "[illegalstateexception: no value]". because erroneous form doesn’t contain values received form.get() method, in case it’s milestoneset. can make work errors displayed? the problem for-loop in view: view: @(milestoneformset: form[productmilestone.milestoneset], productreleaseid: long) @*function called loop in form below*@ @milestonefields(milestone: productmilestone, index: integer) = { //…other fields @inputtext(milestoneformset("milestonelist[" + index + "].initialdate"), '_label -> "",'class -> "datepicker") …} @form(routes.productmilestones.submitedit(productreleaseid), 'id -> "submitmilestoneeditform") { @*here problem, when f...

asp.net - Javascript window.close on mobile -

i'm developing small web app using asp.net. 1 of function in system open new window tab, i've put button close after save document seems it's working on desktop. here's code. <asp:button id="button2" runat="server" text="close" onclientclick="javascript: window.close();"/> i'm using opera mini browser in mobile (siii). try this <asp:button id="button2" runat="server" text="close" onclientclick="return self.close();"/>

c# - How to restrict Emoji range u2600-u26FF for a text box -

i restrict emojis in text box of range u2600-u26ff using regex . i tried this, fails. private static readonly regex regexemoji = new regex(@"[\u1f600-\u1f6ff]|[\u2600-\u26ff]"); i restric user adding emojis in wp8 thanks in advance. because .net doesn't support surrogated pairs in regexes. have decompose them manually. make clear, char in .net 16 bits, 1f600 needs 2 char . solution decompose them "manually". private static readonly regex regexemoji = new regex(@"\ud83d[\ude00-\udeff]|[\u2600-\u26ff]"); i hope have decomposed them correctly. i used site: http://www.trigeminal.com/16to32andback.asp to decompose low , high range \u1f600 == \ud83d \ude00 , \u1f6ff == \ud83d \udeff . first part of surrogate pair "fixed": \ud83d , other range. example code ( http://ideone.com/0o6qbt ) string str = "hello world 😀🙏☀⛿"; // 🌀 1f600 grinning face, 1f64f person folded hands, 2600 black sun rays, 26ff whi...

xcode - Avoid "Can't make ...class... into type number." error -

property myvalue : "" property mypopup : missing value on applicationwillfinishlaunching_(anotification) tell standarduserdefaults() of current application's nsuserdefaults registerdefaults_({myvalue:myvalue}) set myvalue objectforkey_("myvalue") text end tell mypopup's selectitematindex_(myvalue - 1) end applicationwillfinishlaunching_ on mybuttonhandler_(sender) set myvalue (mypopup's indexofselecteditem) + 1 -- line may mistake end mybuttonhandler_ on applicationshouldterminate_(sender) tell standarduserdefaults() of current application's nsuserdefaults setobject_forkey_(myvalue, "myvalue") end tell return current application's nsterminatenow end applicationshouldterminate_ i wrote code, debug error: (project name)[42733:303] *** -[appdelegate mybuttonhandler:]: can’t make «class ocid» id «data optr00000000c7ffffffffffffff» type number. (error -1700) can tell me how code ...

c# - What's the difference between a compound type and an anonymous type? -

as question states above, what's difference between compound type , anonymous type? in this answer , compound typed object defined new {} statement (below statement). m => new { member = m, split = m.name.split(',') } but isn't same when create anonymous typed object? both same thing different names? those different names, yes. code put above creates anonymous type (that name should use, official one, , common one).

How to generate coverage report with JMockit and Maven? -

i'm trying generate coverage report jmockit , maven surefire plug-in. nothing happens. here relevant parts of pom.xml: <plugin> <artifactid>maven-surefire-plugin</artifactid> <version>2.15</version> <configuration> <argline> -djmockit-coverage-outputdir=target/coverage-report </argline> </configuration> </plugin> the jmockit dependency: <dependency> <groupid>com.googlecode.jmockit</groupid> <artifactid>jmockit-coverage</artifactid> <version>0.999.22</version> <scope>runtime</scope> </dependency> this pretty same example jmockit docs . it should generate report mavens "test" goal, not. i've tried "surefire:test" too, nothing happens. i'm using java 7 , maven 3.0. how can generate jmockit coverage report maven? you need add "jmockit" dependency, ve...

linux - wait for two PID in c-shell -

following works me: >sleep 20 & [1] 30414 >sleep 30 & [2] 30415 >wait $30414 $30415 this works right until want write tmp.csh in tem.csh file sleep 20 & set pid1=$! sleep 30 & set pid2=$! when comes "wait" wait $pid1 $pid2 => many arguments wait $pid1 => many arguments wait \$$pid1 => many arguments wait $($pid1) => illegal variable name how shall write it? and question solution of how can wait until specified "xterm" finished? the "wait" command not wait specific pids. try following in csh wait specific pids: #!/bin/csh -f sleep 30 & set pid1 = $! sleep 40 & set pid2 = $! while ( `ps -p "$pid1,$pid2" | wc -l` > 1 ) sleep 1 end

google app engine - How to update single files in GAE? -

the following command upload whole project google app engine: appcfg.py -r update c:/users/user/desktop/myproject/ however, made corrections locally single file of project called index.php , update server version without uploading whole project, large. i have tried: appcfg.py update c:/users/user/desktop/myproject/index.php (notice removed -r , added file name @ end) prints: usage: appcfg.py [options] update appcfg.py: error: directory not contain index.yaml configuration file. any idea? my inexperience google app engine made me post question, got answer on own after little while. hahahaha discovered did not know before. after making changes index.php file , decided redeploy whole thing. time took less minute redeploy server (the first time took on 10). it seems local appgine scans local changes , submits instead of whole project! therefore re-running: appcfg.py -r update c:/users/user/desktop/myproject/ will update files changed only.

Android gradle build: running assembleDebug makes release tasks of project dependencies being called -

when running assembledebug, release related tasks of projects depend on called. e.g. have project called 'x' depends on 'y'. when gradle assembledebug calls y:mergereleaseproguardfiles, packagereleaseaidl, etc... etc.. android library modules publishes "release" build type. don't have "debug" build type. application module build debug version, use release version of library. you can enable "debug" build type of library dependency using following in module's build.gradle file: android { publishnondefault true ... } then when using dependency in other module, should use this: dependencies { releasecompile project(path: ':moduley', configuration: 'release') debugcompile project(path: ':moduley', configuration: 'debug') } i using same trick in application. have shared module , use debug version of module. find details here: https://github.com/pomopomo/wearpomodoro/bl...

Eclipse plugin: java.lang.NoClassDefFoundError -

Image
as can see: i added jni4net.j-0.8.6.0.jar referenced libraries stell receive java.lang.noclassdeffounderror exception: java.lang.noclassdeffounderror: net/sf/jni4net/bridge @ sibeclipseplugin.debug.debuggerinterface.initialize(debuggerinterface.java:15) @ sibeclipseplugin.debug.sibdebugtarget.<init>(sibdebugtarget.java:65) @ sibeclipseplugin.ui.launch.launchconfigurationdelegate.launch(launchconfigurationdelegate.java:30) @ org.eclipse.debug.internal.core.launchconfiguration.launch(launchconfiguration.java:858) @ org.eclipse.debug.internal.core.launchconfiguration.launch(launchconfiguration.java:707) @ org.eclipse.debug.internal.ui.debuguiplugin.buildandlaunch(debuguiplugin.java:1018) @ org.eclipse.debug.internal.ui.debuguiplugin$8.run(debuguiplugin.java:1222) @ org.eclipse.core.internal.jobs.worker.run(worker.java:53) caused by: java.lang.classnotfoundexception: net.sf.jni4net.bridge cannot found sibeclipseplugin_0.0.0.1 @ org.ecli...

Smarty reading config values from .conf files in PHP -

for meeting schedule, want have dynamic pages given room. user can edit file named "schedules.conf" in config folder. @ moment looks this: [rooms] room = 5022 room = 5082 and can load , shows 2 links in web page: {config_load file="schedules.conf" section="rooms"} ...... ...... ...... {foreach from=#room# item=r} <li><span><span><a href="{$smarty.const.site_url}/admin/schedules.list.php?room={$r}">schedules {$r}</a></span></span></li> {/foreach} so links handler php file, in php file want check weather room exist in config file, if manually change value room in address bar have chance handle that: if(!isset($_get["room"])) { header('location: '.site_url.'/admin/index.php'); } else { $validrooms = $smarty->getconfigdir(); //how check id $_get["room"] value exist in config file } g...

sql server - CTE Recursion to get tree hierarchy -

i need ordered hierarchy of tree, in specific way. table in question looks bit (all id fields uniqueidentifiers, i've simplified data sake of example): estimateitemid estimateid parentestimateitemid itemtype -------------- ---------- -------------------- -------- 1 null product 2 1 product 3 2 service 4 null product 5 4 product 6 5 service 7 1 service 8 4 product graphical view of tree structure (* denotes 'service'): ___/ \___ / \ 1 4 / \ / \ 2 7* 5 8 / / 3* ...

javascript - JS - Set variables value in function but use variable outside of it? -

i need set variables value within function, use outside of function. can done? $(document).ready(function() { $(window).scroll(function () { var myvar = something; }); console.log(myvar); }); yes, need first declare outside of function. $(document).ready(function() { var myvar; $(window).scroll(function () { myvar = something; }); console.log(myvar); }); just know myvar updated after scroll event triggered. so, console.log log undefined because runs before event runs , sets variable.

excel - Vlookup translation error in multiple sheets -

suppose have sheet question numbers , different respondents. example, in sheet 1 have q1 q2 q3 q4 q5 q6 q7 q8 q9 q10 person 1 3 1 5 2 4 1 2 1 5 person b 5 1 5 1 3 3 2 5 4 3 person c 5 1 5 1 3 3 2 5 4 3 on sheet 2 have same setup q5 q4 q2 q3 q4 q6 q7 q8 q9 q10 person person b person c when type following in on respective sheet 2 calls: =vlookup(a1,sheet1,b$1+1,0) # return value of person a, q1 sheet 1 i value of person q6 instead. why? am right assume using excel? if so, equation use is: =vlookup($a2,table1,match(b$1,sheet1!b1:k1)+1,false) you can't pass whole sheet parameter. going need pass range. here named table1. in third parameter, adding 1 string, causes problems. use match function column number.

python - What is the pythonic way of generating this type of list? (Faces of an n-cube) -

if n == 1: return [(-1,), (1,)] if n == 2: return [(-1,0), (1,0), (0,-1), (0,1)] if n == 3: return [(-1,0,0), (1,0,0), (0,-1,0), (0,1,0), (0,0,-1), (0,0,1)] basically, return list of 2n tuples conforming above specification. above code works fine purposes i'd see function works n ∈ ℕ (just edification). including tuple([0]*n) in answer acceptable me. i'm using generate direction of faces measure polytope. directions, can use list(itertools.product(*[(0, -1, 1)]*n)) , can't come quite concise face directions. def faces(n): def iter_faces(): f = [0] * n in range(n): x in (-1, 1): f[i] = x yield tuple(f) f[i] = 0 return list(iter_faces()) >>> faces(1) [(-1,), (1,)] >>> faces(2) [(-1, 0), (1, 0), (0, -1), (0, 1)] >>> faces(3) [(-1, 0, 0), (1, 0, 0), (0, -1, 0), (0, 1, 0), (0, 0, -1), (0, 0, 1)]

javascript - wierd way to get chrome, IE 8 and firefox to submit the same form -

this way found 3 browsers submit form without problems. there obvious reason why so? more elegant solution this? i'm using jquery 1.9. chrome odd man out here, code in else sufficient submit via ie , firefox. function submitformbypost(actionname){ $("#eventaction").val(actionname); var is_chrome = navigator.useragent.tolowercase().indexof('chrome') > -1; if(is_chrome){ document.getelementbyid('myform').method='post'; document.getelementbyid('myform').submit(); } else{ document.forms[0].method='post'; document.forms[0].submit(); } } the way works in chrome work in others also, use that: function submitformbypost(actionname){ $("#eventaction").val(actionname); var frm = document.getelementbyid('myform'); frm.method = 'post'; frm.submit(); } or using jquery way: function submitformbypost(actionname){ $...

android - Nested fragments and back button cause duplicate id -

i have activity hosts 3 fragments in viewflipper. each of 3 fragments hosts fragments of own. using viewflipper tab control, allows me switch between various "views" in app. works fine, far. when user inside view, there navigation flow. use: final fragmenttransaction txn = getchildfragmentmanager() .begintransaction(); txn.replace(r.id.view1_silo_container, new view1fragment()); txn.addtobackstack(null); txn.commit(); to move around inside view. user navigates, call variation of code above replace current fragment new one. again, works fine far. the problem that, when bottom fragment (a>b>c) , hit button go (c>b) duplicate id error. problem "b" fragment has fragment nested in it. long avoid giving fragment id, there no problem. however, if give fragment id "duplicate id, tag null, or parent id 0x0 fragment". i don't understand why problem, , haven't found way work ar...

Add New Row to SlickGrid -

hi have tried these 2 codes inserting new row in slickgrid. code-1: data1.push({id: "12345", name: "seckey", field: "seckey", complete:true}); //grid1.setdata(data1); //grid1.render(); it inserting undefined in slick grid cell.. code-2: try{ var rowdata = grid1.getdata(); //alert(rowdata+"rowdata"); newid = dataview1.getlength(); //alert(newid); newrow.id = newid + 1; //alert(newrow.id); var newrow = {title: "new title"}; //alert(newrow); dataview1.insertitem(newrow.id, newrow); alert("end"); }catch(e){ alert("error:"+e.description); } the code-2 catches , gives error..let me know wat have code change.! you can follows if using dataview, function addnewrow() { dataview.additem({id: "12345", name: ...

java - What exactly is meant by Spring transactions being atomic? -

my understanding of atomic operation should not possible steps of operation interleaved of other operation - should executed single unit. i have method creating database record first of check if record same value, satisfies other parameters, exists, , if not create record. in fakecode: public class foodao implements ifoodao { @transactional public void createfoo(string foovalue) { if (!fooexists(foovalue)) { // db call create foo } } @transactional public boolean fooexists(string foovalue) { // db call check if foo exists } } however have seen possible 2 records same value created, suggesting these operations have interleaved in way. aware spring's transactional proxies, self-invocation of method within object not use transactional logic, if createfoo() called outside object expect fooexists() still included in same transaction. are expectations transactional atomicity should enforce wrong? need using synch...

ocr - ABBYY Flexicapture Layout/Setup stations recognizing different things -

Image
when build abbyy flexicapture layout in layout studio captures perfectly. after saving , exporting layout setup station of information missing, particularly info in repeating group. for example, in repeating group in layout studio can find 2 'taxes' listed on page. recognized @ quality no errors. however, in setup station, 1 of 2 taxes captured. fl studio location_taxes repeating block fl studio captured taxes (2/2) close of tax repeating group fc studio captured tax (1/2) is there missing cause recognition work in layout studio not in setup/capture? thanks it see abbyy flexilayout project there couple of causes, , test , confirm solution. think see issue enough. when capture elements using repeatable group element, make sure expose capture results in flexilayout studio under blocks block has "has repeating instances" enabled (checkmark). show instances in flexicapture, not first captured instance. think issue, because stated see 1 ins...

php - Recaptcha check page returns nothing -

i have feedback webpage on php-based project. feedback page has form fields need , put recaptcha display there , works fine: displayed , functions according google manuals. form "action" set page should check recaptcha, prevent sql injections , insert user message db. seems simple. the problem in second page. returns blank though shouldnt: <?php require_once('recaptchalib.php'); $privatekey = "my private key"; $resp = recaptcha_check_answer ($privatekey, $_server["remote_addr"], $_post["recaptcha_challenge_field"], $_post["recaptcha_response_field"]); if (!$resp->is_valid) { // happens when captcha entered incorrectly //in case returned page totally blank echo <<<eot <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-tra...

How should I deal with linebreaks in strings I want to marshal in Java to XML? -

how should deal linebreaks in strings want marshal xml? i having difficulty using java , jaxb handle putting strings in xml files have linefeeds in them. data being pulled database actual line feed characters in them. foo <lf> bar or additional example: foo\r\n\r\nbar yields: foo&#xd; &#xd; bar if marshal data xml, literal line feed characters in output. apparently against xml standards characters should encoded &#xd; . ie in xml file output should see: foo &#xd;bar but if try , manually, end ampersand getting encoded! foo &amp;#xd;bar this pretty ironic because process apparently supposed encode linebreaks in first place , not, foiling attempts encode manually. below example of jaxb's default behaviour regarding \n , \r : java model (root) import javax.xml.bind.annotation.xmlrootelement; @xmlrootelement public class root { private string foo; private string bar; public string getfoo() { return...

Synapse/WSO2: Modifying a message in proxy service with iterate mediator -

here's problem i'm trying solve: receive message enrich message calling service obtain information (the other service happens wso2 data service, using mock proxy works same); see here info on enrich pattern send message on way the input message looks this: <purchaseorder xmlns="http://example.com/samples"> <header> <vendordata> <vendornumber>123456</vendornumber> </vendordata> </header> <body> <lineitem> <itemnumber>111222333</itemnumber> </lineitem> <lineitem> <itemnumber>333224444</itemnumber> </lineitem> <lineitem> <itemnumber>123456789</itemnumber> </lineitem> </body> </purchaseorder> ... , output message should this: <purchaseorder xmlns="http://example.com/samples"> <header> <vendordata> <vendornumber>1234...

jquery - Adding and removing input fields -

i have requirement add 4 input fields when user clicking addagent button. allow user remove 1 of those. if user adds 4 input fields, want disable add button. if user removes 1 of 4 input fields, enable add button 1 more add or 2 more add, depending on how many inputs user removed or added. max four. jquery, or sample can get? thanks! here working jsfiddle [demo] <div id="add">add</div> <div id="container"></div> $('#add').bind('click', function() { if($('#container').find('input').length < 4) { $('#container').append('<div><input type="text"><span class="remove">remove</span></div>'); } }) $('body').on('click', '.remove', function() { if($('#container').find('input').length > 0) { $(this).parent().remove(); } })

html - Responsive CSS triangles jQuery not working -

so, funny is, found concept of css triangles using element borders. i'm trying implement in 1 of custom wordpress themes, , i'm running issue. i'm trying add triangle bottom of div (kind of banner), div contains text can set user, can't hard code width of box , triangle. led me jquery try box width, , resize triangle appropriately. when first tried simple script set both borders half total parent width, seems ran issue box resizing elements load (seems slow font loading). wrapped script fire on element resize, doesn't seem triggering. causing triangle stay larger box it's under. can see effect here: http://dev3.thoughtspacedesigns.com here's code: html <div id="logo-box"> <h1><?php bloginfo('name'); ?></h1> <div id="logo-box-point"></div> </div> css #logo-box{ background:#374140; display:inline-block; padding:20px; position:relative; } #logo-...

c++ - Is there a convenience function in win32 (windows.h) that would convert lParam to POINT? -

i keep doing following: lresult onmousemove(uint umsg, wparam wparam, lparam lparam, bool& bhandled) { mouse.x = loword(lparam); mouse.y = hiword(lparam); // ... return 0; } i wonder if there convenience method convert loword(lparam) , hiword(lparam) point me? mouse = topoint(lparam) ? no, trivial roll own: point topoint(lparam lparam) { point p={get_x_lparam(lparam),get_y_lparam(lparam)}; return p; }

httpclient - Android HTTP GET doesn't work -

i know java unfortunately chosen basic4android android development. after working on year realized should move in native solution. question might silly need advice solve it. my goal retrieve data request. i've tried tons of android http client tutorials on internet failed each tutorial. i'm going share 1 here can me fix. when i'm clicking on button, nothing happening without tons of error message in logcat window. main class here quick review: public class mainactivity extends activity implements onclicklistener { private button test; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); test = (button) findviewbyid(r.id.test); test.setonclicklistener(this); } @override public void onclick(view v) { if (v.getid() == r.id.test){ try { httpclient client = new defaulthttpclient(); ...

javascript - Calling super method in sails.js controller -

when create controller in sails.js standard method redefined, how call default parent method of controller? module.exports = { create: function(req, res) { //test parameters if (condition) { //call regular super method, proceed usual //_super(); <- how this? } else { //do other things } } }; update: sails >= v0.10.x, see the comment below @naor-biton if want access default implementation (the blueprint), of v0.9.3, can call next() (the third argument controller). because sails based on express/connect concept of middleware, allowing chain things together. please note behavior may change in subsequent version, since next() how call default 404 handler ( config/404.js ) actions don't have blueprint underneath them. a better approach, if you're interested in using blueprints running bit of logic beforehand, leave controller action undefined , use 1 or more policies, ...

python - Arrange strings for maximum overlap -

let's have set of strings: strings = {'qqq', 'eqq', 'qqw', 'www', 'qww', 'wwe', 'eee', 'eeq', 'wee', 'qwe'} how write algorithm arranges strings such overlap maximally? know 1 way of arranging them follows: qww www wwe wee eee eeq eqq qqq qqw qwe however, found above result brute-force solution. there cleverer way of doing this? this called shortest superstring problem , np complete. you might interested in approaches in paper approximation algorithms shortest common superstring problem jonathan turner .

javascript - Responsive Bootstrap -

i added responsive bootstrap application , things working great. i've been able make modifications layout based on screen resolutions following in application.css file: * // other stuff here...// * *= require_self *= require bootstrap_and_overrides *= require_tree . */ @media (min-width: 1200px) { #winner_table { max-width: 30%; } } now, i'm wondering if it's possible make modifications these javascript based on screen resolution? specifically, want popover on element float right default, float when using phone. options this? may incorrect assuming responsive bootstrap can solve problem, feel solvable problem somehow. you can use matchmedia.js call jquery elements - https://github.com/paulirish/matchmedia.js/

c# - Ajax postback partialview not getting loaded with updated image -

i trying create sample mvc4 webpage partialviews on parent page ,eg., index.cshtml page displaying partialview page allow user view/update profile photo when index page loads ,i need partial page show photo if photo available once page loaded ,when user uploads new photo,i need partialview page ajax postback , show new photo . i able load page photo fetched db, able save new photo db clicking "#btnphotoupload" button. but after saving photo ,the partialview not getting refreshed automatically.please me how partialview page refesh , display updated photo. here index page ie., "index.cshtml" @model mvcsamples.models.viewmodels.userinfoviewmodel @{ viewbag.title = "ajax partial postback demo"; viewbag.userid = 1; } <h2>personalinfo example</h2> <div id="photoform"> @html.partial("_userphoto") </div> <div id="otherdetails"> @html.partial("_userdetails") ...

Gmail not rendering email with html breaks properly when sent from Django -

i'm using django send email user has forgotten password. other email clients render email breaks. gmail doesn't seem care html , squishes text together. here's email looks when rendered in hotmail: hello bob, you receiving email because have (or pretending has) requested new password sent account. if did not request email can let know @ support@mailapp.com. to reset password, enter temporary password below login. temporary password: sebdtzk4cc once logged in, can change password in "edit profile" option under "account" in settings. -the mail app team however in gmail, looks this!: hello bob,you receiving email because have (or pretending has) requested new password sent account. if did not request email can let know @ support@mailapp.com.to reset password, enter temporary password below login.temporary password: sebdtzk4cconce logged in, can change password in "edit profile" option under "account" in settings.-th...

How to call public method jquery plugin from outside? -

i read lot undertand not working. i'm using jquery plugin boilerplate . i have plugin called "defaultpluginname" , have public method inside plugin: sayhey: function(){ alert('hey!'); } i want call method outsise, that: $('#test').defaultpluginname('sayhey'); but not working, follow here fidle link give better view issue: http://jsfiddle.net/tcxwj/ the method trying call not public need alter plugin in order trigger outside plugin. see here how can that: https://github.com/jquery-boilerplate/jquery-boilerplate/wiki/another-extending-jquery-boilerplate . basically need change $.fn[ pluginname ] = function ( options ) { return this.each(function() { if ( !$.data( this, "plugin_" + pluginname ) ) { $.data( this, "plugin_" + pluginname, new plugin( this, options ) ); } }); }; to $.fn[pluginname] = function ( arg ) { var args, instance; // allow ...

coffeescript - jQuery circular reference -

i made jquery plugin/widget oop object , in object saving html/jquery element ( $elem ) property. storing object's reference (created using new ) in data attribute of html element. cause circular reference/memory leakage? the code in coffeescript be: class wid constructor @$elem = $('<div>hello</div>') @$elem.appendto('body') @$elem.data('obj',@) // adding instance element's data attribute updatetext: (p)-> @$ele.text(p) widget = new wid() on real browser, no. internet explorer, microsoft's browser-shaped object, has separate garbage collectors dom , javascript, it's easy create circular references. since ie tightly integrated operating system, merely shutting down browser not free memory: os has rebooted. however, thing: ie becomes slower , slower, weighed down unfreed object references, user learns vital lesson microsoft quality.

sql - Ruby on Rails: Duplicates with Join -

i working on part of app sort list of children based on parent's other children's attributes. here classes i'm working with: class specialchild belongs_to: parent class child_a belongs_to: parent class child_b belongs_to: parent class parent has_many: specialchild has_many: child_a has_one: child_b these 2 order functions applied it: scope :order_child_a, joins("inner join child_a on specialchild.parent_id = child_a.parent_id"). where("booleanvalue = true") scope :order_parent_and_child_b, joins("left outer join parent on specialchild.parent_id = parent.id"). joins("left outer join child_b name on parent.child_b_id = child_b.id"). order("name asc, parent.lastname asc") my problem though there 1 specialchild in list yet parent has multiple child_a's have booleanvalue = true, copies of same specialchild showing if doesn't exist. edit: problem arises in first scope though includ...

javascript - Array[0] but still data in it -

Image
i'm debuging code chrome devtools , have strange ocasion. have array which contains data console shows array[0] when try access it, gives me arror syntaxerror: unexpected token illegal let me show details: there object call console "quick_chat", when expand object there object called data, shows data: array[0], i'm still able expand there object id of chat. as see here data array[0] data in it. how can access console? suggestions? that data stored in property of array, , accessed using: quick_chat.data["3swa8h0clcai"]

How to decipher matlab function syntax ambiguity -

this question has answer here: what @ operator in matlab? 3 answers i cannot find syntax anywhere y = @(beta, x)x*beta; where x vector or matrix lets say. @ used reference function can have more 1 externally visiuble function in same .m file? sorry i'm new matlab can't find in documentation that way define anonymous function in matlab. same function result = y(beta, x) result = x * beta; but without needing m-file or subfunction define it. can constructed within other m-files or within expression. typical use throw-away function inside call of complex function needs function 1 of inputs, i.e.: >> arrayfun(@(x) x^2, 1:10) ans = 1 4 9 16 25 36 49 64 81 100 i use them lot refactor list of repetitive statements a = complex_expression(x, y, z, 1) b = complex_expression(x, y, z, 3) c = complex_ex...

html - How to get an element centered while a floated element is next to it? -

i have element want centered relative page, while having floated element inline it. html: <div class="container"> <span class="centerme">i should centered</span> <span class="ontheright">i'm on right!</span> </div> css: .container{ text-align:center } .centerme{ margin-left:auto; margin-right:auto; } .ontheright{float:right;} the problem centered element centered relative space left over, after floated element uses up. want center relative full width of container. have tried using position:absolute instead of float, collides when screen small. http://jsfiddle.net/j5mff/ you set relative positioning center-me div define left property: .centerme { margin-left:auto; margin-right:auto; position: relative; left: 70px; } for problem colliding on small screen widths, use media query: @media screen , (max-width: 320px) { .ontheright { float: none; top: 20px; } } be sure inclu...

Anyone else having Provisioning Profile Problems in iOS? -

since apple developer site outage, unable add new devices new or existing provisioning profile , have app install without error new devices. devices added before recent outage work fine new , existing profiles, device added since saturday august 3 2013 fails, same file! we have built new profiles , modified existing ones without luck. have submitted bug apple, no response. we distribute through testflight testers, , install works great on old devices prior date. however, devices added since, download file , seem fail @ point "install" takes place (ie, signature check , decryption.) testflight correctly recognizes new (and old) devices being added profile, , installs show in testflight on devices available. my guess keys being corrupted when new devices being added portal. i looking see if else has had problem, , if have kind of workaround issue? have tried new profiles, new builds, new devices! nothing works thanks in advance so problem "went awa...

jquery - Submit with javascript -

how can specify submit button submit with? the current example submits first submit button, $("form").submit(); how can make chooses submit button id or name? <html> <script> $("form").submit(); </script> <form action="<?=$_server['php_self']?>" method="post" /> //other inputs <input type="submit" value="enter" name="enter" id="enter"> <input type="submit" value="void" name="void" id="void"> <input type="submit" value="refund" name="refund" id="refund"> </form> </html> by id you can select element id $('#my_btn') , can click on using jquery method click() . by name (or other attribute other attributes bit harded (but not complex) select element $('input[name=some_name]') examlpe using code here example shows how...

How to SELECT only few rows from a column in sql (SQLite Database Browser)? -

i using sqlite database browser. table : test test has single column "words" values shown below : words -------- apple pen xerox notebook toys zoo stars apes write sql query (which should execute in sqlite database browser) select words between 'xerox' , 'stars' & words 'pen' apes. this may 1 option: select * test rowid between (select rowid test words = 'xerox') + 1 , (select rowid test words = 'stars') - 1 union select '---' union select * test rowid between (select rowid test words = 'pen') , (select rowid test words = 'apes');

github - Gitignore CodeIgniter -

before put first (codeigniter) application on github, have question codeigniter .gitignore file (see below). not have development directory in config directory. can .gitignore */config/* instead? importance of development directory in config directory? */config/development */logs/log-*.php */logs/!index.html */cache/* */cache/!index.html many people set development , production folders in config folders. codeigniter load correct file correct folder depending on environment set in main index.php if you're creating public repository on github copy files passwords , keys (your config.php , database.php 2 come standard framework believe) new folder called development inside config, remove passwords , paths , things ones in root folder. leave gitignore is. this way when push git aren't pushing personal private information project.

python - multiple download folders using Selenium Webdriver? -

i'm using selenium webdriver (in python) automate donwloading of thousands of files. want files saved in different folders. following code works, requires quitting , re-starting webdriver multiple times, slows down process: some_list = ["item1", "item2", "item3"] # on 300 items on actual code item in some_list: download_folder = "/users/myusername/desktop/" + item os.makedirs(download_folder) fp = webdriver.firefoxprofile() fp.set_preference("browser.download.folderlist", 2) fp.set_preference("browser.download.manager.showwhenstarting", false) fp.set_preference("browser.download.dir", download_folder) fp.set_preference("browser.helperapps.neverask.savetodisk", "text/plain") browser = webdriver.firefox(firefox_profile = fp) # bunch of code accesses site , downloads files browser.close() browser.quit() so, @ every iteration have quit webdrive...

javascript - Why is this returning undefined? jquery -

i have line <table id='<?= $value['name']?>'> in php sets id can target. this table inside <div> id="god" . but when click table has script: $("#god table").click(function(){ var link = $(this).id; alert(link); }); it alerts undefined - tell me why is? my best guess targets <td> click on $(this) not sure - , not know how test that. use following: var link = this.id; the jquery object $(this) not have propery id . note: do not use $(this).attr('id') when can use this.id way more efficient. also, note id case sensitive consistent "god" , "god".

java - intent flag over intent startActivity(i); -

@override public void onclick(view view) { // launching news feed screen intent = new intent(getapplicationcontext(), profile.class); startactivity(i); } }); what difference of using code , difference on program compared doe intent = new intent(currentactivityname.this, nextactivityname.class); i.setflags(intent.flag_activity_reorder_to_front); startactivity(i); first 1 uses getapplicationcontext() launch intent. application context attached application's life-cycle , same throughout life of application. if using toast, can use application context or activity context (both) because toast can raised anywhere in application , not attached window. second 1 uses activity context. activity context attached activity's life-cycle , can destroyed if activity's ondestroy raised. if want launch new activity, must need use activity's context in intent n...

textbox - Dismiss Numeric Keyboard WP8 in Code Behind (VB) -

so have numeric keyboard entering few numbers , according other apps , questions best way put done/cancel button application bar have setup without issues. problem when click on done or cancel button want dismiss keyboard can't seem figure part out. i've seen few other posts use this.focus(); that's c# , i'm using vb instead , far haven't been able find similar function. the page still has method called 'focus()' in vb. problem that: (c#) this (vb) me so, it's: me.focus() or, simply: focus()