Posts

Showing posts from 2012

memory management - How to serve a page fault in the linux kernel? -

i working on project requires heavy modifications in linux kernel. in 1 of modifications have change way page fault handler works. to intercept page faults specific processes , satisfy them possible getting copying data machine. as first step, write experimentation code can me understand how linux satisfies page fault , how tells process page fault can not served right , needs retry @ later time. so, modify handle_mm_fault in way helps me understand above. this: int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, unsigned int flags) { /* code */ if(current->pid == my_target_pid) { /* 1. chose randomly between 1 , 2 -> rand_num 2. if rand_num (1) 1 allocate block of memory, write 'x's , give process , return. 3. if rand_num (1) 2 tell process come later , return. */ } /* rest of handle_mm_fault other process here */ } yo

applescript - How does one keep Alfred 2 from opening and entering your Terminal command in a new window when Terminal is already open? -

what changes make make opens window if terminal isn't running otherwise, enters command in open window? i'm thinking control flow, conditional jawn. i'm not sure how write out though. thanks, tj the script follows: on alfred_script(q) tell application "terminal" activate script q end tell end alfred_script try: on alfred_script(q) tell application "terminal" if not (exists window 1) reopen activate script q in window 1 end tell end alfred_script

ios - Linker failed with error code 1 -

i keep getting error linker command failed exit code 1 , seems because of .h-file . in stringsde.h define constant strings. might problem? duplicate symbol _questioncatbuttonmixed in: /users/philip_air/library/developer/xcode/deriveddata/juraquiz-awgytksreajdjbdmoctjoffmzmmk/build/intermediates/juraquiz.build/debug-iphoneos/juraquiz.build/objects-normal/armv7/applaunch.o /users/philip_air/library/developer/xcode/deriveddata/juraquiz-awgytksreajdjbdmoctjoffmzmmk/build/intermediates/juraquiz.build/debug-iphoneos/juraquiz.build/objects-normal/armv7/quizvc.o ld: 17 duplicate symbols architecture armv7 clang: error: linker command failed exit code 1 (use -v see invocation) code: http://pastebin.com/igtvab6k declare of strings in .h file using: // questioncat buttons extern nsstring const *questioncatbutton1; extern nsstring const *questioncatbutton2; extern nsstring const *questioncatbutton3; extern nsstring const *questioncatbuttonmixed; and def

variables - Time complexity of this testing algorithm? -

what worst case scenario , how improve while statement? main() { clock_t tic = clock(); int n, i, j; int *p; scanf("%d",&n); p=&n; printf("1 \n"); getchar(); for(i=2; i-*p; i++) { j=2; while(j<(int)sqrt((double)i)+1) if(i % j) j++; else j=(int)sqrt((double)i)+3; if(j!=(int)sqrt((double)i)+3) printf("%d \n",i); } clock_t toc = clock(); printf("elapsed: %f seconds\n", (double)(toc - tic) / clocks_per_sec); getchar(); }

ocaml - Error: Camlp4: Uncaught exception: Not_found -

i working on ocsigen example ( http://ocsigen.org/tuto/manual/macaque ). i error when trying compile program, follows. file "testdb.ml", line 15, characters 14-81 (end @ line 18, character 4): while finding quotation "table" in position of "expr": available quotation expanders are: svglist (in position of expr) svg (in position of expr) html5list (in position of expr) html5 (in position of expr) xhtmllist (in position of expr) xhtml (in position of expr) camlp4: uncaught exception: not_found my code is: module lwt_thread = struct include lwt include lwt_chan end module lwt_pgocaml = pgocaml_generic.make(lwt_thread) module lwt_query = query.make_with_db(lwt_thread)(lwt_pgocaml) let get_db : unit -> unit lwt_pgocaml.t lwt.t = let db_handler = ref none in fun () -> match !db_handler | h -> lwt.return h | none -> lwt_pgocaml.connect ~database:"testbase" () let table = <:table< users ( login t

indexing - Clarification on sorting subsets in mongodb -

i have documents fields a, b, c, d, e, p in mongodb. have indexes { a: 1 } , { b: 1 }, { c: 1 }, { d: 1 }, { e: 1 }, { p: 1 } , compound indexes { a: 1, b: 1, c: 1 } . field p represents position of fields. if have select this: { a: 'something', b: 'something else', c: 'and again' } , know use index { a: 1, b: 1, c: 1 } search (obviously). however, if want sort p ( { p: 1 } ), indexes used sort data? worried because can potentially have large dataset. i read http://docs.mongodb.org/manual/tutorial/sort-results-with-indexes/ , cannot quite figure out use case (although it's there) probably best said "can mongodb use 1 index match , 1 sort?" , answer no. the thing "looking" in explain output see if index used sort value scanandorder show true when index cannot used , false can. considering adapted sample, compound index on "a", "b", , "c" , separate index on "p", que

asp.net - Google Chrome: Stylesheet only appears after "Inspect Element" -

i'm experiencing weird stylesheet problem (only happens in chrome) text showing after used inspect element function of chrome. (id post images of error seems not have enough reputation points since new here) i've been searching around quite time , still no luck. it turns out it's issue chrome-based browsers , custom fonts. see google fonts not rendering on google chrome discussion , answers. i found https://stackoverflow.com/a/22637615/949055 work in initial testing.

javascript - Have a delete button, must be hit twice to update page in IE -

so have "delete record button" in other browser functioning correctly. deletes record sql, , updates page. thought ie not updating page js event, , deleting record view. if hit once, doesn't update page, twice does. hit once, , refresh page manually gone view properly. ever heard of ie doing this? nothing in debugger telling me of error. delete event below, if mishandled. ie need special filter handle events this? thanks! // button in question creation function create_delete_button( oobj ) { return '<input type="button" value="delete" onclick="deleteitem(' + oobj.adata[0] + ')"/>';} // post db deletion function deleteitem( id ) { $.post( "/data/deleteitem?id=" + id, getupdateditems() );} the code you've shown not update page in way in browser - doesn't include dom manipulation or navigation @ all. whole point of ajax (and assume $.post() jquery ajax method) makes request without refresh

Create an array of arrays from a list in Perl -

i want create array of arrays list of objects. how reset array variable (@row , reuse hold items in next sections)? know @row declared once, when pushed array, emptying empty @arrays too. how can reset @row while not empty @arrays? use data::dumper; # sample data, long list complex data types @list = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20); @arrays; @row; $numsub = 10; foreach $itm (@$list) { if (scalar(@row) == $numsub) { push @arrays, \@row; @row = (); # clear array, cleared array of arrays push @row, $itm; } else { push @row, $itm; } } # push last reminder push @arrays, \@row; dumper @arrays; # nothing put my @row inside of foreach loop instead of outside. distinct variable every time through loop. incidentally, there nicer ways write this, example: my @copy = @list; while (@copy) { push @arrays, [ splice @copy, 0, $numsub

celery - Setting up a load balancer for HA rabbitmq -

i trying set high availability rabbitmq cluster mirrored queues. actually, have set , easy part. comes part producers , consumers need access cluster, or specifically, master node, whichever might @ time. trying set haproxy have questions pertaining how work. specifically, haproxy not being used here balancer health checks. suppose original master goes down , oldest surviving slave promoted new master? how can haproxy set detect , route connections new master? you can configure haproxy this. check out this complete guide rabbitmq. if want achieve real load balancing rabbitmq in ha-configuration, this might interest you.

javascript - Implementing waitFor functionality with phantomjs-node -

i have tried , tested - success - phantomjs example waitfor . however, having difficulty implementing via phantomjs-node module because page.evaluate gets evaluated in callback. phantomjs implementation page.open("http://twitter.com/#!/sencha", function () { waitfor(function() { // here easy evaluate method returns return page.evaluate(function() { return $("#signin-dropdown").is(":visible"); }); }, function() { console.log("the sign-in dialog should visible now."); phantom.exit(); }); } }); however, phantomjs-node evaluate function gets returned data in callback: page.evaluate( function(){ /* return thing */ }, function callback(thing) { /* write code thing */ } ) using phantomjs-node , how can run function on page after element visible? just in case link above dead, here implementation of waitfor function /** * wait until test condition true or time

ios - Get indexPath of Core Data object in UITableView -

i have uitableview i'm populating core data following nsfetchedresultscontroller: - (nsfetchedresultscontroller *)fetchedresultscontroller { if (_fetchedresultscontroller != nil) { return _fetchedresultscontroller; } nsfetchrequest *fetchrequest = [[nsfetchrequest alloc] init]; nsentitydescription *entity = [nsentitydescription entityforname:@"event" inmanagedobjectcontext:_managedobjectcontext]; [fetchrequest setentity:entity]; nssortdescriptor *sort = [[nssortdescriptor alloc] initwithkey:@"date" ascending:yes]; [fetchrequest setsortdescriptors:[nsarray arraywithobject:sort]]; [fetchrequest setfetchbatchsize:20]; nsfetchedresultscontroller *thefetchedresultscontroller = [[nsfetchedresultscontroller alloc] initwithfetchrequest:fetchrequest managedobjectcontext:_managedobjectcontext sectionnamekeypath:nil cachename:@"root"]; self.fetchedresultscontroller = thefetchedresultscontroller; _fetch

controls repeating in ruby on rails -

on signup page make communication preferences each user, means how other person contact person e.g: "phone","email","skype" , on settings page getting communication in text_field. if user have 3 communication i.e "phone","email","skype". show me below: phone: [1234567895] email: [abc@ab.com] skype: [abc ] assume square brackets "[ ]" text_field show me below: phone: [1234567895] email: [ ] skype: [ ] phone: [ ] email: [abc@ab.com] skype: [ ] phone: [ ] email: [ ] skype: [abc ] and below new .html.erb of setings page: <table> <% if @user_communication.blank? %> <tr style="text-align: left; vertical-align: middle;"> <td style="font-size: large; color: #212121;"> phone: </td> <td style="font-size: larg

r - Creating a sequence bases on value of previous element -

i'm trying 20 sequences of length 1000, each generated randomly adding 1 or 0 previous element in sequence. i tried this: h <- replicate(20, rep(0, 1000), simplify=false) lapply(h, function(v) for(i in 2:1000){ v[i] = v[i - 1] + 1 }) but loop in lapply doesn't appear anything, , i'm left list of 20 lists of 1000 0s. what working way this? if there's way without loop, better :) thanks set.seed(100) x <- replicate(20, cumsum(sample(0:1, 1000, replace = true)), simplify = false) str(x) # list of 20 # $ : int [1:1000] 0 0 1 1 1 1 2 2 3 3 ... # $ : int [1:1000] 0 0 1 2 2 2 2 2 3 4 ... # $ : int [1:1000] 1 2 3 3 4 5 6 6 7 7 ... # $ : int [1:1000] 0 0 1 1 2 2 3 4 4 5 ... # $ : int [1:1000] 1 1 1 2 2 2 2 3 3 3 ... # $ : int [1:1000] 1 2 2 3 4 5 6 7 7 7 ... # $ : int [1:1000] 0 0 0 1 2 3 3 4 5 6 ... # $ : int [1:1000] 1 1 1 2 3 3 4 4 4 5 ... # $ : int [1:1000] 1 1 1 1 1 1 1 1 1 2 ... # $ : int [1:1000] 1 1 2 3 3 3 3 3 3 3 ... # $ : int [1:

Empty CSV in web scrapping - Python -

i try create csv tables appear in each link. this link in link there 36 links, 36 csv should generated. when run code, 36 csv created empty. code below: import csv import urllib2 bs4 import beautifulsoup first=urllib2.urlopen("http://www.admision.unmsm.edu.pe/admisionsabado/a.html").read() soup=beautifulsoup(first) w=[] q in soup.find_all('tr'): link in q.find_all('a'): w.append(link["href"]) l=[] t in w: l.append(t.replace(".","",1)) def record (part) : url="http://www.admision.unmsm.edu.pe/admisionsabado".format(part) u=urllib2.urlopen(url) try: html=u.read() finally: u.close() soup=beautifulsoup(html) c=[] n in soup.find_all('center'): b in n.find_all('a')[2:]: c.append(b.text) t=(len(c))/2 part=part[:-6] name=part.replace("/&q

c++ - Qt : Setting a border bottom on QtableView disables selection-background-color -

i have in qtableview stylesheet qtableview::item { selection-background-color: rgb(85, 85, 127); border-bottom: 1px double #8f8f91; } now problem selection-background-color: rgb(85, 85, 127); takes effct if border-bottom: 1px double #8f8f91; disabled. suggestions ?? you should specify border attribute if want suck customization. is't specific of qss: border: 0px solid transparent; // or other border

c# - StackedColumn chart is flying -

Image
i trying implement stackedcolumn type chart in project, find understand how assign different series . this demo purpose code: for (int = 1; <= 3; i++) { (int = 0; < 5; a++) { string item = "boo" + i.tostring() + a.tostring(); chart1.series.add(item); chart1.series[item].charttype = seriescharttype.stackedcolumn; chart1.series[item].points.addxy(i, 100.0); } } however, produces flying 3 stacked columns instead of 3 equal stacked columns: however, if remove seriescharttype.stackedcolumn (and use default) works fine , go ground. how should make them go bottom using stackedcolumn ? you creating chart 15 series, each series has 1 data point. trying achieve? example if wanted have 3 series, each 5 data points should this: for (int = 1; <= 3; i++) { // add series chart string item = "boo" + i.tostring(); chart1.series.add(item); chart1.series[item].charttype = seriescharttype.s

c# - What lines have not been read? Streamreader -

i'm developing file reader complex format. there literally hundreds of different entries. in way i'm doing need use 2 streamreaders because need extract information before. these files big enough not read them @ once. what want notify user lines have not been read. structure this: streamreader file1 = new streamreader(path); while((line=file1.readline()) != null) { if(line.startswith("hello") { //... } //... more conditions } streamreader file2 = new streamreader(path); while((line=file2.readline()) != null) { if(line.startswith("good morning") { //... } //...more conditions } so if reader perfect @ end lines read. things can bizarre entries can not yet implemented, , want catch lines. problem here, see, having two streamreaders . my options are: store in array not read lines , use second reading, subtracting line line after reading it. not because storing several thousand of lines there. add conditions in second streamreader

javascript - How to dynamically change the 'repeat' property of Polyline in Google maps v3? -

this code drawing line on map in google maps v3: var line = new google.maps.polyline({ path: linecoordinates, strokeopacity: 0, icons: [{ icon: linesymbol, offset: '0', repeat: '20px' }], map: map }); the repeat property can draw dashed line. want change property dynamically. this: setrepeat('20px'); you must re-assign icons-property of line, e.g.: line.set('icons',[{icon:line.icons[0].icon, offset:line.icons[0].offset, repeat:'50px'}]);

c - Client server implementation -

after research found code server side. #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> int main(void) { int listenfd = 0,connfd = 0; struct sockaddr_in serv_addr; char sendbuff[1025]; int numrv; listenfd = socket(af_inet, sock_stream, 0); printf("socket retrieve success\n"); memset(&serv_addr, '0', sizeof(serv_addr)); memset(sendbuff, '0', sizeof(sendbuff)); serv_addr.sin_family = af_inet; serv_addr.sin_addr.s_addr = htonl(inaddr_any); serv_addr.sin_port = htons(5000); bind(listenfd, (struct sockaddr*)&serv_addr,sizeof(serv_addr)); if(listen(listenfd, 10) == -1){ printf("failed listen\n"); return -1; } while(1) { connfd = accept(listenfd, (struct sockaddr*)null ,null)

javascript - How do I load a H1 tag first -

i took @ page speeds can see at, http://www.webpagetest.org/result/140310_a0_4q3/1/details there seems delay loading <h1> tag extending page time. there way force <h1> tag load earlier? thanks in advance help. michael. the problem background image , logo image(in h1 tag). try optimize them in image editor, , save them web. also should save them .jpeg , not transparent images, save more file size. later edit: if want transparent logo image, save jpeg web, use css opacity .

Android: change button background/text/compoundDrawables with selector XML -

i have been using selector drawables make button change background according state. however, want change text color , left compound drawable background. default selector xml atrribute not contain "android:textcolor" or "android:drawableleft" assigned. i know can achieve extend own button class, there clean way out? i not sure drawables changing textcolor depending upon button state, use selectors below, <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="true" android:color="@color/color_light_green"></item> <item android:color="#fff"></item> //state want </selector> and apply textcolor attribute in xml as, android:textcolor="@drawable/selector_btn_text_color" eclipse doesn't auto suggest color attribute in selector can it. :)

git - GitLab showing modified folders instead of files -

we using git source control using gitlab. problem is, created new branch no uncommitted files in repository created branch , showing modified folder , not files follows, # on branch 114531 # changes not staged commit: # (use "git add <file>..." update committed) # (use "git checkout -- <file>..." discard changes in working directory) # (commit or discard untracked or modified content in submodules) # # modified: lib/library/cl (new commits) # modified: lib/library/fw (new commits) # modified: plugins/cpp (new commits, modified content) # modified: plugins/crbp (new commits) # modified: plugins/cup (new commits) # modified: plugins/slp (new commits) # modified: plugins/sip (new commits) # no changes added commit (use "git add" and/or "git commit -a") what wrong? why i'm not seeing files , seeing folders? , how make show modified files instead of folder? please friends. why i'

asp.net mvc - How to retain data (form) on custom pagination using MVC? -

i have grid (list generated using scaffolding option) search criteria. , created paging concept. entered search criteria data , search, after post back, retained form data using tempdata. but, if click page numbers in grid, form data not retained , grid getting refreshed. is there way retain data on pagination? thanks! i added hidden field dynamically within form using javascript. page number stored in hidden field, when user click page number, submit form. working without issue. paging: <button onclick="navigateto(this, '@url.routeurl("defined_route", new { currentpage = j })');">@j</button> javascript: $(function () { //page load - create hidden field, if search button found if ($("#search")) // button id { var element = document.createelement("input"); element.type = "hidden"; element.id = "currentpage"; element.name = "currentpage&quo

css - How to make Bootstrap 'List group' responsive -

i using bootstrap ' list group ' , need make responsive. means in mobile view, list show drop down button navbar. i tried nav classes, not working expected. code: <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#side-menu-collapse"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <ul class="list-group collapse navbar-collapse" id="#side-menu-collapse"> <li class="list-group-item dropdown-toggle">cras justo odio</li> <li class="list-group-item dropdown-toggle">dapibus ac facilisis in</li> <li class="list-group-item dropdown-toggle">morbi leo risus</li> <li class="list-group-

How to exclude traffic in Google Analytics from Dynamic IP addresses? -

google's detection of unusual traffic nice. how handling dynamic ip addresses? for example,i not have ranges of ips , isp provides dynamic ip may change everytime router reboots , changes everyday. here, when ip address see notification w/o captcha. after several reboots seem ip not blocked! how solve type of issues in google analytics. know how exclude traffic single ip , ranges of ips not know how block internal traffic ips changes everyday? there problems many of popular answers question... even if you're lucky enough find ip range, if you're working coffee shop or hotel? checking host name eliminates hits dev environment, if i'm debugging live site? editing server configurations annoying/advanced , multiple domains become complicated. opt-out extensions either block hits on websites or none @ depending on ask. so, combined several other solutions works me... it follows me wherever go it works on dev environment , on live/public domains

How does PHP upgrade affect Magento site? I am experiencing problems when I update my phpMyAdmin -

could please explain how php upgrade affects magento site? i developing magento site locally on mamp. 9 months have been using same version of mamp uses php 5.4.4. have upgraded mamp newest version , using php 5.5.10. error message when try access site. have feeling because of php upgrade. please note rookie @ programming , know less php , databases. thanks take @ magento system requirements . php compatibility: 5.2.13 - 5.3.x, 5.4.x patch magento not support php 5.5, guess that's problem you.

Problems with Java UML Class using Mutators and Accessors -

i suppose make driver called black jack , class program called card. have not made driver class yet because professor asked class program card first. teacher has said use: teacher file of problem above file describing use. absolutely use no arrays or array list , have not learned yet , allowed use things have learned. have asked lot of people , use arrays , dont understand why cant use them. my code far... sorry tabs , spacings not right figure out later on. import java.util.scanner; public class card { private final int max = 13; private int face, suit, points, spades, clubs, diamonds, hearts, ace, jack, queen, king; prive int randomnumber = new newcard(); //constructors public card() { randomnumber = newcard() } public card(int facevalue,int suitvalue) { //face ace = 1; jack = 11; queen = 12; king = 13; //suit hearts = 1; diamonds = 2; clubs = 3; spades = 4; } //^^^^^^^ //mutat

sql - Add amounts from two different tables Oracle -

Image
i have 2 tables, interest table , charges table. interest table has debit interest , credit interest have been able difference using query: select e.sol_id, (sum(case when e.interest_ind = 'd' e.amount_in_lcy else 0 end)- sum(case when e.interest_ind = 'c' e.amount_in_lcy else 0 end)) difference tbaadm.interest_details e group e.sol_id; my output correct: i need add amount in charges table have attempted this: select e.sol_id, (sum(case when e.interest_ind = 'd' e.amount_in_lcy else 0 end)- sum(case when e.interest_ind = 'c' e.amount_in_lcy else 0 end) + sum(f.amount_in_lcy)) difference tbaadm.interest_details e,tbaadm.charge_details f f.sol_id = e.sol_id group e.sol_id, f.sol_id this query after hanging moment gives me output: which wrong considering while subtracting debits credit in first tables has entries branch 000,001 , 003, how can add amount second table , maintain result set if second table not have entries branch 000 , 0

show activity after notification Android -

i´m trying open activity after recieiving push notification. i recieive notification, when select nothing happens! the problem trace is: w/inputmethodmanagerservice(771): window focused, ignoring focus gain of: com.android.internal.view.iinputmethodclient$stub$proxy@438ae618 attribute=null, token = android.os.binderproxy@4319aab8 here code public class gcmintentservice extends intentservice { private static final int notif_alerta_id = 1; public gcmintentservice() { super("gcmintentservice"); } @override protected void onhandleintent(intent intent) { googlecloudmessaging gcm = googlecloudmessaging.getinstance(this); string messagetype = gcm.getmessagetype(intent); bundle extras = intent.getextras(); if (!extras.isempty()) { if (googlecloudmessaging.message_type_message.equals(messagetype)) { mostrarnotification(extras.getstring("message")); } } gcmbroadcastreceiver.completewakeful

Set a wait time for a statement in C# -

this question has answer here: how change timeout on .net webclient object 7 answers i using webclient in c#. returnvalue = webclient.uploadstring(url, message) it works fine if connection , other credentials fine. if mistake in either credentials or connection, waits webclient @ least 5 minutes respond. want set 30 seconds command executed , if dont response abort it. how do so? there way? is code looking for? webclient.timeout = 500; returnvalue = webclient.uploadstring(url, message);

php - Trouble Shuffling a MYSQL Result Set -

via database returning array by: print_r($stmt->fetchall(pdo::fetch_assoc)); as expected looks there. add php "shuffle" function so: print_r(shuffle($stmt->fetchall(pdo::fetch_assoc))); the result "1". no shuffled array. i wanting query result set , them output them in random order guarantee of no duplicates. in regards appreciated. thanks. shuffle() takes reference array , return boolean, should do: $result = $stmt->fetchall(pdo::fetch_assoc); shuffle($result); print_r($result);

java - Applying a list of values as predicate using Collection Utils by the use of pedicates -

i want implement database systems in functionality using predicate. this if sql filter recordset in cumbersome results. but if pass list in predicate takes 1 value i.e. if passing 53 , 54 filter results 53 only. public class classnamepredicate implements predicate<classname> { private object expected1; private string property; private list<object> listofvalues = new arraylist<object>(); public salesorderpredicate(object expected1, string property) { super(); this.expected1 = expected1; this.property = property; } public salesorderpredicate(list<object> listvalues, string property) { this.listofvalues = listvalues; this.property = property; } @override public boolean evaluate(salesorder object) { try { if (property.equals("volume")) { return ((integer) expected1 < object.getvolume()); } if (property.equals("startdateid")) { return (expected1.equals(object.g

windows phone 8 - LongListSelector with items of variable height & content -

i've used , familiar longlistselector having specific item template items listed. now try implement more complex longlistselector items added not of fixed height/specific content. couple of textblocks , images in 1 case , 2 times same elements in (it's set of elements appears 1,2 or 3 times per item). note: use observablecollection connect longlistselector. observablecollection<routeinformation> routes = new observablecollection<routeinformation>(); public routepage() { initializecomponent(); routeslonglistselector.itemssource = routes; } and populate list pulling data database , in end adding them with routes.add(new routeinformation(..., ...)); any suggestions? define multiple item templates in page's resources: <phone:phoneapplicationpage.resources> <datatemplate x:key="itemtemplate3line">... </phone:phoneapplicationpage.resources> <longlistselecto

delphi - How to define that node of TVirtualStringTree is presented on screen? -

it's easy check node visible. don't know how rightly define node presented on screen. can find out so: bottomnode := tree.bottomnode; node := tree.topnode; idbottomnode := tree.absoluteindex(bottomnode); while tree.absoluteindex(node) <> idbottomnode begin node := node.nextsibling; if not assigned(node) break; end; (code without checking) but think rather rough way. may there more accurate way? you may write function follows. tree parameter there specifies virtual tree, node node want check if it's visible, , column optional parameter index of column if need determine whether node , column visible in client rect: function isnodevisibleinclientrect(tree: tbasevirtualtree; node: pvirtualnode; column: tcolumnindex = nocolumn): boolean; begin result := tree.isvisible[node] , tree.getdisplayrect(node, column, false).intersectswith(tree.clientrect); end; but maybe there's more straightforward way...

Manipulating button via DOM, JavaScript -

i'm trying find index of clicked button, can manipulate other elements same index, don't know how! html: <body> <div id="area"> <h1>javascript</h1> <button class="knapp">click!</button> <p class="text">adöfkljg ldjfögj jsdflkgjh kjddflkgjh dfgkjdöjg </p> <button class="knapp">click!!</button> <p class="text">dfghödifgjöoeirugeöori dijfoidj oidoi odi!</p> </div> <script src="visa.js"></script> </body> javascript: var text = document.getelementsbyclassname("text"); var butt = document.getelementsbyclassname("knapp"); window.onload = start(); function start(){ (i=0; i<text.length; i++){ text[i].style.visibility = "hidden"; }; }; this.onclick = function(){ var index = butt.in

HTML5 Audio doesn't play until I physically rotate Nexus 7 -

i'm trying html5 audio sprites working on nexus 7 using android chrome browser. change audio being played, change source of audio player, reload audio player. i have detect 2 'timeupdate' events make sure audio playing, because html5 audio on android can bit unreliable . it's 1 part of large page can't post all, setup boils down basically: <body> <audio id="myaudioplayer" src="audio_1.wav"> <script type=javascript> function changeaudio() { var audioplayer = document.getelementbyid("myaudioplayer"); audioplayer.currentsrc = getnextaudioclip(); audioplayer.load(); audioplayer.play(); audioplayer.addeventlistener('timeupdate', firsttimeupdate, false); } function firsttimeupdate() { this.removeeventlistener('timeupdate', firsttimeupdate, false); this.addeventlistener('timeupdate', secondtimeupdate, false);

string - New line character in excel when printing from vb.net -

Image
i trying print value cell contains line seperator alt + enter or char(10) . far prints text prints values want wrap in excel in different cells in vb.net code keep building string loop through reports , have tried vbcrlf , vblf etc try , mimic alt + enter entry in excel using similar below _string = _string & vbcrlf & report.name &" " & _pctstatus &"%" and paste string a1 using clipboard.setdataobject(_string.tostring, false) arange.select() aworksheet.paste() in picture can see keep getting values in a3 want result in a1 i can around structuring text formula char(10) in cell formula prefer enter string value , have no formulae. have constrained number of free cells in excel report since adding excel sheet heavily populated already so special need use clipboard? if not try this: arange.value = _string.tostring

python - how to get the penultimate element? -

please using xpath content of second tag . below code wrote. not work import lxml.html doc = lxml.html.document_fromstring(""" <nav class="paging"> <a href="/women/dresses/cat/4?page=1" class="active">1</a> <a href="/women/dresses/cat/4?page=2">2</a> <a href="/women/dresses/cat/4?page=2" rel="next">next »</a> </nav> """) res = doc.xpath('//nav[@class="paging"][position() = 1]/a[position() = last() , @rel != "next"]/text()') print(res) you current expression not work because a[position() = last() , @rel != "next"] tries match last element if rel attribute different "next" . not case in markup, expression matches nothing. you can compare position() against last() - 1 instead: res = doc.xpath('//nav[@class = "paging" , posi

c# 4.0 - How to run a specific function daily at specific time in asp.net -

hy all, new here , first question stackoverflow.com. please ignore mistakes. want call open exchange api convert currency rates currencies . using api scenario api must called @ morning time 8:00 starting , called @ ending time 6:00 pm. please how call specific code or function @ 8:00 in morning , after delay again call api @ 6:00 pm. please me. if trying on remote server, perhaps " easy background tasks in asp.net " do. simulates windows service using httpruntime.cache , removes need external dependancies. otherwise running cron job equivalent in windows can acheived by: quartz.net

java - Writing image not working properly using BufferedOutputStream -

iam reading , writing image file in java.the file can of type used buffered reader , writer while writing image not written properly.the image scattered. bufferedreader bufferedreader = null; bufferedoutputstream bufferedwriter = null; if(!(dto.getinputstream() == null)){ try { bufferedreader = new bufferedreader(new inputstreamreader(dto.getinputstream())); fileoutputstream writer = new fileoutputstream(new file(webinflocation.getwebinfpath()+constantifc.resourcepath+dto.getfilename()+dto.getdocumentcode()+"_"+dto.getversion()+1+"."+dto.getformatname())); bufferedwriter = new bufferedoutputstream(writer); int value; while((value = bufferedreader.read()) != -1){ bufferedwriter.write(value); } } catch (ioexception e) { // todo auto-generated

javascript - Convert epoch time to date in titanium -

i have epoch times stored in database so: 1392821307. these picked on separate web service using php time() function. need convert date/month/year format in titanium. so far have used following code based off answer here in stack overflow var utcseconds = jobs_data.jobs[i].dateposted; var d = new date(0); // 0 there key, sets date epoch d.setutcseconds(utcseconds); this returns string so: wed feb 19 14:48:27 gmt 2014 i need feb 19 2014. i'm wondering how parse string. going use substring example, mon have 3 letters , thurs have 4, starting index of parse changing. not sure if month of varying length also d date object. if pass ti.api.info, or console.log, it'll coerced in string see above. should use getdate , getmonth , , getfullyear methods string want. var formattedstring = (d.getmonth()+1) + '/' + d.getdate() + '/' + d.getfullyear(); alternatively, use moment.js , included in alloy apps, , can downloaded in vanilla titanium apps

ios - Add Bubble view dynamically -

Image
hi guys, have achieve above design. here no of bubbles dynamic (maximum 8) , size of each bubble dynamic. have designed bubbles dynamically can't find out way add bubbles (i mean in position, bubble) output looks above. bubble formed randomly each , every times 2 bubbles for 4 bubbles but there no particular logic time 2 , 4 bubbles position same. to honest far away start cause couldn't figure out logic. idea, appreciable. thank you. do: create class method set frames prepare layout how display. depend on no of bubbles. for ex: if 1 bubble show in center screen if 2 bubbles show both in 1 line if 3 bubbles make round display if 4 bubble square display if 5 bubbles shape shown image here above so define frames buttons checking no of bubbles. after you'll need use class code. automatically take frames defined in class.

java - Adding KeyListener to TitleAreaDialog -

Image
i have titleareadialog tableviewer allows user select row table. problem is, content of table may change on time. implement refresh behaviour commonly found in browsers (e.g. pressing f5 content of table should refresh). below screenshot should make scenario little clearer: it looks there possible solution in this question , think flawed several reasons: the listener isn't detached (e.g if reopen dialog have 2 filters on display ) it doen't add listener titleareadialog or widget believe belongs architectural point of view. i avoid manual listener-attaching/detaching (e.g. listener should disposed titleareadialog ) long story short: proper way of adding keylistener titleareadialog (or dialog in general) without using filter mechanism described in aforementioned question ? i know question somehwhat fails in sscce department, pointers right direction highly appreciated. adding listener key events tricky thing. want listener fired when non

java - Hadoop WordCount sorted by word occurrences -

i need run wordcount give me words , occurrences sorted occurrences , not alphabet i understand need create 2 jobs , run 1 after other used mapper , reducer sorted word count using hadoop mapreduce package org.myorg; import java.io.ioexception; import java.util.*; import org.apache.hadoop.fs.path; import org.apache.hadoop.io.*; import org.apache.hadoop.mapred.*; import org.apache.hadoop.mapreduce.job; public class wordcount { public static class map extends mapreducebase implements mapper<longwritable, text, text, intwritable> { private final static intwritable 1 = new intwritable(1); private text word = new text(); public void map(longwritable key, text value, outputcollector<text, intwritable> output, reporter reporter) throws ioexception { string line = value.tostring(); stringtokenizer tokenizer = new stringtokenizer(line); while (tokenizer.hasmoretokens()) { word.set(tokenize

vba - How to add image automaticly on excel -

Image
i have excel file below image. in column c there product code & local drive there images product code. want insert image on column w automatically image column. how it's possible? (i using microsoft office excel 2007) you can see here example : http://www.exceltip.com/general-topics-in-vba/insert-pictures-using-vba-in-microsoft-excel.html

intern Functional Testing with Frames -

i'm using intern , writing functional tests. application testing uses lot of dojo tabs , iframes , i'm having trouble navigating around functional tests. i can select iframes using "frame()" call , fine accessing nested iframes. how navigate up? selenium webdriver has defaultcontent return top frame can't find implementation of in intern wd. the problem having navigate down nested iframe , click button switches different dojo tab in higher frame. can see browser loading , switching new tab intern still stuck on same nested iframe , can't navigate up. thanks passing null frame identifier switches page’s default content.

python - After splitting add newline -

after splitting add newline. both queue size = 3; how split without '\n' in end source.txt: 234;234 456;567 4567;6789 exec: open('source.txt') line: source in line: result = source.split(";") qm.put(result[0]) qp.put(result[1]) print(result[0]) print(result[1]) print('----') result: 234 234 ---- 456 567 ---- 4567 6789 ---- please check this: using strip() import queue qm = queue.queue() qp = queue.queue() open('txt') line: source in line: result = source.strip().split(";") qm.put(result[0]) qp.put(result[1]) print(result[0]) print(result[1]) print('----') output: 234 234 ---- 456 567 ---- 4567 6789 ----

java - Is a TCP inbound gateway automatically closed by Spring? -

i'm using spring tcp-inbound-gateway listen socket connections on server side. i wonder if socket connection automatically closed after response end client? not find in spring docu: http://docs.spring.io/spring-integration/reference/htmlsingle/#ip-endpoint-reference <ip:tcp-inbound-gateway id="gateway" connection-factory="factory" request-channel="channel" /> further question: how can specify timeout socket connection should kept alive? , close socket if response not send client within time interval? set single-use="true" on connectionfactory , close socket after sending reply. use so-timeout set timeout socket option , socket closed after inactivity. see reply-timeout on inbound gateway. see configuration section of reference manual attributes , meaning.

in Java can one instance method hide another method? -

overriding case: class a{ public void m() {} } class b extends { @override public void m(){} } hiding case : class { public static void m(){} } class b extends a{ public static void m(){} } is 1 instance method hiding another? interface { void m(); } interface j { void m(); } class implements i,j { void m(){} } can instance method hide instance method? class { public static void m(){} } class b { public static void m(){} } these classes don't share common ancestor, 1 can't "hide" other's method. in java, same-name instance methods in subclasses override superclass's instance method, there no hiding mechanism there in other languages (such pascal if remember correctly). true if @override annotation isn't made, annotation makes code more readable , helps against typos. if changed class b extend class a , however, it's static method m() in fact hide same name method in a . this the oracle docs h

c# - How to display links in TextBlock? -

i want show long list of reviews may contain links. how can show them user can click , open links? this question has been asked lot, couldn't find functional answer, obsolete answer seems isn't working: <textblock> <run>let me</run> <hyperlink navigateuri="http://www.google.com">google</hyperlink> <run>that you</run> </textblock> also richtextbox doesn't support data binding it? reviews shown inside longlistselector this: <phone:longlistselector itemssource="{binding reviews}"> <phone:longlistselector.itemtemplate> <datatemplate> <textblock text={binding review}/> </datatemplate> </phone:longlistselector.itemtemplate> </phone:longlistselector> you missing text property, here complete example of how add links inside richtextbox hyperlink inside rich textbox

Waiting for user input with jQuery and Javascript -

i trying wait take user's input (clicking button) before continuing program. simplified version of code this: $(document).ready(function(){ var answer = $(".question").on("click", "button", takeanswer); alert(answer); }); //code set next question once user has answered previous question function takeanswer(){ var answer = ($(".question button").data("answer")); alert(answer); return answer; } the html body contains this: <p class="question"><button data-answer="1">push me</button></p> on loading, html alerts [object object] . once click button, page alerts 1 supposed to. think problem return line executing without awaiting user's click. research suggests need use callback function (there several discussions on waiting user input), i'm confused because thought putting takeanswer code in separate function keep subsequent code executing. for furt