Posts

Showing posts from March, 2012

spring - What is the best way to do BULK INSERT using Java? -

i'm trying make app can save lot of structured objects in database. using spring data jpa (with hibernate + mysql (myisam tables + foreign keys)) write code data services easy , pleasant using spring data repositories performance slow. for example, tried insert 100 records in 1 table , takes 8,5 sec. i've try same insert operations straight in mysql cmd (using hardcoded "insert strings" in procedure) , shows me time - 0,85 sec. such result me slow, problem of mysql reading forum have found post says spring data jpa can't bulk insert properly. how can make app more faster? want use bulk insert operations size 1000 or more. the situation complicated fact can't store object db in 1 bulk (despite size of bulk) to make clearer: the objectgame contains list of objectround objectgame contains list of objectgameplayer objectround contains list of objectroundcard objectgameplayer contains list of objectplayercard objectgameplayer contains list of o

android - Load a video from gallery into VideoView -

what want same images. when user clicks on button (in case videoview itself) want let them open gallery , load video videoview. vv_video = (videoview) findviewbyid(r.id.vv_video); vv_video.setontouchlistener(new view.ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { intent intent = new intent(); intent.settype("video/*"); intent.setaction(intent.action_get_content); startactivityforresult(intent.createchooser(intent, "complete action using"), load_video); return false; } }); @override public void onactivityresult(int requestcode, int resultcode, intent data) { if (resultcode != result_ok) return; switch (requestcode) { case load_video: toast.maketext(newbucketactivity.this, "test", toast.length_short).show(); //this appears!

Android, Google maps and changing "required" in uses-permission -

i have code in app uses google maps: <uses-permission android:name="com.example.app.permission.maps_receive" /> <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" /> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-feature android:glesversion="0x00020000" android:required="true" /> i have started wonder though, if set these required="false" app presumbly generated shorter "requires" list when users download app... there reason not set them not required? currently when loading maps private void setupmapgoogleifneeded() { if (mmapgoogle == null) { mfragmentmanager = getsupportfragmentmanager(); msupportmapfragment = (supportmapfragment) mfragmentmanager.findfragmentbyid(r.id.mapfr

Android Google Map V2 - Find my location error -

i'm trying retrieve device's location faced several problems: my logcat: 07-21 22:23:34.072: e/androidruntime(11634): fatal exception: main 07-21 22:23:34.072: e/androidruntime(11634): java.lang.runtimeexception: unable start activity componentinfo{com.test.projecttest/com.test.projecttest.mainactivity}: java.lang.nullpointerexception 07-21 22:23:34.072: e/androidruntime(11634): @ android.app.activitythread.performlaunchactivity(activitythread.java:2081) 07-21 22:23:34.072: e/androidruntime(11634): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2106) 07-21 22:23:34.072: e/androidruntime(11634): @ android.app.activitythread.access$700(activitythread.java:134) 07-21 22:23:34.072: e/androidruntime(11634): @ android.app.activitythread$h.handlemessage(activitythread.java:1217) 07-21 22:23:34.072: e/androidruntime(11634): @ android.os.handler.dispatchmessage(handler.java:99) 07-21 22:23:34.072: e/androidruntime(11634): @ android.os.loo

Linux Git repository and TortoiseGIT -

i've browsed web find solution found many variants none of solves problem. i'm starting use git , want have main repository on linux server work locally on windows. have created repository in root of website using git init : cd /var/www git init then i've successfuly added files , committed them. have history displayed in logs: commit eac728dc06731788e6f39e5ed2a819aa7f0fae1e author: max <my_email@gmail.com> date: sun jul 21 15:06:56 2013 +0400 now want able clone repository windows. want use tortoisegit purpose. i've read need create .ssh keys on linux , copy them windows. i've generated them using ssh-keygen -t rsa -c "my_email@example.com" on linux , copied c:\documents , settings\user on windows. other article says have put them gitosis-admin/keydir - don't know is. first question is do need copy keys generated on linux windows? if so, folder should place them at? when open tortoisegit asks url git repository. i'm access

Django object.id does not match with the objects used in reverse url look up -

Image
i have model "listing" represents companies, model "lead" represents different projects can assigned companies. associated via many many relationship since company can assigned many leads many leads can associated many other companies. models listed below. leads displayed in listing admin page inline elements. there snippet used display link directly lead edit page of object done through reverse url. problem object.id argument wrong not corresponding leads id other number. in image above lead id shown "53".but in reality 78. pointers may missing appreciated. #admin.py def url_to_edit_object(self,object): #info = (object._meta.app_label, object._meta.module_name) admin_url = reverse('admin:dirapp_lead_change', args=(object.id,)) return u'<a href="%s">edit</a>' %(admin_url) lead model: class lead(models.model): slug = models.slugfiel

asp.net mvc - SignalR - Calling Hub class method (present in a separate MVC project) from Server side code -

i have read signalr tutorials. in order implement signalr in existing asp.net solution application did following: i have created separate mvc 4 project , created hub class along methods, can called other mvc project/client present in existing solution, means use service. but have 2 questions: how can call other mvc project. same way mentioned in tutorials, example adding necessary script files in head of .cshtml page , using js script following: var hub = $.connection.; //and hub.server.send("some args"); i want call hub code directly server side code. did before when using supersocket. same approach using signalr. how can ? if answer, kindly please give code sample(s). many thanks. there sample code calling client methods outside hub class (but within application) here . basically, use connectionmanager call hub's clients. var context = globalhost.connectionmanager.gethubcontext<myhub>(); context.clients.all.myclientmethod(myvalue);

Search for files (with conditions) in the Google Drive SDK using Java -

i'm trying search files in drive java, i'm not sure how set conditions. example given in video tutorial in python. so, here method retrieve list of files drive: private static list<file> retrieveallfiles(drive service) throws ioexception { list<file> result = new arraylist<file>(); files.list request = service.files().list(); { try { filelist files = request.execute(); result.addall(files.getitems()); request.setpagetoken(files.getnextpagetoken()); } catch (ioexception e) { system.out.println("an error occurred: " + e); request.setpagetoken(null); } } while (request.getpagetoken() != null && request.getpagetoken().length() > 0); return result; } now, mention here file.list method accepts q parameter. how can that? when try set parameter examples given in video q = "title contains 'fruit&#

python - Running webapp2 app in a multiple WSGI apps set up with Werkzeug -

i trying run django app , webapp2 app in 1 python interpreter. i'm using werkzeug described here . here's sample code. from werkzeug.wsgi import dispatchermiddleware django_app import application djangoapp webapp2_app import application webapp2app application = dispatchermiddleware(djangoapp, { '/backend': webapp2app }) after doing this, expect requests /backend should treated webapp2 app /. treats requests /backend. work fines other wsgi apps using django or flask. problem appears webapp2 apps. have suggestions how overcome this? there other way can achieve purpose without using werkzeug serving multiple wsgi apps under 1 domain? dispatchermiddleware fabricates environments apps , script_name . django can deal with configuration varibale force_script_name = '' ( docs ). with webapp2 it's more complicated. can create subclass of webapp2.wsgiapplication , override __call__() method , force script_name desired value. in webap

Display categories on Magento -

i create 1 root categori , 2 sub-categories http://i.imgur.com/aek3mo9.jpg and create new static block http://i.imgur.com/tnm5ucc.jpg the next make file categories.phtml in app/design/frontend/default/my_template/template/catalog/navigation categories.phtml <?php foreach ($this->getstorecategories() $_category): ?> <?php $open = $this->iscategoryactive($_category); ?> <?php $cur_category=mage::getmodel('catalog/category')->load($_category->getid()); $layer = mage::getsingleton('catalog/layer'); $layer->setcurrentcategory($cur_category); if ($immagine = $this->getcurrentcategory()->getimageurl()): ?> <div style="float: left; padding-right: 30px; text-align: center;"> <div class="linkimage"> <p> <a href="<?php echo $this->getcategoryurl($_category)?>"> <img src="<?php echo $immagine ?>" alt="<?php echo $this->htmlescape

java - Categorize ArrayList of objects based on their property -

i have arraylist of products, , each product has category property (so each category can have many products). need format data products categorized according category property. i think hashmap useful, use category key , arraylist of products value. if correct approach, can assist me logic involved in turning arraylist hashmap have described? or maybe there better way of handling it. /** update **/ here sample method, i'm not sure how make logic happen: private hashmap<string, arraylist> sortproductsbycategory (arraylist<product> productlist) { // hashmap value category name, , value array of products hashmap<string, arraylist> map; for(product product: productlist) { // if key not exist in hashmap if(!map.containskey(product.getcategory()) { // add key map, add product new arraylist } else { // add product arraylist corresponds key } return map; } }

html - javascript for loop increment by > 1 problems -

i have loop works , i+1, i+2 onwards not work. error is: cannot read property 'logo_sm' of undefined here's code: var jsonobj = json.parse(http_request.responsetext); var rows = ''; for(var i=0;i<jsonobj.length;i=i+2){ rows += '<tr><td class="logo_sm">' + "<img src='"+jsonobj[i].logo_sm+"'/>" + '</td><td class="logo_sm">' + "<img src='"+jsonobj[i+1].logo_sm+"'/>" + '</td><td class="logo_sm">' + "<img src='"+jsonobj[**i+2**].logo_sm+"'/>" + '</td></tr>'; i++; } document.getelementsbytagname('table')[0].innerhtml += rows; in loop, if increment i++ , final column has i+1 instead of i+2 works. seems simple still in learning phase. so, struggling it. the way loop setup trying access array indexes items not exist. if ini

In VBscript, how do you set an array element to be a dynamic array? -

i want each element of array dynamic array can later individually resize redim. don't want use arraylist or use 2d array. possible, , how? redim masterarray(10) x = 1 10 redim subarray(10) masterarray(x) = subarray next masterarray(1)(2) = 5 masterarray(2)(2) = 6 msgbox masterarray(1)(2) ' shows 5 msgbox masterarray(2)(2) ' shows 6

python - Can I set low priority upload request using pycurl/curl to avoid using all upstream -

i'm building small python application upload bulk of files server using pycurl. bandwidth throttling possible using pycurl not solve problem. need app use 100% upstream when available , gracefully downscale when other application want use upstream. if priority can not set go logic app should consume 70% of total bandwidth. check these libcurl examples , usage , options names same in pycurl. (see examples right column).

playframework 1.x - Creating optgroup in play framework from a query result -

if example have following data retreived database: -------------------------- | id | name | department| -------------------------- | 1 | john | hr | -------------------------- | 2 | peter| accounting| -------------------------- | 3 | adam | secretary | -------------------------- how can create optgroup tag display result in optgroup have following: <select > <optgroup label='hr'> <option value='1'>john</option> </optgroup> <optgroup label='accounting'> <option value='2'>peter</option> </optgroup> <optgroup label='secretary'> <option value='3'>adam</option> </optgroup> </select> this may not best way, represent department model , way : user model : public class user extends model {

browser - Is Javascript only NAT punch through possible? -

i wanted know if possible implement javascript nat punch through app. should able run in browser. i looking solution allow p2p connections punch through. server there, making introduction between peers , exchanging ip addresses , ports. if possible udp (have read nat punch through easier in udp) or tcp connections possible? you can. packaged both stun server , client npm ( https://npmjs.org/package/stunsrv ). haven't documented client-side of things still there. aside there few other client packages available. edit: webrtc might interested in looking @ https://github.com/webrtc .

javascript - Concat objects? -

this question has answer here: concat json objects 8 answers how can merge properties of 2 javascript objects dynamically? 53 answers i have 2 objects same structure , want concat them using javascript. there easy way this? var num = { '0': 0, '1': 0, '2': 0, '3': 0 }; var let = { 'a':'1', 'b':'2', 'c':'3' } you can use jquery's .extend() : $.extend(num,let); // num merged object. note: every duplicate index have value had in let

php - One line of my script using all available memory - why? -

i have php project i'm making, i've hit dead end 1 line causing script error out saying memory limit has been exausted. the line in question part of method, follows: public function query_all($query) { if (function_exists('mysqli_fetch_all')) # compatibility layer php < 5.3 $res = mysqli_fetch_all($this->query($query)); else ($res = array(); $tmp = mysqli_fetch_array($this->query($query));) $res[] = $tmp; return $res; } this function part of class named db, line error line loop: for ($res = array(); $tmp = mysqli_fetch_array($this->query($query));) $res[] = $tmp; this function called once in code, @ top of else statement: do { $id = rand(1000000, 9999999); if (!util::in_array_r($id, $db->query_all('select * tickets'))) { break; } } while (true); $emailsubject = $db->escape($emailsubject); $emailbody = $db->escape($emailbody); $from

ios - Mysterious memory management issue in Core Graphics -

here method use in category on uiimage resize it. works seems in method (i not 100% sure it's in there) amassing memory. not expert , quite difficult me trace down cgcontext function using instruments.app http://bytolution.com/instruments_scrnsht.png - (uiimage *)cropwithsquareratioandresolution:(cgfloat)resolution { uiimage *sourceimg = (uiimage*)self; cgsize size = [sourceimg size]; int padding = 0; int picturesize; int startcroppingposition; if (size.height > size.width) { picturesize = size.width - (2.0 * padding); startcroppingposition = (size.height - picturesize) / 2.0; } else { picturesize = size.height - (2.0 * padding); startcroppingposition = (size.width - picturesize) / 2.0; } if (resolution == 0) resolution = sourceimg.size.width; cgrect croprect = cgrectmake(startcroppingposition, padding, picturesize, picturesize); cgrect newrect = cgrectintegral(cgrectmake(0, 0,resolution, r

asp.net mvc - FormBuilder in ASP .NET MVC 4 -

i've got simple question. in symfony 2 able use formbuilder create forms, see link more info http://symfony.com/doc/current/book/forms.html . does asp .net mvc 4 has this? this example of using forms in asp .net mvc 4 : @using (html.beginform()) { @html.actionlink("back list", "index") } here basic tutorial on how use forms , mvc : http://www.codeproject.com/articles/207797/learn-mvc-model-view-controller-step-by-step-in-7#step2:-%20creating%20the%20input%20html%20form%20using%20helper%20classes

ios - UISearchBar CGContext ERROR -

i have uisearchbar inside view, whenever tap on it, after keyboard comes - after -(bool)searchbarshouldbeginediting:(uisearchbar *)searchbar it sends console: <error>: cgcontextsetstrokecolorwithcolor : invalid context 0x0 . serious error. application, or library uses, using invalid context , thereby contributing overall degradation of system stability , reliability. notice courtesy: please fix problem. become fatal error in upcoming update. it repeats same error. wonderring problem? i believe there null context out there has uisearchbar? tnx. it´s known issue on apple working on. should fixed in next beta release. have here: xcode number pad decimal error edit: have issue textfield maybe should around: from apple developer forums bye popeye7 - credits him i have found fix issue! have 3 apps broken on, so, me... find. found solution on stackoverflow... combined 2 answers similar question. in case, user taps barbuttonitem , &

java - Threads and UserInterface interaction -

i'm trying make app lets user log location web server, i'm stuck in flow of this. i'm using threads confusing @ point how best use them this. on main thread(1) there ui , user hits button log location, after hitting button, ui thread shows "please wait" dialog box , starts new thread(2) acquire gps location. understand right now: ui thread stuck showing dialog box , thread(2) getting location. next when thread(2) done geting location, need thread(3) communicate http server. understand it, main thread(1) can't deal "sleep()" periodically check on flags other threads set it. way dismiss "please wait" dialog 1 of threads. guys can see i'm little confused. best way address (strictly talking thread synchronization)? need user interface shows please wait dialog while in background app 1st getting gps coordinates , 2nd, after getting location logging on web server. , showing success or not user. thanks! you can use asynctask @vik

speech recognition - RaspberryPi + Pocketsphinx + ps3eye Error: Failed to open audio device -

just installed pocketsphinx on raspberry pi. think i'm going crazy not sure if i'm providing correct device. whenever run: src/programs/pocketsphinx_continuous -adcdev plughw:1,0 -nfft 2048 -samprate 48000 i following: root@scarlettpi:/usr/install/pocketsphinx-0.8# src/programs/pocketsphinx_continuous -adcdev plughw:1,0 -nfft 2048 -samprate 48000 info: cmd_ln.c(691): parsing command line: /usr/install/pocketsphinx-0.8/src/programs/.libs/lt-pocketsphinx_continuous \ -adcdev plughw:1,0 \ -nfft 2048 \ -samprate 48000 current configuration: [name] [deflt] [value] -adcdev plughw:1,0 -agc none none -agcthresh 2.0 2.000000e+00 -alpha 0.97 9.700000e-01 -argfile -ascale 20.0 2.000000e+01 -aw 1 1 -backtrace no no -beam 1e-48 1.000000e-48 -bestpath yes yes -bestpathlw 9.5 9.500000e+00 -bghist no no -ce

Python: Why this tuple is printing the result and "None"? Also: Is there a better way to achieve the result? -

i need calculate given number, how many "fives", "twos", , "ones" can numbers. sorry english little limited sort of explanation :) maybe example better: excercise: print stamps(8) result should be: (1, 1, 1) ( 1 5p stamp, 1 2p stamp , 1 1p stamp) i´ve found way achieve that, tuple() printing result , "none", , don´t know why. know there´s better, shorter way correct result. this i´ve done: def stamps(dinero): p5=dinero/5 p5a=p5*5 resultado1=dinero-p5a dinero=resultado1 p2=dinero/2 p2a=p2*2 resultado2=dinero-p2a dinero=resultado2 p1=dinero/1 p1a=p1*1 resultado3=dinero-p1a dinero=resultado3 print tuple([p5,p2,p1]) the result with: print stamps(8) (1, 1, 1) none update: i´ve found better solution , i´m posting here in case wonders better solution: def stamps(n): #basically, thats same return n/5, n%5/2, n%5%2 return n/5, (n-5*(n/5))/2, (n-5*(n/5))-2*((n-5*(n/5))/2)

java - The markup in the document following the root element must be well -

i have try compalie android code keep getting error markup in document following root element must well <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/relativelayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/main_bg" android:orientation="vertical" > <imageview android:id="@+id/imageview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" android:layout_margintop="20dp" android:src="@drawable/main_title" /> <textview android:id="@+id/wwwtext" android:layout_width="wrap_content" android:layout_height="wrap_

c - socket control to accept multiple UDP connections -

i'm breaking mind trying understand how make client/server write myself accept multiple socket connections. the connection datagram (udp), implemented based on getaddrinfo(3) man page works nice, each client needs wait process of connections processed. i've heard select, in man page says: select() can used solve many problems in portable , efficient way naive programmers try solve in more complicated manner using threads, forking, ipcs, signals, memory sharing, , on. and more: the linux-specific epoll(7) api provides interface more efficient select(2) , poll(2) when monitoring large numbers of file descriptors. so, is? epoll better select? or depends? if depends, on what? epoll man pages has partial sample, i'm trying understand it. at now, (on server) think, need thread listen in thread , write in another. how control completion of partial message? if 2 clients send partial message i

How to add views to a controller in a ruby on rails application manually(not through controller wizard)? -

i using ruby mine building ruby on rails application. working fine. create new project , press ctrl+alt+g. generator option choose controller. window in have name controller , actions. when select different actions, corresponding functions created in controller named after actions. if press icon left of functions name view file opened particular function having extension.html.erb.this fine. if forget add 1 or more action in controller dialog box. supposedly have add function name view want. i.e. def functionname end now when click on left of functionname. option create file of extension .html.erb. of working fine. when build application , try access newly created view following error` routing error no route matches [get] "/say_hello/sona" try running rake routes more information on available routes. how can add views controller except using controller wizard??can't add view afterwards?? ` i don't know wizard access url in application need:

html - Dynamically created checkboxes using ajax from sql result set -

i looking use ajax dynamically create checkboxes each time change selection <select> tag, see below screenshot section of form relevant: snippet http://i39.tinypic.com/2ik5xg8.png note: checkboxes under " queues " should dynamic. at moment, when change value team grabs team name (in case "test"), using ajax (post) returns manager name team. what want table has list of "queues" associated each team; going add "onchange" attribute in tags " manager name " field. below code i'm using accomplish team => manager name dynamic filling: <script> window.onload = function() { getmanager($("#team").val()); } function getmanager(team) { $.ajax({ type: "post", url: "getmanager.php", data: {team:team} }).done(function( manager ) { $("#manager_nam

Replace a word using javascript -

i want replace word between 2 "bla bla" mean have sentence - he "bad boy". want replace "bad boy" good boy out "" how dynamically using java script live example helpful. code have tried var str='he "bad boy".'; var n=str.match(""); var str='he "bad boy" , "bad boy".'; var n=str.replace(/\".*?\"/gi, 'good boy'); //g: globally, i: case-insensitive console.log(n) edit: /\".*\"/ without ? match chars in quotes including ending code, match entire bad boy" , "bad boy since in quotes. trick use ? make match less greedy.

android - Orientation Issue in Andengine Live Wallpaper -

i have live wallpaper in market runs potrait mode, in landscape.. looks stretched , bad. have developed wallpaper in andengine. looked through web figure out need implement onconfigurationchanged() method take care of orientation changes. used solution proposed here :- http://www.andengine.org/forums/live-wallpaper-extension/orentation-problem-landscape-portrait-t10669.html following onconfigurationchanged() method @override public void onconfigurationchanged(configuration newconfig) { if (mode == 0) { if (newconfig.orientation == configuration.orientation_portrait) { mmainscene.setscale(1); mmainscene.setposition(0, 0); } else if (newconfig.orientation == configuration.orientation_landscape) { mmainscene.setscaley(1.5f); mmainscene.setscalex(0.5f); mmainscene.setposition(260, -500); } } else if (mode == 1) { if (newconfig.orientation == configuration.orientation_portrait) {

jquery - Find the last visible textbox index number -

i want find last visible textbox index number jquery, have tried code below giving wrong index number : var lastindex = $('input[type=text]').filter(':visible:last').index(); your problem caused fact index() looking @ siblings. you're selector working fine, see http://jsfiddle.net/2ueea/ . try following: $('input[type=text]').filter(':visible:last').index('input[type=text]'); you'll index of input in relation other inputs on page. if that's not want receive, tell us.

codeigniter 2 - How to do checking before importing the csv file by php? -

how checking before importing csv file in php? i have csv file contains information columns id, name, telephone, email , have database same columns. have php file can import csv file database. now, want update information batch, how can match id, name between csv file , database avoid wrong data input (suppose data in database correct in csv wrong). at end, php can show message csv data incorrect! thanks! can help? you can follows: read csv using fread() , filesize() explode() data, using linebreak ( \n ) loop through each line of data foreach explode each line, using comma ( , ) test each index of array preg_match() , regex pattern make sure meets requirements query database (in php, untested) $query = "update yourtable set name='".$name."' id='".$id."'"; make sure query santized using pdo or similar, avoid sql injection @ times. that last bullet point key question, think. you'll need read updat

javascript - Split integer into parts using RegExp -

i have input field , user may type time in different format(800,08:00,08:00 etc).i need display ever user input time format(xx:xx am/pm). example: 1.'800'=>'08:00'; 2.'1245'=>'12:45'; 3.'1000 am'=>'10:00 am'; 4.'10.00 am'=>'10:00 am'; 5.'9 am'=>'09:00 am'; so type in "800" , convert "8:00" or type in "2145" , convert "21:45". i have tried str.split(/[:;,. \/]/); ,but applicable in case of example 4. you can use regex parse string components: var myregexp = /^(\d{1,2}?)\d?(\d{2})?\b\s*([ap]m)?$/; var match = myregexp.exec(subject); if (match != null) { hours = match[1]; minutes = match[2]; ampm = match[3]; } explanation: ^ # start of string ( # capture group 1: \d{1,2}? # 1 or 2 digits, preferably 1 ) # end of group 1 \d? # match optional non-digit ( # capture group 2: \d{2}

awk - count and print the number of occurences -

i have files shown below gll alm 654-656 654 656 sem lyg 655-657 655 657 sem lyg 655-657 655 657 alm leg 656-658 656 658 alm leg 656-658 656 658 alm leg 656-658 656 658 leg leg 658-660 658 660 leg leg 658-660 658 660 the value of gll 654. value of alm 656. in same way, 4th column represents values of first column. 5th column represents values of second column.i count unique occurrences of each number in fourth , fifth column. desired output 654 gll 1 655 sem 1 656 alm 2 657 lyg 1 658 leg 2 660 leg 1 if understand question right, script give output: awk '{d[$4]=$1;d[$5]=$2;p[$4];l[$5]} end{ for(k in p){ if (k in l){ delete l[k] print k,d[k],"2" }else print k,d[k],"1" } (k in l) print k, d[k],1 } ' file with input data, output of above script: 654 gll 1 655 sem 1 656 alm 2 658 leg 2 657 lyg 1 660 leg 1 so not 100% same expect

android - This Handler class should be static or are there leaks?? Whats' happening? -

i newbie android programmer , found out handle issue program, when try run below program forcefully closed. why happening ?? how solve problem ?? thank you public class antivirus extends activity { protected static final int stop = 100; private imageview iv; private progressbar pb; private linearlayout ll; private animationdrawable anim; private scrollview sv; private sqlitedatabase db; private boolean flagscanning = false; private handler handler = new handler() { @override public void handlemessage(message msg) { super.handlemessage(msg); if(msg.what==stop){ ll.removeallviews(); anim.stop(); } string str = (string) msg.obj; textview tv = new textview(getapplicationcontext()); tv.settext(str); ll.setorientation(linearlayout.vertical); ll.addview(tv); sv.scrollby(0, 20);

objective c - How can I manually change the orientation -

my app should start landscape mode. change orientation of phone. how manually.i tried doesn't work. shouldautorotatetointerfaceorientation: is there other way?? in project settings, can set orientations app permits. set landscapeleft , landscaperight. prevent app going potrait mode, irrespective of orientation of device before app started. manually force change orientation in ios, cannot directly set device orientation manually. however, can use method work done. [[uiapplication sharedapplication] setstatusbarorientation:uiinterfaceorientationlandscapeleft animated:no]; the usual way alternatively, can goto implementation file can specify allowed orientations in method: - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { //return yes if want allow orientations return uiinterfaceorientationlandscaperight; //if want allow landscape right &c }

c# - Why do we not need to return a value outside of the `using` scope? -

consider code: public int downloadsoundfile() { using (var x= new x()) { return x.value; } } and code: public int downloadsoundfile() { if (x!=null) { return x.value; } } the first code doesn't give compile time errors in second code error: not code paths return value this means should return value outside of if scope. why have return value outside of if scope don't need return value outside of using scope? why should return value out of if scope don't need return value out of using scope? because if scope might not execute (if condition not satisfied) whereas body of using scope guaranteed execute (it either return result or throw exception acceptable compiler). if scope method undefined if condition not satisfied , compiler refuses that. so should decide value return if condition wrote not satisfied: public int downloadsoundfile() { if (x != null) { return x.value; }

jQuery - delay and fadeout before remove -

i trying .delay() , .fadeout() .remove() but delay , fadeout has no effect in remove here code: jquery("#container").delegate(".remove", "click", function (e) { e.preventdefault(); var parent = jquery(this).data('parent'); jquery(this).closest('.' + parent).fadeout(1000).delay(1000).remove(); }) why not jquery(this).closest('.' + parent).fadeout(1000, function(){ $(this).remove() }); you should make use of complete callback provided .fadeout() in case jquery("#container").on("click", ".remove", function (e) { e.preventdefault(); var $this = jquery(this), parent = $this.data('parent'); $this.closest('.' + parent).fadeout(1000).delay(1000).remove(); })

java - "ConnectionPoolTimeoutException" when iterating objects in S3 -

i've been working time aws java api not many problems. i'm using library 1.5.2 version. when i'm iterating objects inside folder following code: amazons3 s3 = new amazons3client(new propertiescredentials(myclass.class.getresourceasstream("awscredentials.properties"))); string s3key = "folder1/folder2"; string bucketname = constantes.s3_bucket; string key = s3key +"/input_chopped/"; objectlisting current = s3.listobjects(new listobjectsrequest() .withbucketname(bucketname) .withprefix(key)); boolean siguiente = true; while (siguiente) { siguiente &= current.istruncated(); contador += current.getobjectsummaries().size(); (s3objectsummary objectsummary : current.getobjectsummaries()) { s3object object = s3.getobject(new getobjectrequest(bucketname, objectsummary.getkey())); system.out.println(object.getkey()); } current=s3.listnextbatchofobjects(current); } g

PHPExcel Repeat Columns at Left -

Image
i want repeat columns @ left excel report. used phpexcel, , function $objphpexcel->getactivesheet()->getpagesetup()->getcolumnstorepeatatleft(); the problem don't know how , should put parameters. want repeat column , b every page. :) $objphpexcel->getactivesheet()->getpagesetup()->setcolumnstorepeatatleftbystartandend('a', 'b'); this should work.

qml - Saving the text to label from textfield blackberry -

i want display entered text label. here's code qml: container { horizontalalignment: horizontalalignment.center verticalalignment: verticalalignment.top toppadding: 100 leftpadding: 50 rightpadding: leftpadding /*textarea { id: tacomment preferredheight: 270 editable: quotebubble.editmode enabled: enablesave input.flags: textinputflag.spellcheckoff }*/ label { verticalalignment: verticalalignment.top horizontalalignment: horizontalalignment.center text: cppobj.desc } } container {