Posts

Showing posts from June, 2015

php - SimpleXML with decoded entities -

how can make simplexml replace html/xml entities respective characters, in php? assume having xml document, in string: $data = '<?xml version="1.0" encoding="iso-8859-1"?><example>tom &amp; jerry</example>' obviously, want simplexml decode &amp; & . not default. have tried these 2 ways, neither of worked: $xml = new simplexmlelement($data); $xml = new simplexmlelement($data, libxml_noent); what's best way xml entities decoded? guess xml parser should it, avoid running html_entity_decode before parsing (actually, won't work either). may problem encoding of string? if so, how track , fix it? i don't know if going work in cases maybe... $xml = new simplexmlelement(html_entity_decode($data)); http://www.php.net/manual/en/function.html-entity-decode.php

Convert PDF to binary in Ruby -

is there ruby function convert pdf binary data.i need binary data soap api. found lot of reference converting binary file , other formats , need reverse. this shorter type: text = io.read(fname, mode: 'rb') but soap isn't easy deal with. check out savon gem.

sublimetext3 - How to install SFTP plugin in Sublime Text 3 on Windows 7 64bit -

i cannot install st3's sftp plugin on windows 7 64bit. installed menus greyed out, not active. i read support. says: to fix this, please perform following: open preferences > browse packages… navigate sftp/ folder and open sftp.py in sublime. i open browse packages... written there no sftp/ folder in sublime text 3\packages folder thet opened. neither in sublime text 3\packages nor in sublime text 3\packages\user . have 2 folders there: \sublime text 3\packages\package control \sublime text 3\packages\user what do wrong? how may install or set plugin correctly? on computer mentioned directory located here c:\users\user\appdata\roaming\sublime text 3\packages\ . may st3 install plugin other directories? sftp doesn't work in sublime text 3. @ least on windows 7 64 bit. works fine in sublime text 2. uninstalled st3, installed st2 , installed sftp plugin. , quite happy.

Publish Blackberry app for BB10 and BBOS -

i want publish app blackberry 10 have version on app world bbos. version if targeted bb10 overwrite old version targeted bbos? how upload bb10 version keep both versions? when upload application, have choose os target specific release. won't overwrite current version if select qnx targets (bb10 and/or playbook). can select custom set of devices/os version each release.

sql - Select another attribute if the original attribute is NULL (Conditional select) -

how can achieve if want select attribute , if attribute null. i know long way of this: select val1 test_table val1 not null or select val2 test_table val1 null the bad solution if have long , complicated select need write twice... eg: select val1 test_table condition1 , condition2 , condition3 , val1 not null or select val2 test_table condition1 , condition2 , condition3 , val1 null so hope, maybe there shorter form this. anyway if or case in programming languages (i think). any idea appreciated. first ide: inside select can shorten second select select coalesce(val1, val2) test_table

c# - Why is Ajax.BeginForm not working? -

i looked @ several similar questions, can't working. i have radio buttons in form. instead of selecting option , clicking submit button, want submit form when user clicks radio button. so hid submit button , placed javascript function emulates click of button (i tried working button click, doesn't seem problem). in view have: <script type="text/javascript" src="/scripts/jquery-1.9.1/jquery-1.9.1.min.js" ></script> <script type="text/javascript" src="/scripts/jquery-1.9.1/jquery.unobtrusive-ajax.min.js"></script> <script type="text/javascript"> function change() { $('#buttonradio').click(); } </script> <h2>dashboard</h2> <div class="dashboard" id="itemsdshbrd" style="overflow:auto;height:97%;"> <div id="dshbrdradiogroup" style="float:right;font-size:small"> <% usi

c# - Windows 8 phone application runs out of memory -

i have windows phone(lumia 920) app deals lot of images(10 or full resolution) being captured camera. it being sent asynchronously service(wcf) , discarded phone. when wifi little slow photos in memory of phone gets bottle , out of memory exception occurs. this not app on store want increase available usage on phone. i have tried set <requirements> <requirement name="id_req_memory_300" /> </requirements> yet having same issue. have tried saving images isolatedstorage, disposing of in-memory objects, recovering each image in turn form isolatedstorage memory, uploading it, then, when sure has been uploaded, disposing of isolatedstorage version?

ios - Passing compiler flags through xcodebuild -

i'm using xcodebuild automate testing ios. right now, i'm stuck on trying pass compiler flags through xcode directly compiler. these flags are: -fprofile-arcs -ftest-coverage . i don't have liberty of modifying xcodeproj, that's why want inject these flags via xcodebuild command. it like: xcodebuild -project path/to/my.xcodeproj -scheme myapp -fprofile-arcs -ftest-coverage is feasible? how? apparently compiler flags can expressed constants, , these can passed compiler via xcodebuild easily. to them, select option in xcode build settings view, , hit command-c (copy). in case, gcc_generate_test_coverage_files , gcc_instrument_program_flow_arcs . my command looks this: xcodebuild gcc_generate_test_coverage_files=yes gcc_instrument_program_flow_arcs=yes ...

view not refreshing after zend redirect -

so trying do, after user submit information, make call action call saveronda, save information on database, after saving want redirect page, according firebug html correct, view isnt refreshing. here code in /rondas/chooseronda ive got this <span class="st-labeltext">tags da ronda:</span> <table id="toolbar2"></table> <div id="ptoolbar2"></div> <div class="clear" style="z-index: 670;"></div> </div> <div class="st-form-line" style="z-index: 680;"> <span class="st-labeltext">nome da ronda:</span> <input type="text" name="nomeronda" id="nomeronda"> <div class="clear" style="z-index: 670;"></div> </div> <div class="st-form-line" style="z-index: 680;"> <span class="st-labeltext">tag inicial:&

javascript - Radio button value regardless of selected input -

i have code: <input type="radio" name="pay" id="payid" value="banktransfer"> bank transfer <br/> <input type="radio" name="pay" id="payid" value="paypal"> paypal <br/> <br/> i try: var sample = $('#payid').val() alert(sample); why have still banktransfer ? (regardless of selected input)? the id must unique. radios need same name on-off functionality work, each must have unique id. could, instance, have "payid1" , "payid2"

emacs - Replacing yasnippet fields by entries from a list -

recently stumbled across question "a quick way repeatedly enter variable name in emacs?" asks way create , expand snippets "on-the-fly". found package auto-yasnippet created author of question , result of question. package much, expanded functionality. package allows following: you write following snippet: convert img$1.jpg -monochrome -resize 50% -rotate 180 img$1_mono.pdf call aya-create , enter new line , call aya-expand : above code pasted , can replace placeholders ( $1 , $2 , ...) ordinary yasnippet. this great feature, however, if have create many copies of snippet , enter expansion string becomes not fun. nice pass list (or list of lists if have multiple placeholders) used expand placeholders. lets have call above thing files img_1.jpg img_9.jpg , results should called img_a_mono.jpg img_k_mono.jpg , 1 create list: (setq foo-list '( '( 1 2 3 4 5 6 7 8 9 ) '( b c d e f g h j k ) ) write snippet convert img$1.jpg -monoch

jquery - Javascript on carousel breaking -

i made update page: http://www.thesanfordcenter.net/sanford-center , carousel broke on me. should have 4 items able slide right , left, showing of items. pretty new javascript , jquery, apologize in advance if seem bit slow. thank why broken.

javascript - How to check if value is not `blank` in this code using Java Script or jQuery? -

how check if value not blank in code using java script or jquery? <select name="producttype" class="selectoption"> <option class="selectoption" value="blank">select something</option> <option class="selectoption" value="test1">test1</option> <option class="selectoption" value="test2">test2</option> <option class="selectoption" value="test3">test3</option> </select> using jquery: $(".selectoption").on("change", function() { if ($(this).val() != "blank") // });

sql - MAXDOP is set to 0, however, all transactions run in serial -

the server setting maxdop set 0 , threshold default of 5. all transactions run against server run in serial , not against multiple cores/cpus (virtual machine , has 8 cpus). server windows server 2008 r2 enterprise x64 , sql server 2008 r2 enterprise x64. there "default" , "internal" workload group on machine both resource governors not enabled , disabled, have maxdop setting of 0. i've confirmed sql server has cpu affinity across cores/cpus. i'm kind of lost why server refuses run transactions in parallel opposed other machines @ location. came in noticing many of servers here had long cxpacket wait times , many processes causing wasted cpu overhead. dba said after reading evaluation there nothing wrong maxdop 0 , threshold of 5 because xxxx server never runs in parallel say. i believe evaluation of site still correct, darn server debunking evaluation. i open suggestions why server not configured , should run in parallel doesn't.

user interface - Domain Entity and UI Entity -

we creating project using mvc c# in application having following layers: presentation (mvc) controller view domain domain entity repository interface interface unit of works infrastructure (dataaccess) repository unit of works edmx data entity our domain entity , data entity same. poco class. have bound our views domain entity tightly coupled. question: 1. correct or create viewmodel entity our views? 2. pass our data entity our view save on mapping? i dont think rigth... talking mvc, our layers meens model, view,controller, maybe

xamarin.ios - Error rebuilding ATMHud.DLL for Monotouch -

after updating latest versions of xamarin studio morning zbar , atmhud references in our project started throwing bunch of errors, of were: the type 'monotouch.uikit.uiviewcontroller' defined in assembly not referenced. consider adding reference assembly 'monotouch, version=0.0.0.0, culture=neutral, publickeytoken=null' (cs0012)' i did reading , found out needed rebuild both of libraries because of "assembly strong names" in xamarin. able muddle way through rebuilding zbar library, atmhud rebuild has given me trouble , i'm not familiar enough i'm doing fix problem. i downloaded atmhud project github , followed instructions in readme state "run 'make' in binding directory build atmhud.dll", when errors. teds-mac:binding ted$ make /developer/monotouch/usr/bin/btouch -e atmhud.cs enums.cs assemblyinfo.cs --out=atmhud.dll --link-with=libatmhudsdk.a,libatmhudsdk.a /var/folders/75/vl_6zkyx03sc4tymnp41lsgw0000gn/t/09x9yx

ios - Saving Photos to Core Data -

i want save photo core data. in internet , find many resources core data cannot find 1 want accomplish. want use core data save images user has taken , want user select category wants save it. sorting pictures categories example meat or vegetables or etc. have made 1 entity called photo , put 6 attributes name of categories example meat vegetables. did not select type yet. thinking user chooses category , save attribute. here's question. want cannot find resources meet want do. doing correct thinking of using multiple attributes? scroll down storing uiimage data in core data, firstly bit core data attributes: shouldn't use multiple attributes different categories, should have single attribute called 'category'. integer or string, depending on implementation. recommend using integer , defining enum follows: typedef ns_enum(nsuinteger, myfoodcategory){ myfoodcategoryvegetable = 0, myfoodcategorymeat = 1, myfoodcategoryfish = 2, myfoo

linux - GPIO output value not changing -

i trying setup output gpio pin on nitrogen6x board, can't change file value . navigated /sys/class/gpio/ , exported pin (gpio18) echo 18 > export . able change direction command echo out > direction , seems should able change value file same way, echo 1 > value , doesn't seem working. logged in root , permissions on both direction file , value file same: -rw-r--r-- 1 root root . does have idea why not writing file? thanks of help! the commands have listed should work, if gpio number correct. while have not worked nitrogen6x in particular, have found out linux gpio pin numbers not match labels on board. advice trying find out proper mapping experimentally watching possible gpios: cd /sys/class/gpio x in `seq 1 128`; echo $x > export; done ground pin in question via 10k resistor, run: grep . gpio*/value > /tmp/values0 connect pin in question vcc via 10k resistor, run: grep . gpio*/value > /tmp/values1 diff files, , pay a

java - Saving large short array android -

i'm looking way save , reload few large arrays (about 5 million short ) in fastish way on android. app needs save them in way them later, can't hold them in memory... so far, i've tried converting them byte[] array , seem save successfully, can't data back, how saving code works (it's separate functions, simplified here): bytearrayoutputstream baos = new bytearrayoutputstream(); objectouputstream oos = new objectoutputstream(baos); oos.writeobject(data); oos.close(); baos.close(); fileoutputstream fos = new fileoutputstream(filename); // valid absolute path fos.write(baos.tobytearray()); fos.close(); and loading part stuck, how short[] byte[] ? read database might work too, quick enough? i've looked around stackoverflow , google , can't seem find similar problem, or @ least solution it, beginner might have missed obvious... if data short[] , want write whole thing file, don't use buffer in memory, write directly. objectoutputst

How to limit the product quantity for specific items in magento -

i'm setting magento site client sells fabric , other related materials. there minimum of .5 yard 1 fabric product, after that, can go amount, minimum .5. i'm able type in .25, .125, etc. , add shopping cart. i want apply fabric products (there around 2000 different fabric products) not other types sells on site, rulers, needles, buttons, etc... don't want people able purchase .5 buttons. thanks you might need observer monitors checkout_cart_product_add_after event. event passes following parameter: array('quote_item' => $result, 'product' => $product) here, check quantity via quote_item , product's category (if it's fabric or not) via product . imagine here remove specific quote item cart if decimal value , not member of 'fabric' category. good luck.

jquery - SPServices applications on SharePoint 2010. Will it work on SharePoint 2013? -

i'm using spservices develop on sharepoint 2010. organization upgrading sharepoint 2013 sometime in future. need (if anything) when new sharepoint server installed keep using spservices library? i'm using getlistitems, updatelistitems, createlistitems , query operations. per article linked in response question - depend on number of factors , deprecated between 2010 , 2013...but can tell able port company news site/portal made extensive use of getlistitem ajax calls , search queries no issues. keep in mind lot of stuff still works in 2013 deprecated , removed entirely in future releases. here's list starters: http://www.c-sharpcorner.com/uploadfile/roji.joy/deprecated-features-in-sharepoint-2013-from-sharepoint-2010/

jdbc - Java SQL Resultset retrieval order is not correct -

hi have following 3 row in table tb1 key time id rowid x 11:40 1 1 y 4:50 1 2 z 6:48 1 2 now using jdbc records , iterating on resultset shown below: rs = statement.executequery("select * tb1") resultsetmetadata md = rs.getmetadata(); int cols = md.getcolumncount(); while(rs.next()) { for(int = 1; <= cols ; i++) { system.out.println("col name " + md.getcolumnname(i)); system.out.println("col name " + rs.getobject(i)); } } when execute above code strangely prints second row first , first row , third row. in short resultset data retrieval not in order. dont understand why? please guide. in advance. you have not specified "order by" clause. in general, databases not required return rows in order unless "order by" clause specified. add order clause select statement.

Loop playback with ffmpeg + ffserver -

i have ffserver multicast stream other devices , ffmpeg send input video ffserver using following command: ffmpeg -re -y -i ~/videofile.mp4 http://192.168.2.38:8090/f.ffm is possible loop video playback, mean after videofile.mp4 ends, ffmpeg or ffserver restarts playback beggining of file? i couldn't find key ffmpeg loop playback, can done using shell script: #!/bin/sh while [ 1 ] ; ffmpeg -re -y -i /path_to_videofile http://url:8090/f.ffm done

MySQL error at line 1 when I try to insert values -

php script: <?php include('connect.php'); if (isset($_post['project_name'])){ $name = $_post['project_name']; $date = $_post['date']; $amount = $_post['amount']; $curr = $_post['curr']; $spec = $_post['spec']; $sql = "insert projects (name, date, currency, amount, specifications) values '$name','$date','$amount','$curr','$spec'" or die(mysql_error()."update failed"); $insert = mysql_query($sql); if($insert){ echo "successful"; echo "<br>"; echo "<a href='insert.php'>back main page</a>"; } else { ?> html form here <?php } ?> note: connect.php file working ok since i've used before on other scripts on same server. every time try submit form ( method = post ), error: you have error in sql syntax; check manual corresponds mysql server version right syntax use

Weird behavior of XCode4.6 base localization: Works on simulator but only PARTLY on device -

i tried use base localization project using xcode4.6. weird thing works on simulator , on ad-hoc testing device loaded archive itunes, on development iphone connected xcode, language setting german, localizable.strings shown in german, none of mainstoryboard_iphone.strings - shown in english. have cleaned product, deleted app development iphone, changed language settings english , forth german, restarted xcode etc. result same: development iphone not translate storyboard files, although translated on simulator , on ad-hoc testing device. configuration: have base localization storyboard, , localization of in 2 languages (english , german), i.e. in project folder there folder base.lproj containing mainstoryboard_iphone.storyboard , en.lproj folder containing infoplist.strings , localizable.strings , , mainstoryboard_iphone.strings (apart mainstoryboard_ipad.storyboard , don't use right now), , de.lproj folder containing files same name. base localization english. english

Testing an externally hosted app on HTTPS using Karma -

i have angularjs/flask app (serverside) redirects https version of if you're not on https. i'd use karma test app using https, btu can't locally without running https server on own computer (which hassle), pushed app heroku site (say @ mine.herokuapp.com ) has ssl. now, i'm trying run karma tests against external site config file like var proxypath = 'mine.herokuapp.com'; files = [ ... ]; urlroot = '/_karma_/'; singlerun = true; browsers = ['chrome']; proxies = { '/': proxypath }; but when try run tests, error sandbox error: application document not accessible upon navigating app. i'm positive nothing wrong on heroku side; can navigate there fine. there way test https in karma or on wild goose chase? i had problem running dev site in iis redirect http requests https i still haven't go working, can @ least load site inside iframe in karma runner i had specify hostname , allow invalid ssl certificat

jquery - How can I render a grails model to javascript using a post method from a controller action? -

at jquery event want call upon controller action , use data. way did until was: $('#my-button').click(function(){ $.post("${createlink(controller: 'myview', action: 'myaction')}", {param1: x, param2: y}, function(data){ //in here want use both elements of model see fit. }) }); my controller method looks this: def myaction(param1, param2){ //some data manipulation goes here render model: [returnvalue1: variable1, returnvalue2: variable2]; } my question how can access variable1 , variable2 $.post method? if don't use model , return 1 of variables, data equal variable, in case won't. can tell me how access variables in model please? calling ${returnvalue1} not work in function. you can render json object representing model. here's render documentation render(contenttype: "text/json") { [returnvalue1: variable1, returnvalue2: variable2] } or render([returnvalue1: variable1, returnvalue2: variable

format - EDI, 852 Product Transfer: N1 loop out of order? -

i have build edi report i'm working on. i'm using edi notepad validate output. while edi readable edi notepad, keep getting errors have few n1 loops out of order. gives? i've been reading through spec afternoon trying figure out, , see no mention of n1 order anywhere. doing wrong? here's edi in question: isa*00* *00* *12*abccom *01*999999999 *110127*1719*u*00400*000005438*0*p*>~ gs*pd*4405197800*999999999*20110127*1719*1421*x*004010vics~ st*852*000008315~ xq*g*20130807*20130807~ n1*st**11*ad6448446~ lin**ua*53233*pi*76189053560~ za*qa*0*ea~ za*qs*0*ea~ lin**ua*53234*pi*76189053430~ za*qa*0*ea~ za*qs*0*ea~ n1*st**11*bd9628542~ lin**ua*53234*pi*76189053430~ za*qa*30*ea~ za*qs*0*ea~ lin**ua*53233*pi*76189053560~ za*qa*0*ea~ za*qs*60*ea~ n1*st**11*fd0286244~ lin**ua*53233*pi*76189053560~ za*qa*180*ea~ za*qs*930*ea~ lin**ua*53234*pi*76189053430~ za*qa*390*ea~ za*qs*585*ea~ n1*st**11*bd9076008~ lin**ua*53234*pi*76189053430~ za*qa

powershell - I am not able to find my webparts after deploying them to sharepoint site -

i have add .wsp package sharepoint site , deployed through sharepoint central management web app. it says deployed not see in gallery. did miss step ? thanks, won't let me answer own question :p able solve it: ok after additional clicking around central management web app found disconnect. here steps worked first published package of solution right click on project select publish select folder save .wsp file open sharepoint powershell , execute add-spsolution [path wsp file] open sharepoint central management web application select system settings on left side menu find solution , click deploy missing part go on sharepoint home site under site actions go site settings page look web parts in gallery section on library tools strip select documents click on new document , pop list of new webparts appear scroll , find web parts check out web parts solution click populate gallery should find web part under misc. folder this assumes sp admin. hope

ios - When is it appropriate to release CGImageRef? -

when xcode analyzes code, finds potential memory leaks. use arc , learned arc doesn't handle c types. since use cgimageref in order create uiimage , assign uiimageview.image property, when appropriate release cgimageref ? can release right after create new uiimage it? if release cgimageref , make uiimage instance invalid? uiimageview retains image property (if needs it) or copies - whatever. once have set property, can release cgimageref.

c++ - Does a win32 application have one message loop? Or is it one message loop per window? -

i'm little bit confused how message loops work in win32 programming. in winmain put following: while ( getmessage ( &msg, null, 0, 0 ) > 0 ) { translatemessage ( &msg ); dispatchmessage ( &msg ); } this while loop pretty runs until application stops. mean have 1 message loop per application rather per window? from about messages , message queues : applications multiple threads can include message loop in each thread creates window. note messsage queue can support multiple windows... second parameter of getmessage handle of window want watch messages for. if null windows of thread. as second note, possible create message queue without windows (at least windows 2000 onward). described in documentation postthreadmessage : in thread message posted, call peekmessage shown here force system create message queue. peekmessage(&msg, null, wm_user, wm_user, pm_noremove)

java - How can I write a function boolean succeeds(char a, char b, String s)? using s.equals(""), s.charAt(0), s.substring(1) -

i trying write function takes string s , returns true if every occurrence of character b succeeded character a, , false otherwise. have tried: boolean succeeds(char a, char b, string s) { boolean to_return = true; boolean seen_a = false; while(true) { if (s.equals("")) return to_return; char c2 = s.charat(0); if (c2 == a) seen_a = true; if (c2 == b) { if (!seen_a) return false; } s = s.substring(1); } } } i think have right idea. don't know how put together. given guidelines, can along lines of while (!s.equals("")) { char c = s.charat(0); // record first char s = s.substring(1); // cut off first char // if "first char 'b' , next // not 'a'", can return false if (c == b && (s.equals("") || s.charat(0) != a)) return false; } return true; by

javascript - Remove the latest URL parameter after "/" -

i need remove text (or parameters) after latest "/" in url , did this: var current_url = $(location).attr('href'); var clean_url = current_url.substring(current_url.lastindexof('/') + 1); but it's not working because text (or parameters) after latest "/" , don't want that. how? what's wrong in code? substring returns string starting @ index specified first parameter, , going until index specified second parameter, or end if there isn't second parameter. try this: var current_url = location.href; var clean_url = current_url.substring(0, current_url.lastindexof('/') + 1);

javascript - Is there any way to change the CSS of the Facebook Like Box? -

so i'm trying, through whatever way possible, modify facebook box's css. i've found offending value , want change it. inside of iframe. the css this: .pluginlikeboxstream { overflow-x: hidden; overflow-y: auto; } this causing there scrollbar on box stream, really, don't want. i'm not seeing anyway modify - not javascript sdk (which best hope, think), not through using javascript or jquery on (as creates iframe, impossible, far can tell - though firebug lets me change this). obviously best solution able set style using css, seems impossible. is there way fix this? i've tried load iframe no scrollbars, that's on outside of iframe - internal. all want class set overflow: hidden; it not possible change css of official facebook box because external iframe. read more in this duplicate.

css - How to modify wrapper div error class when using CakePHP with Bootstrap -

i'm using bootstrap 3.0rc1 cakephp 2.3.6 . trying take advantage of beautiful looking classes has-error , has-warning validation states , need change default element class formhelper adds wrapping div. so far i'm using code: echo $this->form->create('user', array( 'inputdefaults' => array( 'class' => 'form-control', 'div' => array('class' => 'form-group'), 'label' => array('class' => 'control-label'), 'error' => array('attributes' => array('wrap' => 'span', 'class' => 'help-block')) ) )); echo $this->form->input('email')); which output on error: <div class="form-group error"> <label for="useremail" class="control-label">email</label> <input name="data[user][email]" class="f

javascript - angular-ui and datepicker directive error -

i trying following example/demo , keep getting error in chrome console: error: non-assignable model expression: undefined (directive: datepicker) i dont 404s during execution. the code used based on: http://angular-ui.github.io/bootstrap/#/modal or http://plnkr.co/edit/?p=preview the code in modal template: <pre>selected date is: <em>{{dt | date:'fulldate' }}</em></pre> <div class="well well-small pull-left" ng-model="dt"> <datepicker min="mindate" show-weeks="showweeks"></datepicker> </div> the code in modal controller: $scope.today = function () { $scope.dt = new date(); }; $scope.today(); $scope.showweeks = true; $scope.toggleweeks = function () { $scope.showweeks = !$scope.showweeks; }; $scope.togglemin = function () { $scope.mindate = ($scope.mindate) ? null : new date(); }; $scope.

mysql - Database full of duplicate entries -

i have huge database full of duplicate entry errors. fastest way remove of errors? error: 1062 - duplicate entry 'x' key 'primary' thanks in advance. if no matter left in table that: dump datebase truncate tables add pk whatever need (empty db) in console replace dump insert insert ignore recover dump profit i did once, not @ production/not big db - 200mb per dump - anoing relation issue @ localhost. know it's not pretty... me worked. edit: if thinks it's bad solution, please leave comment - know how better...

python - For Loop with Bool -

i have simple loop gets stuck on division 0 error. running bool filter out zero-value denominators, reason bool used isn't working. can please help? using python 2.6.5 here sample code: for in range(0,len(lines)): line = lines[i] line = line.split(";") leansz = line[9] fw = line[34] fs = line[35] print "fs: %s %s"%(fs,type(fs)) #troubleshooting denominator , type if fs == "0": #i have tried fs == 0 , fs == "0" no avail print 'fs == "0"' #checking if bool working continue #return top of loop if denominator 0 lnszra = float(leansz)/(float(fs)/2) #division 0 error here sample of returned , error: fs: 184 <type 'str'> fs: 1241 <type 'str'> fs: 2763 <type 'str'> fs: 1073 <type 'str'> fs: 971 <type 'str'> fs: 0 <type 'str'> traceback (most recent call last): file

java - Tapestry - Writing a file to webapp directory -

i'm trying write out xml file within subdirectory of webapp. let's case directory is: c:\tapestry\xyz\src\main\webapp\directory1\ how can part of file path c:\tapestry\xyz\src\main\webapp\ within 1 of java classes? don't want hard code because won't portable. thanks,

Variables in Python: Add and change variables -

i making game in python, , want add store. i want variable. know how add variables, , how change them, not how increase or decrease variable. i have never used variables before. have read it, don't remember it. def level1(): os.system('cls') gold = 500 print print 'you have currently', print (gold), print 'gold' time.sleep(3) level2() def level2(): print print 'congratulation! completed quest! received 200 gold.' time.sleep(2) gold =+ 200 print 'you have now', print (gold), print 'gold.' time.sleep(5) and result is: you have 500 gold congratulation! completed quest! received 200 gold. have 200 gold. i tried gold + 200, gold += 200, , gold =+ 200, last 1 worked. i tried print 'you have now' + gold + 'gold' but didn't work reason. tried print 'you have now' + (gold) + 'gold' i not quite sure what's wrong here, , appreciate can get! thank much. edit: i forgot add

javascript - CSS3 transition fails to animate when inside setInterval -

i'll start off saying have gotten work using jquery .animate, i'd increase performance , try using css3 transitions. when added "transition: opacity 0.6s;" label , used jquery change css value, words generating fade animation disappeared. original jquery method looked this: start 4 animations opacity:0 loop generates 4 new words inside settimeout start 4 animations opacity:1 the thing found odd animations started working after commented out settimeout , setinterval. having either of these in there made stop working. strikes me odd, because use here unrelated (afaik). googled around , have seen people mentioning these functions in relation css3 transitions, have been unable find explains going on here. function printwords() { var words = ["list","of","random","words"]; var selectors = ['div#northslogan', 'div#eastslogan', 'div#southslogan', 'div#westslogan']; /* populate a

c++ - What happens when object is destroyed when it is stuck in an infinite loop? -

i want know happen when destructor gets called on object when object stuck in infinite while loop in different thread. // main thread creates object myclass _obj = new myclass(): // doing stuff delete _obj; where, myclass::myclass() { // start thread calls myclass::mypollingfn() } myclass:: mypollingfn() { // runs in new child thread while(true) { // doing work // sleep(5 seconds) } } explanation: there class object of myclass creates thread , runs mypollingfn method in infinite loop. every iteration of method can change class variables. ok destroy object parent thread holds object? there possibility of giving issue? if mypollingfn ever touches this , explicitly or implicitly (e.g. accessing non-static member variables), code exhibit undefined behavior, this become dangling pointer. and if doesn't touch this , why make non-static member function?

Telerik reporting, how do get a report to print to the very edge of the paper? -

i trying design telerik report , have text print way edge of report. have set margins 0" , in print preview see want on paper when print document, right , left edges of report cut off. according telerik document if see text on screen should expect see text on paper not happening. each printer has hardware margins cannot avoided. experiment program such word/excel - result same.

linux - Raspberry pi network -

is possible write program connect , disconnect raspberry pi, running raspbian, wifi network. instance connect network when picture taken due motion observed. connect network send out email , disconnect itself. possible , simplest way this. note: when raspberry pi connected network whole network seems slow after amount of time why want connect , disconnect. if pi able connect @ will, assume has interface configured appropriately local network. knowing this, connecting , disconnecting simple bash command ifup , ifdown . if you're using bash script: # code taking , saving picture (i'll leave you) ifup wlan0 echo "raspberry pi took pic!" | mail -s "new picture taken" you@yourdomain.com ifdown wlan0 # more code finish out program of course, replace wlan0 relevant interface system (which may wlan0). happy coding! :)

batch processing - automatic loading of directory files into a python script -

i have 125 files in directory on linux machine. have script called annotate.py takes in 1 single file , adds features column. able put filename of 1 of 125 files , run annotate.py script, not effective programming. all 125 files have similar format in terms of column names, , column numbers. can please tell me how can run annotate.py on 125 files? annotate.py merges 2 files on chromosome , position columns. input_file1 125 files read in 1 @ time , merged input_file2. output should different files each name of original input file 1. #!/usr/bin/python #python snp_search.py input_file1 input_file2 import numpy np import pandas pd snp_f=pd.read_table('input_file1.txt', sep="\t", header=none)#input_file1 snp_f.columns=['chr','pos'] lsnp_f=pd.read_table('input2_snpsearch.txt', sep="\t", header=true)#input_file2 lsnp_f.columns=['snpid','chr','pos'] final_snp=pd.merge(snp_f,lsnp_f, on=['chr','

linux - Does Tomcat uses the java under the symbolic link /usr/bin/java? -

i have 2 linux servers having tomcat 7.0.42 running 2 java applications packaged in 2 war files. i'm using jdk7u25 on linux, 1 of them still has symbolic link jdk1.4.2 (i have no admin rights, can't change it). the linux server has correct symbolic link /usr/bin/java --> jdk 7, works fine. applications running without issues. the other linux server has /usr/bin/java --> jdk1.4.2, has java_home in tomcat set jdk 7, (java_home=//jdk_1.7.0.25/), throws me error when deploying apps. apps need forkjoin api (available in jdk 7). the difference noticed between these 2 servers, symbolic links. i copied working tomcat (directory + apps + jdk) not working server, , set java_home imported working jdk, still not working... keeps throwing me error message , can't run apps. here logs, although think it's not explicit enough understand doing. warning: exception encountered when executing asynchronous task com.quartetfs.fwk.quartetruntimeexception: com.quartetfs

jQuery css() not working in if statement -

i have if statement checks see if image displayed in dom smaller 600px wide, , if was, image resized different width. it's not working. correct value displayed in alert doesn't passed css line below. idea why happening? jquery $('span.i_contact').each(function() { var imgwidth = parseint($(this).data('image-width')); console.log(imgwidth) if (imgwidth < 600) { var newwidth = ((imgwidth / 600) * 300) alert(newwidth) $(this).css({ "width":newwidth }) } var pos_width = ($(this).data('poswidth')) / 2.025; var pos_height = ($(this).data('posheight')) / 2.025; var xpos = ($(this).data('posx')) / 2.025; var ypos = ($(this).data('posy')) / 2.025; var taggednode = $('<div class="tagged" />') taggednode.css({ "border":"5px solid orange", "width":pos_width, "height":pos

Fallback Javascript with PHP from CDN to Local Storage on Unavailable -

i need help. create fallback sourcecode. using cdn host javascript , css , images. trying create fallback in php instance ip 123.456.789 not available in 400ms php falback fetch local storage @ 987.654.321 so thinking on lines of (bare me, amatuer example) if ip 123.456.789 in 400ms //show file 123.456.789 else //show file 987.654.321 i have source code hard coded such as: <script type="text/javascript" src="123.456.789/js/jquery.js"></script> so if 123.456.789 not available in 400ms 1 load <script type="text/javascript" src="987.654.321/js/jquery.js"></script> i answered own question while ago. decided share here. <?php //debug off default error_reporting(0); //cdn fallback if (!isset($_get['aws_cdn'])) { $cdn_fallback = curl_init('http://123.456.789/'); //set cdn ip or url curl_setopt($cdn_fallback, curlopt_returntransfer, true); curl_setopt($cd

java - How to append 4 digit number to the next string read from file -

i have 1 file read this mytxt.txt 1234 http://www.abc.com 8754 http://www.xyz.com i tried this try { // make 'file' object file file = new file("e:/mytxt.txt"); // data file using file reader. filereader fr = new filereader(file); // store contents read via file reader bufferedreader br = new bufferedreader(fr); // read br , store line in 'data', print data string data; while((data = br.readline()) != null) { //data = br.readline( ); system.out.println(data); } } catch(ioexception e) { system.out.println("bad !"); } i used actual question want read 1 2 charachter 1 one , appens digit link i'll read string. can tell me how suppose that..? appreciated.

ios - Strings end up as nulls -

i have sequence of code. in there custom objects: item , itemlist . relevant members of these item.code , itemlist.itemdictionary . item.code nsstring code (like "avk") uniquely identifies item . these items separated categories. there 4 categories (named "catone", etc). itemdictionary dictionary category names keys , nsmutablearray object; array filled item objects part of category. the basic problem when try access item.code , string comes out (null) . the functionality have array of updated items ( updateditems ) , want update itemlist.itemdictionary these new items. the following properties of object, , synthesized in main file. @synthesize itemlistfromfile; @synthesize updateditems; @synthesize temppassedmanifest; and code: -(id) updateditems:(nsarray *)newitems manifest:(manifest *)manifest { itemlistfromfile = [[itemlist alloc] init]; itemlistfromfile.itemdictionary = [[nsmutabledictionary alloc] init]; itemlistfromfile = [nskeyedun