Posts

Showing posts from June, 2011

c# - Cuda thrust - xutility: name followed by "::" must be a class or namespace -

i use thrust reduction in cuda application. hence include header , call function: #include <thrust\reduce.h> __host__ void reduction(){ unsigned int t = 0; thrust::reduce(t,t); } however compile errors (only 1 type): "name followed "::" must class or namespace". problem file called xutility (which haven't touched). errors related follow class definition: // template class iterator_traits template<class _iter> struct iterator_traits { // traits iterator _iter typedef typename _iter::iterator_category iterator_category; typedef typename _iter::value_type value_type; typedef typename _iter::difference_type difference_type; typedef difference_type distance_type; // retained typedef typename _iter::pointer pointer; typedef typename _iter::reference reference; }; i not template programming. doing wrong? thrust routines designed invoked host side rather in kernels. see example of usi

Wordpress Loop target individual item hover -

have got stuck on little problem, managed wordpress looping correct stuff.. , works fine. problem have got when try target individual item on hover. ive got jquery script working targets them all.. know ive got to change loop not sure im surpose do.. heres code anyway. great if guys help.. thanks wordpres loop <?php $i = 0 ?> <?php query_posts('showposts=3'); ?> <?php if(have_posts()) : while (have_posts()) : the_post(); ?> <?php if( $i == 3 ) : ?> <div class="row"> <?php endif; ?> <div class="col-lg-4 col-md-4"> <a href="<?php the_permalink(); ?>"> <div class="miniwork"> <?php if ( has_post_thumbnail() ) { the_post_thumbnail(); }

Imported jar in gradle, compiles, but not recognized by Android Studio (0.2.10) -

this annoying one. have simple project structure based on gradle, similar other projects have. project has these imports: dependencies { compile 'com.android.support:support-v4:13.0.+' compile files('libs/jackson-annotations-2.1.0.jar') compile files('libs/jackson-core-2.1.0.jar') compile files('libs/jackson-databind-2.1.0.jar') compile files('libs/zip4j_1.3.1.jar') compile files('libs/httpclient-4.1.3.jar') compile files('libs/httpclient-cache-4.1.3.jar') compile files('libs/httpcore-4.1.4.jar') compile files('libs/httpmime-4.1.3.jar') compile project(":grid_lib") } which works well. the problem android studio not recognize classes, in red , have no intel. very annoying! i've been banging head against wall long, i'm trying here now. guys? ideas? thanks :-) edit i've answered own questions, find same problem. well, answer own

html - Selecting all but children -

i've got html structure this: <div class="foo"> <ul> <li> <a href="link.bar">good</a> <ul class="children"> <li> <a href="otherlink.baz">bad</a> </li> </ul> </li> </ul> </div> now want select "good" a without selecting "bad" a (using jquery). i've tried .foo ul:not(.children) li a doesn't work (obviously). possible achieve in one-liner? fiddle you direct descendant .foo > ul > li > a

oop - c# OO advice for inherited attribute classes -

i oo correct advice please. correct way of accessing attribute data inherited classes. assuming 3 classes: public abstract class vehicle { public int id {get; set; } public int wheels {get; set; } public string name {get; set; } public string color {get; set; } } public class car : vehicle { } public class truck : vehicle { public int loadcapacity {get; set; } } my first thought create repository of kind gives me attributes of whatever i'm looking for. there 2 types of queries see need: return attributes of vehicle specific id give me vehiclesof specific type so: public class vehiclerepository { icollection <???> _vehicles; ??? getvehicle(int id); ??? getvehicles(??? vehicletype); } the ??? unknowns. my thought add interface ivehicle , implement vehicle it. result like: public class vehiclerepository { icollection <ivehicle> _vehicles; ivehicle getvehicle(int id); icollection <ivehicle> ge

Multiple nested JQuery UI Accordion generated through Knockout template does not bind correctly -

i'm trying multiple-nested accordion control work knockout when adding panels items created through ko bindings not bind accordion new panels. the code looks this: <div data-bind="accordion: {collapsible: true, active: false, heightstyle: 'content'}, template: { name: 'querytemplate', foreach: children }"> </div> <script id="querytemplate" type="text/html"> <h3> <div> <a href="#" data-bind="text: id"></a>&nbsp; <span data-bind="text: name"></span>&nbsp; <button data-bind="click: addnext">add next item</button> </div> </h3> <div > <input data-bind="value: name"></input> <input data-bind="value: id"></input> <button data-bind="click: addsubitem">add sub

scala - How to permute all combinations involving both lists, with each element preserved at their respective indices? -

i'd transform list - example: val = list(x,y,z) val b = list(x1,y1,z1) desired output list(list(x1,y,z),list(x,y1,z),list(x,y,z1),list(x1,y1,z), list(x1,y,z1),list(x,y1,z1),list(x1,y1,z1)) the order preserved - hence built-in combinations function wouldn't useful. there concise way of doing scala? def permut[a](l: list[(a,a)]): list[list[a]] = l match { case nil => list(list()) // or nil :: nil case (a,b) :: tail => val t = permut(tail) t.map(a :: _) ::: t.map(b :: _) } val = list("x0", "y0", "z0") val b = list("x1", "y1", "z1") scala> permut(a zip b) res22: list[list[string]] = list(list(x0, y0, z0), list(x0, y0, z1), list(x0, y1, z0), list(x0, y1, z1), list(x1 , y0, z0), list(x1, y0, z1), list(x1, y1, z0), list(x1, y1, z1))

javascript - Ajax: replace the content of the container vs load in other div? -

i trying create ajax website. intuitive way seems to use jquery .html() method replace content of container new content. however consider user may visit , b , again, second manipulation of reloading seems unnecessary. another way occurs me load ajax content in new div , somehow hide original content. seems quite manual me , wonder there framework or plugins better handle this. , there performance issue in case since dom elements keep growing? you can cache ajax requests, client javascript won't request server every time when need content. eg. in jquery: $.ajaxsetup({ cache: true }); caching requests default setting in jquery caches responses time.

java - Android View InflateException: Binary XML File line #63 Error inflating class <unknow> -

i dont have errors project clean doesnt work on test wherever looked error couldnt find anyting dont have errors project clean doesnt work on test wherever looked error couldnt find anyting errrors https://www.dropbox.com/sh/qdlwpluf3m5w20n/fjjxzxbjee package com.martlost.esrarengizolaylar; import com.searchboxsdk.android.startappsearch; import com.startapp.android.publish.startappad; import android.net.uri; import android.os.bundle; import android.app.activity; import android.content.intent; import android.view.menu; import android.view.view; import android.widget.imagebutton; public class esrarengiz extends activity { private startappad startappad = new startappad(this); @override public void onresume(){ super.onresume(); startappad.onresume(); } @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_esrarengiz); startappsearch.showsearchbox(this); imagebutton

vaadin - Getting all artifacts for a given group and version in Maven -

is possible list artifacts given group id , version in maven in web-site/link? i trying vaadin dependencies using maven , have following details available: <groupid>com.vaadin</groupid> <version>7.1.6</version> i using mvn dependency:copy-dependencies command dependencies folder. i aware have specify each dependency hand such as vaadin-shared vaadin-server etc. i want able list of these artifacts providing group id , version number above , generate individual dependency entries this: <dependency> <groupid>com.vaadin</groupid> <artifactid>vaadin-shared</artifactid> <version>7.1.6</version> </dependency> <dependency> <groupid>com.vaadin</groupid> <artifactid>vaadin-server</artifactid> <version>7.1.6</version> </dependency> i have checked answer here: how depend on artifacts group of version maven? and looked @ maven entries her

javascript - Windows Phone WebBrowser: right way to get document height -

in windows phone 8 app have webbrowser control (internet explorer 10). need total height of document loaded it. i must use javascript (no jquery), i'm using code (extracted jquery source): documentheight = math.max( document.body['scrollheight'], document.documentelement['scrollheight'], document.body['offsetheight'], document.documentelement['offsetheight'], document.documentelement['clientheight'] ); with long page, get, example, 6000 pixels . check if result correct, manually scroll bottom of page , document.documentelement.scrolltop value. in case value returned 11000 pixels , should right value of document height. so why documentheight half of real value? thank solved. trying height of document before dom ready event , reason value wrong. one of possible solutions know when dom loaded described here: " javascript domready? "

java - Trying to to give different "screens" in jpanel when changing comboBox -

so im trying creat jpanel combobox @ top, 2 options, when choose options different "screens" in jpanel combobox stays, know how create combobox , actionlister question how change screens? put different panels in jframe? ideas? im trying create jpanel combobox @ top, 2 options, when choose options different "screens" in jpanel combobox stays read section swing tutorial on how use card layout working example want.

Java / MySQL: Inserting row into table from Java Web Application (TomCat v7.0) -

basically, have 2 classes in web application, 1 class 'formprocess.java', takes information inserting html form, performs few calculations, outputs result html. works absolutely fine. i have class adding data new row of mysql database, class called 'sqlconnect.java'. works fine if run seperately on server (ie. correctly inserts row on table). what struggling getting sqlconnect methods run formprocess class. when add following formprocess: private sqlconnect sql; and in method: sql.dopost(request, response); i following error: java.lang.nullpointerexception crunch.formprocess.doget(formprocess.java:27) javax.servlet.http.httpservlet.service(httpservlet.java:621) javax.servlet.http.httpservlet.service(httpservlet.java:728) this sqlconnect class @ moment (i left out imports etc.): @webservlet(name="sql",urlpatterns={"/sql"}) public class sqlconnect extends javax.servlet.http.httpservlet { formprocess process = new formprocess(

html - Picture link not working when inside a block -

Image
would know why picture link doesn't work when inside container (the picture white triangle on right side)? note works fine when outside block. css: .block { position: relative; display: block; clear: both; overflow: hidden; box-sizing: border-box; margin-right: auto; margin-left: auto; padding-right: 20px; padding-left: 20px; width: 100%; } .block img { float: right; margin-left: 40px; } adding css should fix issue: .arrow-circle{ position:relative; z-index: 9999; }

java - How to send requests and receive responses to/from an Apache CXF-based service? -

i have several servlets, take json-encoded requests inputs, process them and return responses client json-encoded objects. up used android client (sample android code see below). now want write plain old java program, send requests , receive responses (do same android code). purpose wrote java test (code see below, section java code ) , ran it. at client side error: 21:43:38.930 [main] error r.a.c.t.testacceptanceprocedure1 - java.io.ioexception: server returned http response code: 405 url: http://myserver/myapp/rest/getuseridservice @ sun.net.www.protocol.http.httpurlconnection.getinputstream(httpurlconnection.java:1441) ~[na:1.6.0_23] @ testclient.testacceptanceprocedure1.test(testacceptanceprocedure1.java:47) ~[test-classes/:na] in server log, see message: warning: no operation matching request path "/myapp/rest/getuseridservice" found, relative path: /, http method: get, contenttype: */*, accept: text/html,image/gif,image/jpeg,*/*,*/*;q=.2,.

android - How do I have an app interact with a server inside an intranet? -

i'm start development on app designed communicate information server (hosting web interface , storing data) inside intranet. i've had large deal of programming experience i'm wholly new mobile app development, whole thing learning experience me. i guess have more 1 question: if intranet offers wifi, easy enough see server existing on same intranet? assuming phone , server part of same intranet network, general mechanisms available me have them communicate? if intranet not available through wifi, what's best option? (maybe force wifi setting router?) p.s. i'm final year undergrad developing app+web-app real organisation, gentle me :) 1) if intranet offers wifi, you're go, http request routed correct local boxes. 2) http requests, treat you'd treat external site. 3) if don't have wifi, consider setting vpn , in app guide user through setting vpn. or, set external server (outside intranet) acts proxy intranet server, requiring sor

php - Generate random and if not exist in DB,add it -

i'm there,but missing.my php app: 1)user requesting server 2)the server generating long unique string , checks if exists in db:if yes generate again(until doesn't exists),if no add db , finish. logic should executed single request,i.e user should not request/refresh page if generated string exist. i stuck in yes part. my code ( disclaimer :i not own parts of following code) <?php class genpass { private $db; function __construct() { $this->db=new mysqli('localhost', 'user', 'pass', 'db'); $this->db->set_charset("utf8"); $this->db->autocommit(false); } function __destruct() { $this->db->close(); } function isused($uid) { $stmt=$this->db->query("select * id udid='".$uid."'")or die($this->db->error); while($stmt->num_rows <1) {

c - Why is parallel execution slower than sequential for this code? -

#pragma omp parallel { (i=1; i<1024; i++) #pragma omp (j=1; j<1024; j++) a[i][j] = 2*a[i-1][j]; } i'm using 12 threads execute code. suggestions must speed up? assuming a's type smaller 64bytes, trying parallelize inner loop way cause have false sharing in cache lines. say aligned array of 4-byte ints, have a[i][0] through a[i][15] in same cache line. means 12 threads attempt read line simultaneously, each part needs, may have resulted in having line shared between multiple cores if left @ that, try write back, leading each core attempt take ownership on line in order modify it. cpu caches based on mesi based protocols, making store attempt issue read-for-ownership invalidate line in each other core except requester. issuing 12 parallel (or rather 6 if have 6 core * 2 threads each) result in race first 1 winning line may have preempted him snoop before had chance modify it (although that's not likely). result quite messy, , may take while b

push notification - lost device tokens on server apns -

we have table containing apns device tokens on our servers , due unforeseen circumstances lost data, including backups. in order send push notifications need send device tokens along message, since lost tokens, there way them through apple/ application ? i'm pretty clueless on how proceed further, appreciated there no api gives device tokens app registered apns. assuming app doesn't send device token server every time launched, you'll have release new version send device token server. you'll device token of every user installs updated version , launches app. won't recover tokens of users don't install update, there's nothing can it. i hope have better backups next time.

Java nio read bytebuffer from channel -

my issue how receive data server example "cutting" in parcels of 1024 bytes, cause when answer comes server in packets 2 parts don't know how solve that. ex. when first packet arrives size informed server 1988 , received 1444, it's ok, when second packet arrives size informed 808333347 , received 540, sum of 1444 + 540 = 1984 right. don't know number 808333347 coming from. i'm googling solution , teachs using udp , need tcp/ip connection. please me, solve that. the class: public class connection implements runnable { private static connection instance; private socketchannel channel = null; private int port = 0; private int service = 0; private final int socket_timeout = 15 * 1000; private final int socket_bytes = 16 * 1024; private final charset charset = charset.forname("iso-8859-1"); priva

windows phone 8 - Does ShareMediaTask Require a Data Connection -

i using sharemediatask in windows phone 8 application, , trying determine specific capabilities , requirements on users device. users data connection have turned on on device sharemediatask send picture? also, required have id_cap_networking checked in application's wmappmanifest sharemediatask work? must both of these on? what have id_cap_networking off in wmappmanifest, not believe require sharemediatask, device's data connection switched on in phone settings. correct? sharemediatask not have capability requirements inclusion within app. however, user able share media need able connect internet , selected services. happens outside of app though , app not need declare networking capability directly. for reference, rules of capability requirements defined in "c:\program files (x86)\microsoft sdks\windows phone\v8.0\tools\marketplace\rules.xml"

linq - c# changing this line so it outputs the string as a variable -

update post origianal post after code --- code update david has been helping me throwing 1 error need using system; using system.collections.generic; using system.linq; using system.text; using system.collections.specialized; using system.net; using system.io; namespace consoleapplication1 { class program { static void main(string[] args) { string url = "http://localhost/test2.php"; webclient webclient = new webclient(); namevaluecollection formdata = new namevaluecollection(); formdata["var1"] = formdata["var1"] = string.format("machinename: {0}", system.environment.machinename); formdata["var2"] = ip(); byte[] responsebytes = webclient.uploadvalues(url, "post", formdata); string responsefromserver = encoding.utf8.getstring(responsebytes); console.writeline(responsefromserver); webclient.dispose(); system.threading.threa

python - How to mix named and unnamed string formatting -

how mix named , unnamed string formatting? consider following not-running example: s = "{:s}_{later}_{:s}".format("foo", "bar") s1 = s.format(later="later") i want first format somthing including named postioner later formatting. how archieve in python ? you'll have escape named formatting part: >>> "{:s}_{{later}}_{:s}".format("foo", "bar") 'foo_{later}_bar' >>> _.format(later="later") 'foo_later_bar' or other way around: >>> "{{:s}}_{later}_{{:s}}".format(later="later") '{:s}_later_{:s}' >>> _.format("foo", "bar") 'foo_later_bar'

recursion - Adding a symbol to the end of a two element list in Scheme -

so far have (define insert-3 (lambda (sym ls) (cond [(null? ls) '()] [else (cons sym (insert-3 (caadr ls)))]))) i know caadr wrong, because doesn't exist in 2 element list. don't know how add symbol end of list. assuming sym 'c ls '(a b) then result constructed by > (cons 'a (cons 'b (list 'c))) '(a b c) or equivalent > (cons 'a (cons 'b (cons 'c null))) '(a b c) so procedure needs cons each element until has consumed ls, , cons (list sym) or (cons sym null) @ point: (define insert-3 (lambda (sym ls) (cond [(null? ls) (list sym)] [else (cons (car ls) (insert-3 sym (cdr ls)))]))) such that (insert-3 'c '(a b)) => (cons 'a (insert-3 'c '(b))) => (cons 'a (cons 'b (insert-3 'c '()))) => (cons 'a (cons 'b (list 'c))) which work length of list: > (insert-3 'c '(a b)) '(a b c

mpi - Parallel execution with a PBS script -

i trying write pbs script. i have use 4 nodes in cluster , run 4 times executable program. difficulty 4 executions have run in parallel, 1 node for moment, have allocated nodes #pbs -l nodes=4:ppn=1 the problem don't know how sure programs run in parallel. how can ? if don't need program communicate other copies of itself, don't need mpi. mpi stands message passing interface ( mpi forum website ) , popular way of writing parallel program. there lots of tutorials on web can find quick search. recommend taking @ them. can test things out on own machines installing mpi library yourself. they're available in package managers. popular open-source implementations mpich , open mpi . if you're starting scratch, try date versions you'll more various communities way. you can execute non-mpi program mpiexec , launch across multiple nodes (assuming you've set things correctly), won't make them communicate. has done explicitly (again, see mpi

if statement - Elseifs being skipped in Lua -

i started work on little game-dev project in lua, , having trouble part of code: if genrel == rpg , langl == basic , topicl == war review = math.random(2, 5) review2 = math.random(2, 5) review3 = math.random(2, 3) money = money + 300 print("you have earned total of $300 dollars game. overall not many people enjoyed game.") elseif genrel == rpg , langl == basic , topicl == "western" review = math.random(7, 9) review2 = math.random(4, 9) review3 = math.random(5, 8) money = money + 400 print("you have earned total of $300 dollars game. game recieved mixed reviews.") topicl, langl, , genrel, defined earlier in code. example: topicchoice = io.read() if topicchoice == 'war' topic = "[war]" topicl = war proglang = io.read() if proglang == 'java' lang = "[java]" langl = java genrechoice = io.read() if genrechoice == 'action' genre =

c# - WPF spritesheet animation -

i trying create animated sprite spritesheet in wpf. current technique using breaking down image of containing frames of animation separate images , swapping them out. however costly on memory , wondering if there way draw section of image (specify source rectangle) rather splitting image up. you can this. in order supported wpf's built-in animation system need animate dependency property . in case seems want animate sourcerect property of croppedbitmap using rectanimationusingkeyframes discreterectkeyframe class. if you're displaying image using image element set it's source property croppedbitmap , cropped bitmap have source property set bitmapimage . cropped bitmap wraps standard bitmap , adds cropping functionality.

php - Is it possible to get which tab is loading ajax page without GET? -

very easy example: <div id="tabs"> <ul> <li><a href="tab_index.php" id="ctx-1">tab 1</a></li> <li><a href="tab_index.php" id="ctx-5">tab 2</a></li> </ul> <div class="tabs-spacer" style="height:0px"></div> </div> and problem: i'd know tab "calls" tab_index.php. the easiest solution be: tab_index.php?ctx=1, don't want use security reasons. is possible @ all? the fiddle: http://jsfiddle.net/sledgehammer/m8jya/ you bind click on tab link $('a[href="tab_index.php"]') $(function() { $('a[href="tab_index.php"]').click(function(){ var clickedtab = $(this).attr("id")); }); }); jsfiddle example - http://jsfiddle.net/zdw37/6/

Bash get hard drive path -

is there way symbolic path (e.g. /dev/sda) of computer's hard drive bash script executed flash drive inserted computer? /dev/sda? it different sda . if computer has 4 hard-drives? you run fdisk -l root (or sudo), check bootable device. c: drive. doesn't mean device contains windows. one can install windows on hard-disk(ii) boot disk(i). so fdisk -l way can find bootable partition/disk on machine. can check fs if could windows system fs (e.g. fat32/ntfs). cannot tell if disk has windows (those windows system files) installed. moreover, if computer has 4 disks, , install winos on each of them, there 4 windows installed. multi-booting system. cannot find proper solution find disks except mounting partitions , checking fs.

javascript - Converting busy time to free time -

i have set of data busy times during day , want predict unbusy time somehow subtracting time slots day. i'm wondering what's best approach/algorithm that. [ '20:30 21:30', '11:00 12:00', '07:30 08:50', '09:00 20:00' ] what i'm thinking right make array 24 blocks of day free [1-2, 2-3, 3-4, 4-5 ..etc] , somehow process starting time , deduct spot ex. 1.30 2.00 turn free block of 1 1-2 1-1.30. start not sure if work i had similar problem, had busy slots of person, , wanted find time slots person available ("free"). coded, hope can someone: function getfreeofday (date, busyslots) { function samedatedifferenttime(date, hours, minutes) { return new date(date.getfullyear(), date.getmonth(), date.getdate(), hours, minutes, 0, 0); } // define range free spots var freeslots = date.getday() === 0 || date.getday() === 6 ? [] : [ { start: samedatedifferenttime(date, 10, 0), // 10:00 (am) en

java - Starting with FXML - App returns error when changing Label ID and modifying controller accordingly -

Image
i'm following basic tutorials. environment is: java 7 oracle sdk netbeans 7.3.1 javafx scenebuilder 1.1 i asked project wizard produce first fxml called main. it has button on , label fx id "label". when click on it, label set "hello, world!". far good. i want simple: add label id "label2" , add the button event in controller: label2.settext("something else"); this fails. don't understand why. details: fxml: <?xml version="1.0" encoding="utf-8"?> <?import java.lang.*?> <?import java.util.*?> <?import javafx.scene.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <anchorpane id="anchorpane" prefheight="200.0" prefwidth="320.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="fs2i.maincontroller"> <children> <button id="butt

java - why does the for-loop go through the args three times? -

i want know why for-loop counts through args 3 times , doesn't stop after first loop? code : public class test2 { public static void main(string[] args) { int n = args.length; int[] x = new int[n]; int count = 0; (int = 0; < x.length; i++) { x[i] = integer.parseint(args[i]); } (int = 0; < n; i++) { (int j = i+1; j < n; j++) { if (x[j] != x[j-1]) { count++; } system.out.println(count); } } system.out.println(n-count); } } i think mean this: (int j = 1; j < n; j++) { if (x[j] != x[j-1]) { count++; } system.out.println(count); } system.out.println(n-count); instead of: for (int = 0; < n; i++) { (int j = i+1; j < n; j++) { if (x[j] != x[j-1]) { count++; } system.out.println(count); } } system.out.println(n-count);

vBulletin - update forum password not working -

my question more theoretical, because not sure wrong. here goal: i have password protected forum. have script runs once week , simple statement: mysqli_query($con,"update vb_forum set password=$password forumid='28'"); that changes password forum in database; however, when user goes forum , enters new password - doesn't work. have go admincp , edit forum (the password field filled in updated password.) without changing hit save , new password takes effect. i wondering vbulletin don't in code? any hints appreciated! figured out after doing search on entire database. appears have update value in vb_datastore table well

awk - bash command quoted by single quote -

i need find process string matching, , kill it, need in 1 line in script file: here's tried: 'kill $(ps -ef|grep xxx|grep -v grep | awk '{print $2 }' )' "kill $(ps -ef|grep xxx|grep -v grep | awk '{print $2 }' )" first 1 didn't work because of nested single quote, second 1 didn't work because $2 taken parent script argument 2 parent script. how do this? the easiest way accomplish task is: pkill xxx (which you'll find in debian/ubuntu world in package procps , if don't have installed.) might need use pkill -f xxx , depending on whether xxx part of process name or argument, case script execution. however, answer more general question shell-quoting, if need pass string kill $(ps aux | grep xxx | grep -v grep | awk '{print $2}') as argument, need use backslash escapes: bash -c "kill \$(ps aux | grep xxx | grep -v grep | awk '{print \$2}')" or, can paste several quoted strings:

recursion - Recursive function returning none in Python -

this question has answer here: i expect 'true' 'none' 1 answer python recursion list returns none 1 answer i have piece of code, reason when try return path, none instead: def get_path(dictionary, rqfile, prefix=[]): filename in dictionary.keys(): path = prefix+[filename] if not isinstance(dictionary[filename], dict): if rqfile in str(os.path.join(*path)): return str(os.path.join(*path)) else: get_path(directory[filename], rqfile, path) is there way solve this? in advance. you need return recursive result: else: return get_path(directory[filename], rqfile, path) otherwise function ends after executing statement, resulting in none being returned. you want drop else: , return @ end: for filename

sublimetext2 - How to open and save files -

is there way open files in sublime text2? at moment open files this. i open terminal , enter subl source/myproj/myfile.rs can inside of sublime text2/3 ? also when want create new file in source/myproj/ usally press ctrl + n create new window , hit ctrl + s save , name file. problem when hit ctrl + s file system dialog opens , have use mouse. i think saw using vim , source/myproj/mynewfile.rs , file created. is possible in sublime text 2/3? to open file in current project, can hit ctrl+p , start writing filename. sort through files in project , give little list, 1 looking pre selected, if not, somewhere near topmost options select from, use arrow key down , highlight it, press enter , opened file. another option create file using advancednewfile plugin . when hit ctrl+n , asks near bottom of window path , filename, once enter it, opens new tab file created, not untitled file later use system dialog save disk.

Add a parent to the original changeset in Mercurial -

i have project 24 months of source control history in mercurial repository. i've found old tarballs of project predate source control, , think useful import repository "pre-historic" changesets. can somehow add parent initial commit? alternatively, possible re-play entire repository history on top of tarballs, preserving metadata (timestamps etc)? is possible have new parent commits use timestamps of these old tarballs? you can use convert extension build new repository tarballs imported revisions before current root revision. first, import tarballs based on null revision: $ hg update null $ tar -xvzf backup-2010.tar.gz $ hg addremove $ hg commit -m 'version 2010' $ rm -r * $ tar -xvzf backup-2011.tar.gz $ hg addremove $ hg commit -m 'version 2011' i'm using addremove above give mercurial chance detect renames between each tarball (look @ --similarity flag fine-tune , use hg rename --after hand mercurial further). also,

ios - iPhone how to access the notification center programmatically -

as per apple guide: if application icon tapped on device running ios, application calls same method, furnishes no information notification . if application icon clicked on computer running https://developer.apple.com/library/ios/documentation/networkinginternet/conceptual/remotenotificationspg/introduction.html#//apple_ref/doc/uid/tp40008194 as far have known, seems not able detect notification when application icon tapped. so tried retrieve notification center programmatically seems impossible. is impossible retrieve notification center programmatically? what want detecting whether notifications received or not when application in background. is impossible retrieve notification center programmatically? no, it's not possible public api. your app agnostic current state of notification center, 2 decoupled entities. anyway, noted adamg, in ios 7 can implement application:didreceiveremotenotification:fetchcompletionhandler: which, according docume

angularjs - Rails catch all route, excluding resources and HTML -

i using angular html5mode have rails routing set redirect failed requests root # angular catch allow page refresh '*page' => "home#index" this works fine, except when angular module requests missing template (/assets/templates/page.html example), when causes endless loop how can tell rails catch routes, except things in /assets ? i noticed quite old, found through google , wasn't happy answer here. since worked through myself share solutions. use format parameter in route get "/*path" => "home#index", format: false simply disable format option wildcard path ignores requests format (e.g. css, js, png...) use constraint in route get "/*path" => "home#index", constraints: -> (req) { !(req.fullpath =~ /^\/assets\/.*/) } specify constraint option simple lambda checking path value, not best regular expression shows idea i'm going here... use format parameter in apps, constra

math - The running time of my program in big O time -

can me figure out running time of loop? believe o(5nlogn). for(int f = 0; f < array.length; f++) { f = array[f]; for(int e = 0; e <= f; e++) { e = array[e]; for(int d = 0; d <= e; d++) { d = array[d]; for(int c = 0; c <= d; c++) { c = array[c]; for(int b = 0; b <= c; b++) { b = array[b]; for(int = 0; <= b; a++) { = array[a]; } } } } } } thanks a way think space you're iterating over. if think it, loops iterate on nonnegative integral valuesof (a, b, c, d, e, f) where n > f ≥ e ≥ d ≥ c ≥ b ≥ a each of these iterations o(1) work (all loops assign variable, takes o(1) work), question how many possible values there satisfy above formula. i'm going claim it's θ(n 6 ) , , try justify rest of answer. first, note value isn't mor

javascript - JQuery Autocomplete using a global JSON object -

i have json array of objects looks like: jsonobject= [{"description":"mac , cheese", "servingsize":"1 cup", "calories":"500"}, {"description":"slice of pizza", "servingsize":"1 slice", "calories":"400"}, {"description":"oreo cookie", "servingsize":"1 cookie", "calories":"100"}, {"description":"salad", "servingsize":"1 cup", "calories":"50"}, {"description":"apple", "servingsize":"1 apple", "calories":"70"}] i trying create autocomplete text box using description field of jsonobject. have tried following code (on textbox called "food") not display anything: $('#food').autocomplete({source:jsonobject, select: function(event, ui) {

Add a file to tfs that is accessible for all developer, but only for local repository -

we have development server running tfs 2010, working fine have bit of issue: we have file (a class file) contains connection string helps application connect database, each user has own database, mean developers needs connect other servers while specific file locked other users in other machines. therefore @ same time different users trying change connection string! i know can save connection string in file not part of tfs or can allow checked in item edited, know if there anyway can add class file our tfs , able server when want edit it, should not checked out tfs, in local repository changes. thanks if web application can add connection string web.config , have both development , deploy mode. if of developers connect db server running on local box need 1 setting of developers. if need different settings local | integration | quality | production environments can use built in visual studio configurations. it standard practice require of developer local computers c

sqlalchemy - Pyramid console script - DBSession not inserting? -

i have working pyramid web app, based on sqlalchemy scaffold. within application, have function sends emails , inserts/updates tables in database via sqlalchemy. on web, call function via view, i.e., button on web submits view , within view calls function. i create console script calls same function, on scheduled basis. i'm working through sample documentation setting pyramid console script . in perfect world want able access of models , functions i'm using in web app, able use them console. through trial , error i've managed include basics working, in i'm able query 1 of model objects , print console. i'm able call function want. however, inside function writes row database , sends out email. when call function console, work (at least printed console) , sends emails. prints 'insert' statements should. isn't either executing inserts or committing them, i'm not sure which. i'm importing dbsession models.py package rest of pyramid