Posts

Showing posts from August, 2013

flask - Submitting User Data in Javascript MVC Frameworks -

this first attempt @ making webapp using javascript mvc framework , need pointers right ways in getting following accomplished. i'm making voting application in flask (server-side) , sammy.js on client. i've implemented routes , views i'm confused how send data server since "form" in case split across different views. here screenshot . can see candidates standing each post displayed @ http://127.0.0.1:5000/#/post_id i'm fetching data in json , rendering using sammy's templates. my question storing users votes. each tile in screenshot have radio button , want somehow users votes(across posts) , send them query string(i'm not sure if correct) server record votes. is there way address such problems in front-end development? i'm totally clueless pattern of development i've developed more traditional (server-side heavy) applications. pointers appreciated. bunch! ps: apologies misleading title. finding hard find more descriptive. ...

Alternative Captcha Like Services -

what website provides captcha services? it can difficult correct read captcha. in cases letters on stretched difficult discern letters are. recapcha 1 of best. easy implement, , hard bypass

SOLR and stemming -

is there easy way exclude words stemming in solr? have database full of food items , everytime search things "fried shrimp" bring results "boiled shrimp served fries" for 98% of our search stemming in other instances work fine , want keep stemming in place. we need omit words stemming process "fries" , "fried" unique , not variations of each other. when search "fries" picks "fries" not "fried catfish" or word fried in it. thanks! the solr.keywordmarkerfilterfactory should protect words being stemmed. see this page regarding snowballporterstemmer.

c# - Ajax load data from multiple JSON sources -

i using asp mvc4 razor2. trying use javascript retrieve json data , select property want display. each thread has it's own json file , displaying 15 threads @ time. can't data @ once, slows down page load time. thinking client side fine since since it's not sensitive data. here code: public static pagedlist<pifdetailsmodel> getpagedthreads(int skip, int take) { using (var context = new pifdbdatacontext()) { // refactor consideration...make pre-compiled query var threads = context.threads .orderby(c => c.createddate).skip(skip).take(take).tolist(); var threadscount = threads.count(); var details = new list<pifdetailsmodel>(); foreach (thread thread in threads) { var model = new pifdetailsmodel(); var games = new list<game>(); // make ajax instead. string text; ...

java - Why remove element of Map? -

i filtering list ahve same lat,long in 1 list , put same list , put list map code as:- private collection<list<applicationdataset>> groupthelist(arraylist<applicationdataset> arraylist) { map<key, list<applicationdataset>> map = new hashmap<key, list<applicationdataset>>(); for(applicationdataset appset: arraylist) { key key = new key(appset.getlatitude(), appset.getlongitude()); list<applicationdataset> list = map.get(key); if(list == null){ list = new arraylist<applicationdataset>(); } list.add(appset); map.put(key, list); } return map.values(); } public class key { string _lat; string _lon; key(string lat, string lon) { _lat = lat; _lon = lon; } @override public boolean equals(object o) { if (this == o) return true; if (o == null || getclass() != o.getclass()) return false; ...

java - How (in)efficient is ExecutorService.invokeAll() when called with a single task? -

i have code makes heavy use of thread pool, use creating collection<callable<t>> tasks , , calling executorservice.invokeall(tasks) . for (future<object> future : threadpool.invokeall(tasks)) { object object = future.get(); // calling thread blocks on invokeall(). } in app, size of tasks varies lot. in fact, of time executorservice.invokeall() called single task . implementation of invokeall() i'm using calls threadpoolexecutor.execute() , whose implementation appears run task in thread pool (never in calling thread). in case of single task, more efficient call task in current thread rather send off thread? in case of single task, more efficient call task in current thread rather send off thread? yes, more efficient. that's not interesting question though. interesting questions how inefficient - depend on task doing - , whether you're doing enough in application significant overall. we don't have enough information ...

php - Clarity on Code -

just looking clarity on code. i'm looking @ controller class, has protected variables named $grid , inside there there __construct function connect mongodb, after there code: $this->grid = $mongo->selectdb($database)->getgridfs(); further on in in script in class , method have code foreach ($this->grid->find() $file) { am right in thinking foreach using first defined $this->grid being $monmgo->selectdb? many thanks it worth reading on php5 objects , classes __construct() , $this , , method call chaining basic object-oriented implementation concepts in php. the php method calls chained in code example, means results of 1 method being passed next (from left right). $this->grid = $mongo->selectdb($database)->getgridfs(); so code executes as: $mongo->selectdb($database) .. select database name ($database); presumes $mongo connected mongo object ) now, call getgridfs() on selected database finally, assign results ...

wordpress - Truncating content should be based on number of characters or words? Which one is more logical? -

i developing theme , have choice truncate post content on post-listing pages based on either number of characters or number of words. tend towards words because, it's more natural , not cut last word abruptly (which happens when number of character constraint applied). i'd know more opinions.

http - Why does Chrome auto-close links to my site with target of a new window? -

i'm stumped on this, if can offer clue, i'd appreciate it. here's site (built in rails): http://floating-autumn-3174.herokuapp.com/ when attempts visit site link on facebook or twitter, new tab loaded closes right away. happens in chrome. works fine in firefox. if right click on link , select "open in new tab" loads fine. if right click , copy link, works fine. i thought might ssl redirects, tested staging environment (no ssl) , works fine. so auto-closing happens in chrome , when clicking on link loads new tab. any clue what's going on or how can better troubleshoot this? edit ok, after looking our included javascripts more believe i've found issue. involves js use handle pop-ups. first let me explain we're trying do. authenticate via facebook. when user click "sign in via facebook" pop launches , authenticates. when successful popup closes , main window refreshes in signed in state. works fine realize popup closing cod...

Creating a Python list from a list of tuples -

if have, example, list of tuples such as a = [(1,2)] * 4 how create list of first element of each tuple? is, [1, 1, 1, 1] . use list comprehension : >>> = [(1,2)] * 4 >>> [t[0] t in a] [1, 1, 1, 1] you can unpack tuple: >>> [first first,second in a] [1, 1, 1, 1] if want fancy, combine map , operator.itemgetter . in python 3, you'll have wrap construct in list list instead of iterable: >>> import operator >>> map(operator.itemgetter(0), a) <map object @ 0x7f3971029290> >>> list(map(operator.itemgetter(0), a)) [1, 1, 1, 1]

Can you Create a Keynote using the Revit API in C# -

i'm trying create keynote tag via revit 2012 api. however, found reference creating keynote tag anywhere on internet or in samples. see builtincategory.ost_keynotetags part of independenttag class , according http://thebuildingcoder.typepad.com/files/guide-to-placing-family-instances-with-the-api.doc need use tm_addby_category tagmode create keynote. however, when try change new tag via changetypeid, error. has figured out? i haven't had chance try yet, i'm thinking you're out of luck. part, can't things api can't interactively in revit. did test can't change type of multi-category tag keynote tag. while they're both independenttag elements, different categories, , it's rare in experience can switch category of placed element.

javascript - Request being executed as an GET thought defined type="POST" -

i had been trying change relationship between 2 users using js(jquery). had been using jquery ajax achieve , issuing post request. here code. var url='https://api.instagram.com/v1/users/'+ userid +'/relationship?callback=?'; //forming ajax $.ajax({ type:'post', url:url, data: { access_token: edit_access_token, action: 'follow' }, datatype:'json', success: function(res) { if(res.data.) } }); issues: instagram returns meta 200. , data incoming-status="none" & outgoing-status="none" update: request being executed ajax instead of post . expected answers: please tell doing wrong? update: i found request being executed request retrieving relationship info. user! how make sure i'm executing post request ajax? thanks.

callback - jQuery/Javascript Functions Don't Work After Changing Content -

** i have solved deleting jquery library imports in page called via ajax.thanks helps guys! ** i developing admin panel game.all things ok have problem js functions.i have index.php , server.php...i include server.php ajax callback function.that ok.i can retrieve of form content except head tags guess.i have script.js witch has functions.i add script both of pages.when change content callback, server.php's functions don't work. i've read articles that.they change script.i've changed way below see.it $('#dialog_confirm').click it.i still can't use functions in server.php. when open server.php in new tab without callback, works.what can do?thanks in advance. $('#dialog_confirm').live("click", function() { $.confirm("confirm?", function() { $.msg("yes!"); }, function() { $.msg("canceled"); }); i use that in order change page content. ok example of calling ser...

ruby - Gem for Recurring schedule with durations -

i working on building asset tracker. in application have 'assets' user checks out period wed 8a.m friday 8 a.m. want made recurring well. recurring reservation every week wed 8 friday 8 the 5 coming weeks should made feasible.i later have queries want check if reservation has collision such recurring reservation or non-recurring reservation. i found ice_cube quite awesome recurring events there no concept of duration. cleanest way deal durations? , ofcourse not talking of final end duration recurring duration. 'ice_cube' allows specify :duration parameter in seconds in initialize method schedule have recurring duration. i missed out on earlier. should solves problem.

php - Yii recommendation for custom interface -

i want follow conventions , need know place custom interface want classes ipmplement. i know it's recommendation know think? thanks, danny your question has many answers. suggest try , try different ways use yii. example, develop in modules. why? simplest way re-use code. way code. "need". what application need? there way develop reusable actions. so, right one? depends on needs. sometimes people ask "is bettere mysql or sqlite?". , asnwer can "maybe json or text file". are alone or inside team? ask team. or, ... try, , confident , different approach.

python - Mercurial ReviewBoard and post-review -

so here story far, have installed review board on linux environment, have configured everything, installed post-review , works... what not work repository. our repository migrated @ point svn mercurial, there lot of crude file management made moving files around without hg move. wanted run script gather , post reviews every cset containing more 2 parents (every cset merged default branch) , diff previous default branch revision see catastrophic changes fellow collegues have made code. sort of history book , of course schedule job store new review requests made in future. anyway post-review 95% of time throwing me error 207 or file not found (due hg missusage mentioned above). needless 1 big repo - considering daily synced 8 other repositories. maybe there workaround skip missing file diff's , go post-review got far or smt ? i have been reading sorts of issue tickets day long... nothing yet far :( please help... p.s. >>> attempting create review request on...

sendmail - Java's System.getRuntime().exec not behaving as if the shell user called it -

i running java application console on hp-ux machine. in it, generate reports, zip them, , email them. working, except email. i using mail binary send mail command line. since it's hp-ux, it's bit different standard gnu sendmail. this code i'm using send mail: public static void emailreports(string[] recipients, string reportarchive, string subject){ simpledateformat dateformat = new simpledateformat("mm-dd-yyyy"); string today = dateformat.format(new date()); file tempemailfile; bufferedwriter emailwriter; try { tempemailfile = file.createtempfile("report_email_" + today, "msg"); emailwriter = new bufferedwriter(new filewriter(tempemailfile)); } catch (ioexception e) { e.printstacktrace(); system.out.println("failed send email. not create temporary file."); return; } try { emailwriter....

ASP.NET pressing Enter key causes log out -

i have created website. after login when hit enter key add product, website kick me out.? dont have problem adding cart mouse click. 1 have same issue or suggestion .. you need add controls inside asp:panel , make addproduct button default button: <asp:panel id="panel1" runat="server" defaultbutton="btnaddproduct""> //your other stuff <asp:button id="btnaddproduct" runat="server" onclick="btnaddproduct_click"/> </asp:panel> this fire addproduct button when hit enter. regards

memory - How to delete exact file from filesystem passing OS features? -

i have: installed os filesystem ext3 or ntfs or smth else exact file on filesystem ozzy.mp3 i want: to delete file passing os , features, delete file no corrupting other memory how can it? if want erase file bypassing operating system entirely program need include code needed update each file system's directory structures, each file system want compatible with. i guess may kind of doable, far easy, , you'll end rather bulky program (lots of code if need support several file systems).

javascript - How to disable highlighting on Hover? -

i have disable highlighting effect of <select> of html. when pull down items in drop down list , move mouse on items blue color strip moves mouse. have disable effect. here sample code <select> <option>april</option> <option>may</option> <option>june</option> </select> here demo http://jsfiddle.net/jams/5zc3m/ css or javascript solution welcome. it's highlighted browser because it's active. believe way disable literally disable select box <select disabled="disabled"> that remove functionality.

c - Unable to properly terminate "while" loop -

i'm trying out programming in c first time, , applying concrete stuff... the program i'm creating problem deals while loop. goal of program calculate average miles per gallon set of trucks. want terminate -1 inputted number of gallons consumed, instead have input twice, once number of gallons, , once number of miles. have found input in fact used part of calculation of result. here code: #include <stdio.h> int main() { int tanks, miles; float gallons = 0, average = 0, miles_per_gallon = 0; tanks = 0; while (gallons != -1) { tanks += 1; miles_per_gallon = (float)miles / gallons; average = average + miles_per_gallon; printf("the miles / gallon tank %.3f\n", miles_per_gallon); printf("enter gallons used (-1 end): "); scanf("%f", &gallons); printf("enter miles driven: "); scanf("%d...

Perl Imager::Screenshot not doing screenshot with default parameters -

i have following code: use imager::screenshot 'screenshot'; $img = screenshot(hwnd => 'active', left => 450, right => 200, top => 50, bottom => 50 ); $img->write(file => 'screenshot.png', type => 'png' ) || print "failed: ", $img->{errstr} , "\n"; it prints: "can't call method "write" on undefined value @ line 3" but when do: use imager::screenshot 'screenshot'; $img = screenshot(hwnd => 'active', left => 100, right => 300, top => 100, bottom => 300 ); $img->write(file => 'screenshot.png', type => 'png' ) || print "failed: ", $img->{errstr} , "\n"; it take screenshot. why left, right, top , bottom values matter here? edit: after research found out left param must smaller right param , top must smaller bottom. have tried ch...

how to enable opengl es frame capture in xcode 4.3.1 -

just cannot find ui enabling opengl es frame capture. i know in xcode 4.2 document, interface in edit scheme link below. not found in 4.3 @ place. http://developer.apple.com/library/ios/#documentation/developertools/conceptual/whatsnewxcode/articles/xcode_4_2.html#//apple_ref/doc/uid/00200-sw1 there no longer check box enable this. you need have opengles.framework in project navigator camera icon appear. (i have several apps included via linker settings, not picked up). if still fails, try removing , re-adding it, , add build phases/link binary libraries. i've found pretty reliable.

ios - Create a tilt-shift filter like instagram in objective C -

i trying create tilt-shift filter of image instagram or idarkroom in ios. my proposed method use different gaussian blur levels partial image. don't known how control area apply different gaussian blur levels, when user can change effect area rotate, scale, etc. sorry complex presentation simply, want create tilf-shift tool ios in instagram. i search , found powerful framework https://github.com/bradlarson/gpuimage , it's not solution if include huge framework tiny apps i found solution: use filter gpuimagegaussianselectiveblurfilter , change computing distancefromcenter on code: distancefromcenter = abs((texturecoordinate2.x - excludecirclepoint.x) * aspectratio*cos(angle) + (texturecoordinate2.y-excludecirclepoint.y)*sin(angle));

iphone - How to take a screenshot when video playing? -

how take screen shot when video playing? used mpmovieplayercontroller video playing. - (uiimage *) capturescreen { uiwindow *keywindow = [[uiapplication sharedapplication] keywindow]; cgrect rect = [keywindow bounds]; uigraphicsbeginimagecontext(rect.size); cgcontextref context = uigraphicsgetcurrentcontext(); [keywindow.layer renderincontext:context]; uiimage *img = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); return img; }

algorithm - Knuth-Morris-Pratt implementation in pure C -

i have next kmp-implementation: #include <stdio.h> #include <stdlib.h> #include <string.h> int kmp(char substr[], char str[]) { int i, j, n, m; n = strlen(str); m = strlen(substr); int *d = (int*)malloc(m * sizeof(int)); d[0] = 0; for(i = 0, j = 0; < m; i++) { while(j > 0 && substr[j] != substr[i]) { j = d[j - 1]; } if(substr[j] == substr[i]) { j++; d[i] = j; } } for(i = 0, j = 0; < n; i++) { while(j > 0 && substr[j] != str[i]) { j = d[j - 1]; } if(substr[j] == str[i]) { j++; } if(j == m) { free(d); return - j + 1; } } free(d); return -1; } int main(void) { char substr[] = "world", str[] = "hello world!"; int pos = kmp(substr, str); printf("position starts at: %i\r\n", pos); return 0; ...

php - case sensitive search in find query using cakephp -

my query $this->find('first', array('fields' => array('staticpage.title', 'staticpage.description'),'conditions' => array('staticpage.url' => 'australia'))); its display in logs select `staticpage`.`title`, `staticpage`.`description` `staticpages` `staticpage` `staticpage`.`url` = 'australia' limit 1 but need search casesensitive, static url 'australia' type in case 'australia', 'australia' above query give me result. so, used binary like $this->find('first', array('fields' => array('staticpage.title', 'staticpage.description'),'conditions' => array('binary staticpage.url' => 'australia'))); its display in logs select `staticpage`.`title`, `staticpage`.`description` `staticpages` `staticpage` `binary` staticpage.url = 'australia' limit 1 so, doesn't work. how can write query usi...

javascript - JQuery Multiple onload animation loops, bug with multiple tabs -

i have issue on site developing, version of can seen @ http://hg.ipagtest.com/ ! using jquery , jcarosel slider feature on bottom of homepage , piece of jquery written former colleague of mien large image changer on top of page. page loads expected , animations work desired! issues arise when clicking between tabs. when click away tab , return it, seems though animation loop has been thrown out of whack! have seen problem in firefox 13 , in chrome 19 on windows 7, not occur ie9 far can see. i replaced code used on top image changer code show here... http://www.queness.com/post/152/simple-jquery-image-slide-show-with-semi-transparent-caption made change on dev. server not on line can't show link. produced exact same problem. i realise quite specific problem @ loss next. of pointers appreciated neal small remark replace: .linkdiv { color: #ffffff; font-size: 20px; height: 200px; // line-height: 22px; padding: 0 0 0 25px; // position...

php - how to call a sql variable in javascript selected by html onchange, canned response function -

what want able to: --- have "on change" on drop list (containing table data "titles") --- on change runs javascript function --- javascript populates text area "message" column of data in same table corresponding title being selected in drop list. <li><label for="frm_precan">canned response</label> <span class="input"> <select id="frm_precan" name="precan" onchange="updatetext();"> <option value="">--please select--</option> <?php foreach($precan_list $precan) : ?> <option value="<?=$precan['id'];?>"><?=$precan['name'];?></option> <?php endforeach; ?> </select> </s...

blackberry - How can i create custom listField? -

Image
possible duplicate: how customize listfield in blackberry? hi friend's want create custom list field. , want add image on it. thanks in advance yes, can create custom list field implementing listfieldcallback , overriding drawlistrow method. can create custom code inside of method.

amazon web services - AWS automatic failover over different region -

is possible automate failover plan on different regions in aws, example us-east , california or singapore? aws doesn't have many multi-region services, , can't fail ec2 instances different regions standard offerings. @ 2012 aws re:invent conference said prefer multi-az within single region because latency between azs low, , different azs still several miles apart, isolating them each other. they recommend using separate regions serve users in different areas. that's different failing over. failing on north america asia doesn't seem solution normal use cases. neither region serve users on opposite continent well. that said, can kind of using round-robin dns. if you've got server in california address ip1 , server in singapore address ip2, advertise address mywebsite.mydomain both ip1 , ip2. through testing i've found recent web browsers randomly try 1 address and, if can't connected to, try other one. looks pretty seamless user. you're st...

.net - SQL subquery return more that 1 value -

hi trying execute query row between number , trying rows between 10-20. using subquery can use row_number() function the query fails error: sql subquery return more 1 value so need figure way out because need more 1 resulset out of query procedure dbo.search ( @search_text varchar(max), @search_category varchar(max), @page int, @count int output ) set nocount on declare @lower_limit int = (@page-1)*10; declare @upper_limit int = (@page * 10) + 1; -- set @count =0 if @search_category='deal' begin set @count = (select count(*) dealdata dealinfo '%' + @search_text + '%' or dealname '%' + @search_text + '%' or dealdescription '%' + @search_text + '%' group dealid); select x.dealid , x.row ( select dealid,row_number() over(order dealid) row dealdata dealinfo '%' + @search_text + '%' or dealname '%' + @se...

python - matplotlib table gets cropped -

Image
i'm trying table form numpy array @ barplot bottom gets cropped, code: import matplotlib.pyplot plt import pylab p import numpy np = np.array([[ 100. , 152.84493519, 233.63122532, 263.7018431 , 259.22927686, 243.56305545], [ 100. , 147.64885749, 194.26319507, 156.2985505 , 169.1050851 , 124.84312468], [ 100. , 195.46940792, 273.37157492, 296.54100691, 271.93708044, 358.30174259], [ 100. , 216.44727433, 308.30389994, 243.70797244, 335.3325307 , 396.22671612]]) fig = p.figure() ax = fig.add_subplot(1,1,1) y = np.mean(a, axis=0) n = len(y) ind = range(n) err = np.std(a, axis=0)/np.sqrt(n) ax.bar(ind, y, facecolor='#777777', align='center', yerr=err, ecolor='black', bottom=4) ax.set_ylabel('ylabel') ax.set_title('counts, group',fontstyle='italic') tfig = 'fig 1...

why is android.os.Message not immutable -

in android.os.message, there lot of fields thread identify after receiving message. public int what; public int arg1; public int arg2; however, if change value in fields after putting message message queue, it'd affect way receiver thread handles message. why doesn't android team make android.os.message immutable? think it'll prevent android developers make mistakes. isn't better design make immutable? i have no exact answer first question (only android team has one). looks like, it's related memory/performance considerations. generally, creation of objects quite expensive, so, android suggests : the best way 1 of these call message.obtain() or 1 of handler.obtainmessage() methods, pull them pool of recycled objects. if follow android reference , use message.obtain(), won't spent time , memory on creation new message objects, re-use existing ones 'message query'. believe message made mutable, because android mobile systems...

android - Service not starting -

probably easy question guys, first attempt @ creating service should run in background when app closes. problem is: service doesnt start when click on "start service" button. don't see of toast, , nothing in logcat (no errors either). in advance! service class public class myservice extends service { private static final string tag = "myservice"; @override public ibinder onbind(intent intent) { return null; } @override public void oncreate() { toast.maketext(this, "my service created", toast.length_long).show(); log.d(tag, "oncreate"); } @override public void ondestroy() { toast.maketext(this, "my service stopped", toast.length_long).show(); log.d(tag, "ondestroy"); } @override public void onstart(intent intent, int startid) { toast.maketext(this, "my service started", toast.length_long).show(); log.d(tag, "onstart"); } } my main activity public void starts...

javascript - text disappears rapidly after click on 'submit-button' -

got problem. code: <html> <body> <form> <p>13-7: <input id="in1" type="text"" /><input type="submit" onclick="check(6, 'in1', 'out1')" value="tjek!"/></p> <p id="out1"></p> <p>20-7: <input id="in2" type="text"" /><input type="submit" onclick="check(13, 'in2', 'out2')" value="tjek!" /></p> <p id="out2"></p> <script type="text/javascript"> function check(facit, input, output) { var answer, evaluation; answer = document.getelementbyid(input).value; evaluation = (answer == facit) ? "correct" : "wrong"; document.getelementbyid(output).innerhtml = evaluation; return false; } </script> </form> </body> </html> when click submit-button, 'correct/wron...

internet explorer - Switch to web dialog box in selenium webdriver: Python -

i want handle web dialog box under selenium web driver (internet explorer) . using python in application when click on icon, web dialog box opens contains text boxes (webelements) , need click on save button after entering text. problem dont know whether focus got switched web dialog box or not. here code driver.find_element_by_xpath("//img[contains(@src,'/images/btn_add.gif')]").click() driver.switch_to_alert() driver.find_element_by_name("report_cutoff_date").sendkeys("10/31/2010") here error getting traceback (most recent call last): file "c:\users\vthaduri\workspace\ldc\test.py", line 14, in <module> driver.find_element_by_name("report_cutoff_date").sendkeys("10/31/2010") file "c:\python27\lib\site-packages\selenium-2.21.2-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 282, in find_element_by_name return self.find_element(by=by.name, value=name) file "c:\python27\lib\site-p...

encryption - GnuPG: How to encrypt/decrypt files using a certain key? -

long story short, question is: how can force gnupg private/public key use when encrypting/decrypting files? some explanation / long story i have application must encrypt files before sending them s3. users can download files using browsers website, in case must first decrypt files before serving them. client side ( delphi 2010 ): i'm going opt openpgpblackbox server side (php 5), need figure out how encrypt/decrypt files non-interactive commands. i installed gnupg on server, tried code: clear_file='/full/path/my-file.zip' encrypted_file='/full/path/my-file.zip.pgp' # encrypt file /usr/bin/gpg2 --encrypt "$clear_file" # decrypt file /usr/bin/gpg2 --decrypt "$encrypted_file" but seems can't specify, in commandline, keys use. each user have own public/private key, need able specify key use encrypt/decrypt file in question. my question is: how can force gnupg private/public key use when encrypting/decrypting files? ...

python - Getting the same context variable in two template blocks -

i have django template tag sets context variable (it gets random image model, example, lets gets random number) {% get_random_number %} {{ my_random_number }} <!-- outputs random number between 1 , 10 --> this works fine. however need same 'random' number in 2 different blocks within page: {% block block1 %} {% get_random_number %} {{ my_random_number }} <!-- outputs random number between 1 , 10 --> {% endblock %} {% block block2 %} {% get_random_number %} {{ my_random_number }} <!-- outputs random number between 1 , 10 --> {% endblock %} this doesn't work 2 different results (unless chance, they're same!) so how use templatetag set context variable that's consistent across 2 template blocks? doing doesn't work - context variable limited block it's created in... {% get_random_number %} {% block block1 %} {{ my_random_number }} {% endblock %} {% block block2 %} {{ my_random_number }} {% endblock %} so.. h...

windows - Changing date-time format in c# -

creating digital clock. i'm newbie c#. code that timelbl.text = datetime.now.tolongtimestring(); datelbl.text = datetime.now.tolongdatestring(); here is, result http://content.screencast.com/users/tt13/folders/jing/media/da6d1f65-bf5f-4735-97dc-70485112a998/2012-07-02_1826.png i got questions: can change time's format 24 hour? how? how change date digits format (like dd/mm/yyyy) or result in exact language (i mean, words "monday, july" in language, windows support, ex turkish)? how make window dynamically change it's width (depending on text length)? please me,to achieve these 3 things. thx in advance ans 1: timelbl.text = datetime.now.tostring("hh:mm:ss"); will convert time 24 hour format. ans 2: datelbl.text = datetime.now.tostring("dd/mm/yyyy"); will convert date format 31/06/2012 more formats here

running java on linux server -

Image
i run jar file extracted java project run on linux server connect through ssh tunneling. there few problems, first there wrong display: error no x11 display variable set, program performed operation requires it. @ java.awt.graphicsenvironment.checkheadless(graphicsenvironment.java:173) @ java.awt.window.<init>(window.java:437) @ java.awt.frame.<init>(frame.java:419) @ java.awt.frame.<init>(frame.java:384) @ javax.swing.jframe.<init>(jframe.java:174) @ random_v2.v2frame.<init>(v2frame.java:127) @ random_v2.wrapper.main(wrapper.java:25) and second not sure if have install other applications well. in code, java program needs run other applications weka, have install weka same directory name , specs in mac? appreciate in advance. best wishes assuming you're tunneling unix box using putty: make sure x11 forwarding enabled in putty settings.

makefile - Clang++ -c outputs files to the wrong directory -

i have makefile target contains these steps: ... cd $(graphics_build_dir) clang++ -c -i$(sfml_headers) $(graphics_dir)/*.cpp cd $(base_dir) ... for reason, clang outputs build files base_dir , not graphics_build_dir . compiles fine, , when execute 1 line @ time manually, works fine, , *.o files outputted in correct directory. why doesn't make put these files in correct directory, , how can force to? i'm using clang3.1 , current version of gnumake on ubuntu linux kernel 3.2.0-26. the trouble in make rule, each command executes in own subshell; nothing remembered 1 line next. first command starts in $(base_dir) , moves $(graphics_build_dir) , , dies. second command starts in $(base_dir) , runs clang there. try this: ... cd $(graphics_build_dir) ; clang++ -c -i$(sfml_headers) $(graphics_dir)/*.cpp ...

c++ - Segmentation fault using boost::thread -

i've written application using threads boost::thread. compiles , works fine on local machine. problem occurs on 1 of servers. i've send main.cpp file , compiled same way did on local machine: g++ -g main.cpp -o rdzen -lboost_thread ulimit -c unlimited i'm executing with: ./rdzen input.txt dictionary.txt output.txt then got: segmentation fault (core dumped) i used gdb find out reason: gdb rdzen core the backtrace is: #0 0x0804c039 in boost::detail::atomic_exchange_and_add (pw=0x53006d76, dv=-1) @ /usr/local/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:50 #1 0x0804c11a in boost::detail::sp_counted_base::release (this=0x53006d72) @ /usr/local/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:143 #2 0x0804c17c in ~shared_count (this=0xbd928a8c, __in_chrg=<value optimized out>) @ /usr/local/include/boost/smart_ptr/detail/shared_count.hpp:305 #3 0xb2b388e1 in ~shared_ptr (this=0xbd928b3c) @ ./boost/smart_ptr/shared_ptr.hpp:16...

.htaccess and Wordpress - subdirectories not rewriting -

i hosting multiple domains on single hosting account. 1 of domains using wordpress , in subdirectory (/foo), while other in main directory. have changed root .htaccess file rewrite main page of wordpress site correct domain, subsequent pages wordpress site not rewriting. example: foo.com (wordpress site) bar.com (other site in root) bar.com/foo being shown correctly foo.com....however bar.com/foo/page1 not rewriting , being shown (instead of foo.com/page1). looking rewrite , not redirect. .htaccess code i'm using in root folder below. haven't changed default .htaccess file created wordpress in bar.com/foo. missing something? appreciated. rewriteengine on rewritebase / rewritecond %{request_uri} !^/foo/ rewritecond %{http_host} ^(www\.)?foo\. rewriterule ^(.*)$ foo/$1 [l] how rewrite pages well? if want requests bar.com/foo/page1 show foo.com/page1 in address bar, need redirect (not internal rewrite have above. this: rewritecond %{http...

javascript - How to captured Selected Text Range in iOS after text selection expansion -

Image
i'm working on web app allows user select text, click button, , save highlighted text. works great in desktop browsers, (chrome example), in ios i'm having issues native text selection, user can change selected text. here jsfiddle showing issue (issue exists in ios): http://jsfiddle.net/jasonmore/gwzfb/ user starts text selection user expands text selection, , clicks "show selected text above" only first selected word " the " shows up, though want " the path of righteous man " 1 begin 2 select text , hit button 3 "the" here js using: $(function() { $('#actionbutton').click(function() { $('#result').text(selectedrange.tostring()); }); $('#slipsum').on('mouseup touchend','p', function() { getselectedrange(); }); }); var selectedrange = null; var getselectedrange = function() { if (window.getselection) { selectedrange = window.getsel...

How to know Hive and Hadoop versions from command prompt? -

how can find hive version using command prompt. below details- i using putty connect hive table , access records in tables. did is- opened putty , in host name typed- leo-ingesting.vip.name.com , click open . , entered username , password , few commands hive sql. below list did $ bash bash-3.00$ hive hive history file=/tmp/rkost/hive_job_log_rkost_201207010451_1212680168.txt hive> set mapred.job.queue.name=hdmi-technology; hive> select * table limit 1; so there way command prompt can find hive version using , hadoop version too? you can not hive version command line. you can checkout hadoop version mentioned dave. also if using cloudera distribution, directly @ libs: ls /usr/lib/hive/lib/ , check hive library hive-hwi-0.7.1-cdh3u3.jar you can check compatible versions here: http://www.cloudera.com/content/cloudera/en/documentation/cdh5/v5-1-x/cdh-version-and-packaging-information/cdh-version-and-packaging-information.html

linker - linking issue with x11 in C -

i'm trying build getpixelcolor function using x11: #include <stdio.h> #include <x11/xlib.h> #include <x11/xutil.h> void getpixelcolor (display *d, int x, int y, xcolor *color) { ximage *image; image = xgetimage (d, rootwindow (d, defaultscreen (d)), x, y, 1, 1, allplanes, xypixmap); color->pixel = xgetpixel (image, 0, 0); xfree (image); xquerycolor (d, defaultcolormap(d, defaultscreen (d)), color); } int main(int argc, const char * argv[]) { return 0; } however getting following error, seems it's during linking: undefined symbols architecture x86_64: "_xgetimage", referenced from: _getpixelcolor in main.o "_xfree", referenced from: _getpixelcolor in main.o "_xquerycolor", referenced from: _getpixelcolor in main.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) any idea issue be? under impression x11...

ASP.NET MVC 4 Web Application calls Web API -

in same solution, have mvc 4 web application project ("the site") , mvc 4 web api project ("the service"). in future, may want deploy service on separate server site. therefore, site's model class call service's web methods. is possible ? how can accomplish ? unless i'm missing something, why don't create site's model separate project in solution. site reference it. model make calls web api on httpwebrequest or similar.

Google Charts API get graph object from div -

i have drawn several graphs on webpage using google charts api. if want clear them, can use chart's clearchart() method. lets have div id="mydiv" has line chart drawn in it. clear it, have first chart objectcand call clearchart(). how chart object ? if used javascript render charts should had saved reference chart objects clear them after. if not have references have div behaving container them can remove or clear div element browser tree nodes. document.getelementbyid( 'mydiv' ).innerhtml = ''; please add additional notes clarification.

ruby - rolling back rake rails:update -

this first time trying update rails application. i ran rake rails:update , carelessly pressed y lot of questions. the routes.rb among many other things seem changed. i hoping there way bring way similar way rake rollback works. pleas advise. thanks

css - main page boxes not aligned right in Internet Explorer -

i building photo portfolio website using wordpress , editing existing theme. worked on in firefox , checked few times throughout @ styling in ie , fine. having finished looked @ today , in ie , totally messed up. none of boxes on main page lined right. i tried using code in header have ie render ie7 , worked made other little problems. not sure if problem doctype. don't know should be, or if changed along way messed up. the site works in other browsers have tried here site. http://theshalomimaginative.com/blog/ thanks. youre <h3> tags aren't closed. 1 of few instances ie rendering things correctly ;) other browsers allow make mistakes this, ie more strict. never forget value of validating code!

Does Ruby have something like Python's list comprehensions? -

python has nice feature: print([j**2 j in [2, 3, 4, 5]]) # => [4, 9, 16, 25] in ruby it's simpler: puts [2, 3, 4, 5].map{|j| j**2} but if it's nested loops python looks more convenient. in python can this: digits = [1, 2, 3] chars = ['a', 'b', 'c'] print([str(d)+ch d in digits ch in chars if d >= 2 if ch == 'a']) # => ['2a', '3a'] the equivalent in ruby is: digits = [1, 2, 3] chars = ['a', 'b', 'c'] list = [] digits.each |d| chars.each |ch| list.push d.to_s << ch if d >= 2 && ch == 'a' end end puts list does ruby have similar? the common way in ruby combine enumerable , array methods achieve same: digits.product(chars).select{ |d, ch| d >= 2 && ch == 'a' }.map(&:join) this 4 or characters longer list comprehension , expressive (imho of course, since list comprehensions special application of...

c# - Disable button when clicked and make other buttons enabled -

i have 3 buttons in wpf window best way disable button when clicked , make other 2 button enabled <button name="initialzebutton" width="50" height="25" margin="460,0,0,0" horizontalalignment="left" verticalalignment="center" click="initialzebutton_click" content="start" cursor="hand" /> <button name="uninitialzebutton" width="50" height="25" margin="0,0,64,0" horizontalalignment="right" verticalalignment="center" click="uninitialzebutton_click" content="stop" cursor="hand...

jdbctemplate - Spring JDBC connection without dataSource -

i had read several articles on obtaining connection using spring datasource. but in our company setup, connection object obtained through configured environment. following sample code: string pool = propertyfilereader.getpropertyvalue("database.properties", "development.connectionpool"); connection connection = requestutils.getconnection(pool); hence, after reading tutorial i confused on using jdbctemplate using connection object above code. i believe jdbctemplate not designed work against connection expected. workaround, if fine create separate jdbctemplate each connection created, may wrap connection in thin wrapper of datasource, , feed jdbctemplate. i think should work haven't tried anyway... class singleconnectiondatasource implements datasource { private connection connection; public singleconnectiondatasource(connection connection) { this.connection = connection; } public connection getconnection()...

Using move_uploaded_file in Magento Controller -

i new magento , creating custom module file upload in magento admin. right have post upload file in module controller. here have used move_uploaded_file upload file in same directory in controller folder. below code have used file upload in controller $file_name=$_files["file"]["name"]; $file_path="import/$file_name"; if(move_uploaded_file($_files["file"]["tmp_name"],$file_path)) { // files not uploading } i can't able upload file in directory folder. so doing wrong? or suggest me if using move_uploaded_file in magento controller correct way handle file upload ? thanks. in order upload file in magento, can use varien_file_uploader::save() method as: if(isset($_files['file']['name']) && $_files['file']['name'] != '') { try { $filename = $_files['file']['name']; $fileext = strtolower(s...

c++ - New ISO scoping rule for " for LOOP" -

i have piece of code written else before new iso come effect. the for loop in for (pa=a.begin(), i=0; pa != a.end(); ++pa) has little trouble executing because of i=0 part of syntax. also, had prefix other for loop syntaxes read for ( int .....) int before i . however, don't know how fix int i=0 in line: for (pa=a.begin ( ), i=0; pa != a.end ( ); ++pa) . please me out. ( int = 0; pa != a.end(); ++pa) *pa = ++i; (int i=0; i<10; i++) std::cout << "a[" << << "]=" << a[i] << std::endl; // int i; // note work, not want line. (pa=a.begin(), i=0; pa != a.end(); ++pa) std::cout << "a[" << i++ << "]=" << *pa << std::endl; an declaration outside for loop sensible way have 2 iteration variables of unrelated types in c++98 , later versions of language. initialiser can either single expression or single declaration, , declaration can...

ruby on rails - nested routes and form_for and models using has_one and belongs_to -

how map out has_one model nested routes , how add form_for /localhost:3000/users/1/profile/new,html.erb following restful database? user has 1 profile. models class profile < activerecord::base attr_accessible :name, :surname belongs_to :user end class user < activerecord::base attr_accessible :email, :email_confirmation, :password, :password_confirmation has_secure_password has_one :profile, dependent: :destroy end resources :users resources :profiles (note: has_one profile) resources :progress_charts resources :calories_journals end views/profiles/new.html.erb <h1>about you</h1> <div class="row"> <div class="span6 offset3"> <%= form_for(@profile) |f| %> <%= render 'shared/error_messages' %> <%= f.label :name %> <%= f.text_field :name %> <%= f.label :surname %> <%= f.text_field :surname %> <%= f.submi...