Posts

Showing posts from April, 2014

linux - RPM Post Install Execute with Python -

i'm working on deployment process work , have run bit of snag. more of quality of life thing else. i've been following hynek schlawack's excellent guide , have gotten pretty far. long , short of i'm trying install python application along deployment of python version i'm using. i'm using fpm build rpm sent , installed site. as part of deployment, i'd run post-install scripts. can specify in fpm using "--post-install {script_name}" works , when script actual linux script. however, i'd run python script post-install. can specify executable python script, fails because believe trying execute script as: bash my_python_script.py does know if there way execute python script post-install of rpm? thanks in advance! in spec file can specify interpreter %post script using -p parameter, e.g. %post -p /usr/bin/perl .

c# - Pass parameters to timer_Tick event -

i'm wanting pass parameters event timer_tick in c# don't want make them global variables. possible? i had round , came this: //where start timer lift1up.enabled = true; lift1up.tick += (sender, args) => lift1up_tick(sender, args, destination, currentfloor); lift1up.start(); private void lift1up_tick(object sender, eventargs e, int dest, int current) { //my code } many thanks! luke. yes,but not that. can define class inheriting eventargs class myeventargs : eventargs { public int dest { get; set; } public int current { get; set; } } then need manually trigger tick event , pass parameters this: lift1up_tick(this, new myeventargs { dest = 23, current = 100 }); and in tick event can arguments: private void lift1up_tick(object sender, eventargs e) { var args = (myeventargs)e; int dest = args.dest; } i don't know there better way.to (manuel trigger) can add timer.set it's interval write code inside of it's

java - Why do I keep getting this error(cannot be resolved)? -

in 1 of classes getting error: game cannot resolved or not field, , when launch application says cannot open please try again, why keep getting error, there wrong r.java? public class gameactivity extends activity { grid myview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); myview = new grid(this); myview.setgame(new game()); setcontentview(myview); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.game, menu);//error occurring here return true; }} r.java /* auto-generated file. not modify. * * class automatically generated * aapt tool resource data found. * should not modified hand. */ package com.example.applicationprogrammingassignment; public final class r { public static final class anim { public static final int slide_in_left=0x7f040000; public static final int slide_out_left=0x7f040

c - qsort compare function behaviour -

everyone. trying change compare function , okay if write sth 0 -5.5 in infile output recive (after qsort) -5.5 greater 0, , that's not true. check code , tell me should chage? int compare(const void *str1, const void *str2) { char *number1, *number2; int len1=0, len2=0, dot1=0, dot2=0, value=0; int minus1=0, minus2=0; number1 = *(char**)str1; number2 = *(char**)str2; while(*number1=='0') number1++; while(*number2=='0') number2++; while(*number1 || *number2){ if(value==0) {value= *number1-*number2;} if(*number1){ if(*number1=='-') number1++; if(*number1=='-') minus1=1; if(*number1!='.'){ number1++; if(dot1==1) len1++;} if(*number1=='.'){ number1++; dot1=0;} } if(*number2){ if(*number2=='-') number2++;

c# - XAML: Databinding to window not working after InitializeComponent() -

i'm new xaml , i'm trying bind score property of window (a backgammon board) control. i able work follows via code behind: public partial class bgboard : window { public bgboard() { initializecomponent(); datacontext = this; _score = 999; } private int _score; public string score { { return _score.tostring(); } } } xaml <window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:system;assembly=mscorlib" xmlns:bgb="clr-namespace:backgammonboard" xmlns:properties="clr-namespace:backgammonboard.properties" x:class="backgammonboard.bgboard" title="backgammon board" width="750" height="500" minwidth="375" minheight="250"> <textblock x:name="player_score" text="{bi

java - How to execute query of multiple statements as one? -

i came around obstacle . following statement not execute because string query contains multiple statements . string query="create volatile table test1 (etc . ); select top 10 * test1; "; string driver = "com.xxx"; string conurl="jdbc:ccc"; class.forname(driver); connection conn = drivermanager.getconnection(conurl,user,password); preparedstatement stmt=conn.preparestatement(query); the last line throws error data definition not valid unless solitary it cumbersome split query multiple preparedstatements is there other way execute query containing multiple statements 1 ? you use jdbc batch processing (addbatch, executebatch), allows "stack" statements , send them db engine executed @ once. here starting point: http://viralpatel.net/blogs/batch-insert-in-java-jdbc/ but still need split separate statements, , add them 1 @ time. java: splitting comma-separated string ignoring commas i

xcode - Unable to authenticate the package: 805904647.itmsp -

when submit app application loader i'm putting in compressed game right clicked , compressed because will'nt let me click archive button in xcode. these errors unable authenticate package: 805904647.itmsp error itms-9000: "no .app bundles found in package" @ softwareassets/softwareasset (mzitmspsoftwareassetpackage) can please me fix xcode project can put in application loader i have problem developing apps in xcode 7.3.1 os x el capitan , update macos sierra , xcode 8. i can solve problem following next steps: archive app xcode 7.3.1 (download in developer.apple.com) when archived app, find archive in organizer, , then: "show in finder"; "show package contents"; in "xx.xcarchive" file, find "products"-"applications"-"xx.app"(xx app's name), "show package contents" again; finally, can see there has file named"info.plist", open it; edit value key nam

symfony - Change format of date with Symfony2 -

how can insert new \datetime() jj-mm-aaaa format symfony2 ? or if impossible how show in format in twig n what using date twig filter , {{ yourdatetimeobject|date("d-m-y") }}

sage - Suppress the extra white space from compiling in R -

whenever compile r code, lot of white spaces clog worksheet. is there way suppress this, without changing code on same line using semicolons? i'm working in sage worksheets , on cloud. i've made changes reduce whitespace in r mode sagemathcloud ( https://cloud.sagemath.com ); restart project update. however, due how sage works might not sufficient. if evaluate following in cell (in sage mode, or put %sage @ top), eliminate lot of additional whitespace in %r mode. def r_eval0(*args, **kwds): return sage.interfaces.r.r.eval(sage.interfaces.r.r, *args, **kwds).strip().replace('\n\n','') sage_salvus.r_eval0 = r_eval0

vector - Pushing element at back of vec in armadillo -

how can push element @ end of vector in vec of armadillo? performing adding , removing element in sorted list in loop. expensive thing. way doing in case of removing element vec x vec x_curr as: x_curr = x(find(x != element)) however not trivial in case of adding element in loop. x_curr = x; x_curr << element; x_curr = sort(x_curr); this not correct. in addition not efficient. efficient way in armadillo. other stl library solution. using in rcpp armadillo. can perhaps sorting every loop. x_curr used store of indices of column of arma::mat i.e. going use mat.col(x_curr). i don't understand question. armadillo math library, operates on vectors . if not know size, allocate guessed n elements , resize in common 'times two' idiom needed, , shrink @ end. if know size, have no problem. the stl has so-called generic containers , algorithms, not linear algebra. need figure out need most, , plan implementation accordingly.

durandal 2.0 - How to close all open durandaljs modal dialogs -

currently working on project relies heavily on modal dialogs. i'm using durandal's dialog plugin. problem have within modal, user can click element displays details in modal. what close open modals before open new modal. can give me idea of how can ensure single dialog open @ given time in durandaljs? why not use durandal's pub/sub, or client-side message bus such postal.js (which use)? close modals sending close message on channel 'app' , topic 'app/modals'. instead of holding reference observable (which have memory implications), hold reference message channel (which string). cleaner way go.

c++ - Box2d - Problems calculating impulse with speed and angle -

i have weapon bounces next enemy when hits. i first begin calculating delta , getting angle: float deltax = e->m_body->getposition().x - m_body->getposition().x; float deltay = e->m_body->getposition().y - m_body->getposition().y; float angle = atan2((deltay), deltax) * 180 / m_pi; then convert angle vector , multiply 15 (the speed of projectile): b2vec2 vec = b2vec2(cos(angle*m_pi/180),sin(angle*m_pi/180)); vec *= 15.0f; finally, apply impulse body: m_body->applylinearimpulse(vec, m_body->getposition()); the problem vector must incorrect bullet not go in right direction. if output angle next enemy, tends output angle looks correct problem must in conversion vector. i don't think need use trigonometry functions here, because have direction: b2vec2 direction = e->m_body->getposition() - m_body->getposition(); direction.normalize(); // vector has length 1 float speed = ...; m_body->applylinearimpulse( speed * directio

asp.net web api - OData $orderby clause on collection property -

i have following classes : public class parent { public string parentprop { get; set; } public ienumerable<child> manychildren { get; set; } } public class child { public string childname { get; set; } public int value { get; set; } } say have odata operation defined returns ienumberable<parent> . can write $orderby clause performs following operation ('parents' ienumerable<parent> ) : parents.orderby(x => x.manychildren.single(y => y.childname == "child1").value); i know can write custom actions ( http://msdn.microsoft.com/en-us/library/hh859851(v=vs.103).aspx ) ordering me, i'd rather use $orderby clause. (the question asked similar little dated - how can order objects according attribute of child in odata? ) as tried possible nesting $orderby in $expand be: odata/user?&$select=active,description,name,userid&$expand=company($select=active,name,createdby,companyid;$orderby=active

python - QDialog.show() method has a delayed reaction -

i have problem can't quite figure out time. have main window application , qdialog should pop out after clicking 1 of buttons, show() method on qdialog seems waiting funcion connected "clicked()" signal end! want dialog show right after calling qdialog.show() method, not after other code instructions in function... of course in code going replace sleep(5) part more complicated code, pictures problem , code put there irrelevant issue, think (database connections , updates) being more specific: # -*- coding: utf-8 -*- import sys import pyqt4 pyqt4 import qtcore, qtgui twython import twython, twythonerror project import ui_mainwindow time import sleep import psycopg2, globalvals, updater import updating, noconnection class upwindow(qtgui.qdialog): def __init__(self, parent=none): qtgui.qdialog.__init__(self, parent, qtcore.qt.windowstaysontophint) self.ui = updating.ui_updating() self.ui.setupui(self) class noconnection(qtgui.qdialog):

java - Jetty Seems to Ignore Port Argument -

i'm working through spring mvc examples, , using jetty jetty-9.1.1.v20140108 dev server. have server, jboss 5.1.0 listening on port 8080, tried specify alternate port jetty, however, didnt seem "stick". doing wrong here? $ java -djetty.port=9000 -jar start.jar ... info: frameworkservlet 'spring-example': initialization completed in 142 ms 2014-02-05 17:27:50.369:info:oejsh.contexthandler:main: started o.e.j.w.webappcontext@45ad71f0{/spring-example,file:/tmp/jetty-0.0.0.0-8080-spring-example.war-_spring-example-any-1672792505692467455.dir/webapp/,available}{/spring-example.war} 2014-02-05 17:27:50.374:warn:oejuc.abstractlifecycle:main: failed serverconnector@228643af{http/1.1}{0.0.0.0:8080}: java.net.bindexception: address in use java.net.bindexception: address in use @ sun.nio.ch.net.bind0(native method) @ sun.nio.ch.net.bind(net.java:444) @ sun.nio.ch.net.bind(net.java:436) @ sun.nio.ch.serversocketchannelimpl.bind(serversocketchannelimp

visual studio - C++: Iterate Through Map -

i'm trying iterate through map read out string , of numbers in vector file. copied , pasted typedef line, adjusted code, i'm not positive it's correct. anyways, visual studio giving me errors on use of iterator_variable in loops. says type name not allowed. how can fix this? ofstream output("output.txt"); typedef map<string, vector<int>>::iterator iterator_variable; (iterator_variable iterator = misspelled_words.begin(); iterator != misspelled_words.end(); iterator++) { output << iterator_variable->first; (int = 0; < misspelled_words.size(); i++) { output << " " << iterator_variable->second[i]; } output << endl; } you should access iterator iterator->first instead of iterator_variable->first . and inner loop, want iterate through 0 iterator->second.size() instead of misspelled_words.size() . ofstream output("output.txt"); typedef map<strin

python - Why do my Tkinter widgets get stored as None? -

i'm putting buttons array when call them not there. if print out array get: {0: none, 1: none, 2: none, 3: none, 4: none, 5: none, 6: none, 7: none, ...} i don't know doing wrong. from tkinter import * def main(): pass if __name__ == '__main__': main() b={} app = tk() app.grid() f = frame(app, bg = "orange", width = 500, height = 500) f.pack(side=bottom, expand = 1) def color(x): b[x].configure(bg="red") # error 'nonetype' object has no attribute 'configure' print(b) # 0: none, 1: none, 2: none, 3: none, 4: none, 5:.... ect def genabc(): r in range(3): c in range(10): if (c+(r*10)>25): break print(c+(r*10)) b[c+(r*10)] = button(f, text=chr(97+c+(r*10)), command=lambda a=c+(r*10): color(a), borderwidth=1,width=5,bg="white").grid(row=r,column=c) genabc() app.mainloop() the grid , pack , , place methods of every tkinte

java - Is it possible to add goals to a specific maven command? -

i want execute maven mvn android:instrument mvn test. possible? can me specify changes have pom? <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.sample.projectfoundation</groupid> <artifactid>androidsdktest</artifactid> <version>1.0.0-snapshot</version> <packaging>apk</packaging> <name>androidsdktest</name> <dependencies> <dependency> <groupid>com.sample.projectfoundation</groupid> <artifactid>androidsdk</artifactid> <version>0.0.1-snapsho

Editing HTML content in native iOS app -

is there way allow editing of html content in native ios application? for example, if building email app , want allow replying email , editing original message. needs pretty support valid html, including images, styles, etc. i've tried contenteditable uiwebview using nsattributedstring uitextview , neither solutions - uiwebview not have way manage content or cursor position, , uitextview not render html includes images , other elements. unless you're willing show textarea html code, think way go mobile rich text editor toolbar , stuff, because contenteditable uses shortcuts crtl + b right?! check out these 2 guys mobile browsers: http://mindmup.github.io/bootstrap-wysiwyg/ http://imperavi.com/redactor/ update for native apps may try: http://www.omnigroup.com/omnioutliner https://github.com/aryaxt/ios-rich-text-editor http://www.cocoanetics.com/parts/dtrichtexteditor/ https://github.com/enormego/egotextview

java - location of specific function in Junit source -

junit 4.x not provide private methods have test methods generated them. looking in junit source code (downloaded github) enforced in code not able locate it. did find checks test methods public, looking either explicitly checks target class's methods' modifiers or otherwise omits or skips processing private methods of target class. know code might located? addendum: ok so, we've been having nice little chat on , here's what's been learned. suppose have class foo 2 methods, bar , baz, both private. ordinarily using combination of ide , junit4.x cannot make junit generate test stubs these methods on account of being private. rule "do not generate test stubs private methods" enforced @ level of ide , not part of junit per se. so class this: public class foo { private void bar(){} private void baz(){} } you can't generated: public class footest{ @test public void testbar(){} @test public void testbaz(){} } but

jQuery Backstretch not resizing -

i have backstretch initializing once page loaded. after that, have event method changes background image backstretch. once event runs backstretch no longer resize other elements except 1 has been updated. does backstretch have single event instance window resizing? if there can fix this? thanks! example: $('body').backstretch('woot.jpg'); $('#menu-home').backstretch('dog.jpg'); $('#menu-about').backstretch('cat.jpg'); $('#menu-contact').backstretch('iguana.jpg'); $('#menu-home').on('click', function(){ $('body').backstretch('dog.jpg'); }); i use backstretch in 1 div takes visible area of browser, can scroll down , rest of page doesn't have background. adjust on windows resize found no other way using javascript: window.onresize = homepageresize; function homepageresize() { $('#landingtop').css({ 'height': ($(window).innerheight()) + 'p

r - Solve and find x for normally distributed functions -

i'm trying solve equation , find value x it. i'm using following code: mu1 = 0 mu2 = 1 sigma1 = 0.5 sigma2 = 0.6 prior1 = 0.3 prior2 = 0.7 boundary = function(x) { return(( 1 / sqrt(2 * pi * sigma1)) * exp(-0.5 * ((x - mu1) / sigma1)^2)*prior1) - ((1 / sqrt(2 * pi * sigma2)) * exp(-0.5 * ((x - mu2) / sigma2)^2)*prior2) } uniroot(boundary, c(-1e+05, 1e+07)) this not give me correct answers. i'm pretty new r , not sure how uniroot works. is there better way solve equation? are there packages available solve (similar matlab's solve() function)? you can shorten code little bit (and minimize chance of typos) using built-in dnorm() function: curve(dnorm(x,mean=0,sd=0.5),from=-4,to=4) curve(dnorm(x,mean=0,sd=0.6),add=true,col=2) if try uniroot() on reasonable range, sensible answers: uniroot(function(x) dnorm(x,0,0.5)-dnorm(x,0,0.6), c(0,5)) ## 0.546 uniroot(function(x) dnorm(x,0,0.5)-dnorm(x,0,0.6), c(-5,0)) ## -0.546 if try start h

One Month Rails | Image Upload with Paperclip - missing image -

i following 1 month rail course , have problem: used paperclip gem take care of image uploading. followed instructions; however, when upload image, not display correctly, instead display missing image screenshot of chrome console: https://dl.dropboxusercontent.com/u/2570626/screen%20shot%202014-02-06%20at%209.51.13%20am.png my github folder is: https://github.com/phanatuan/pinteresting really appreciate help, tuan in pins/_form.html.erb partial mistyped file_field :image replace: <div class="field form-group"> <%= f.label :image %> <%= f.file_field :image, class: 'form-control' %> </div> everything else ok.

How not to affect the original cloned git repository -

i have cloned repository , in there .git directory. i'm worried if commit, commit original repository , don't want happen. there way can it, not affect original repository i've cloned from. thanks in advance. edit: did maintain repository below: cd /path/to/my/local_repo git remote add origin my_repo_link git push -u origin --all you affect original or remote repository if use push command. git different svn in have complete local repo. can commit repo want because different repo. when push asking local repo svn style commit of whatever have changed in local repo remote (original) repo. if want clone 1 repo , push different remote repo you'll need change remote branch local branch pointed at. how change remote git branch tracking?

c# - How can i create a pictureBox manually to be exactly between two panels on form1? -

Image
my form1 size 800,600 have 2 panels in form1 designer: panel1 @ location: 0,24 size: 200,437 panel2 @ location: 584,24 size: 200,437 the result 2 panels @ each side of form. did in program when put mouse somewhere in form1 area showing picturebox create in form1 constructor: pb = new animatedpicturebox.animatedpictureboxs(); pb.visible = false; pb.size = new size(500, 350); pb.location = new point((clientsize.width - pb.width) / 2, (clientsize.height - pb.height) / 2); the problem new picturebox variable pb not in size fill area between 2 panels. want size of picturebox fill space between 2 panels width , height maybe leave space 5 spaces each side there border. how can calculate picturebox size should ? edit** this image program working regular. on each panel on left , right added 4 pictureboxes. when move mouse cursor inside 1 of pictureboxes area showing content in larger picturebox in middle. and how looks when put mouse cursor in 1 of pictureboxes area pic

avd - getting aapt error in android while running the program -

Image
i getting error message frequently i installed components perfectly i encountered same problem couple of days back. not sure if solution work too, give try, if symptoms same. 1. have antivirus moved aapt.exe quarantine. hence check settings of antivirus if have one, , place folder contains aapt.exe (that means versions) exclusion folder. 2. once done, if antivirus complains aapt wants modify things , may harm system, select watch if have such option (or allow, , keep under watch). 3. , build project again. hope helps , works too.

mysql - order by sql query error -

$post_items = $db->query("select post_id,content,date,category_id post_items join user on(post_items.user_id = user.user_id) post_items.user_id =" . $userid) how can include order in case? tried $post_items = $db->query("select post_id,content,date,category_id post_items join user on(post_items.user_id = user.user_id) post_items.user_id =" . $userid ."order post_id"); please, apply space between field , order keyword, , use tablename if columnaname ambiguse in query use join : $post_items = $db->query("select post_id,content,date,category_id post_items inner join user on post_items.user_id = user.user_id post_items.user_id =" . $userid ." order post_items.post_id ");

rights - How to enable/disable hibernate feature on windows 7 at user level -

i have 2 users in pc. want user account have hibernate feature enabled disabled in other user. have tried powercfg -h off admin mode disables feature users. also free disk space. the hiberfil.sys hidden system file located in root folder of drive operating system installed. windows kernel power manager reserves file when install windows. size of file approximately equal how random access memory (ram) installed on computer. the computer uses hiberfil.sys file store copy of system memory on hard disk when hybrid sleep setting turned on. if file not present, computer cannot hibernate. to make hibernation unavailable, follow these steps: click start, , type cmd in start search box. in search results list, right-click command prompt, , click run administrator. when prompted user account control, click continue. at command prompt, type powercfg.exe /hibernate off, , press enter. type exit, , press enter close command prompt window.. to make hibernation avail

forms - installing oracle fusion middleware(11G) in windows 8(Formsweb.cfg location issue) -

i have installed oracle 11g ( oracle 11.2.0.1) database in windows 8 (64 bit processor) desktop successfully.for learning purpose,i tried installing oracle 11g forms , reports.as first step,installed oracle fusion middleware( weblogic 10.3.6 ) , used 64 bit jdk ( jdk 6- 1.6.0_35) installation.after that,installed oracle forms & reports (oracle forms 11.1.2.2)-all installed in same machine.i able complete installation , started developing basic form layout , compiled it.but while running in firefox,i getting missing plug in error(unable find suitable plugin).by going through page source info,i understood pointing different jdk version.(i have attached page source) after reading many posts,i understood changing parameters in formsweb.cfg file can make difference.but while searching ,i find formsweb.cfg in different folder. mw_home/user_projects\domains\classicdomain\config\fmwconfig\servers\adminserver\applications\formsapp_11.1.2\config i read many posts present in $domain_h

c# - Protocol Buffers NET to serialize a SortedDictionary<CustomTKey, CustomTValue>? -

are there known issues when using protobuf.net sorteddictionary? specifically, we're using sorteddictionary<customtkey, customtvalue> (with appropriate icomparer<customtkey> implementation that's unrelated protobuf.net's focus) it's passing basic tests @ our end wanted know if there known issues or concerns watch out for. if works, working extend in general manner other types collection classes in bcl (eg: dictionary, sortedlist etc)? know sure works list s! protobuf-net tries avoid coding specific collection types, , instead tries detect key patterns ; in particular, looks ilist , icollection<t> , or custom iterator , add(foo) , getenumerator() returns iterator .current of type foo . sorteddictionary<tkey,tvalue> implements icollection<keyvaluepair<tkey, tvalue>> , protobuf-net detects , uses; library treats collection of key-value-pairs, calling .add etc. keyvaluepair<tkey,tvalue> treated again patte

struts2 - how we can add one by one row in table by using struts -

i want show data in tabular format when click add button 1 one keep adding in table . use struts 2 not ajax , jquery. home.jsp <%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> <%@ taglib prefix="s" uri="/struts-tags"%> <%@ taglib prefix="sx" uri="/struts-dojo-tags"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> </head> <body> <table> <tr> <td><s:textfield label="sainumber" name="stockcreationbean.sainumber" /></td> <td><table><tr><td><sx:datetimepicker name="stockcreationbean.said

c# - ASP.Net MVC 4 I need to Delay execution -

i have asp.net mvc 4 application periodically calls external api information (resource). resource has rate limiter account (meaning other apps use same pool , may hit limit). when limit hit, send http status code 429 header of "retry-after" in seconds (lets 25 seconds). if app gets response, need delay execution 25 seconds , retry. first off, let me method code running under asp.net 4.5 async method. this, thinking using system.threading.thread.sleep(25000) now, don't use this, there better way of doing this? i have apologize open ended question, couldn't find on proper way of delay execution (while keeping things async , making sure don't run out of threads) update: following code better delay? await task.run(() => thread.sleep(10000)) you shouldn't use thread.sleep because blocks thread amount of time server less scalable. should instead use task.delay waits asynchronously without blocking thread: await task.delay(10000) ta

java - SQLite JDBC and SQLite version -

i downloaded jdbc driver sqlite-jdbc4-3.8.2-snapshot.jar from https://bitbucket.org/xerial/sqlite-jdbc/downloads after included eclipse project via configure build path and afterwards ran code: public class sqliteinput { public static void main(string[] args) throws exception { newdb(); } public static void newdb () throws classnotfoundexception, sqlexception{ try{ class.forname("org.sqlite.jdbc"); connection con = drivermanager.getconnection("jdbc:sqlite:newdb.db"); con.close(); }catch(exception ed) { system.out.println("error --> " + ed); } }} which creates new database-file called newdb.db but if open file firefox sqlite manager , run code: select sqlite_version() 'sqlite version'; it returns: sqlite version - 3.7.

hadoop - How do I read a block from a specific replica in HDFS? -

i need write program pulling out blocks in hdfs from specific data node given file. not run within mapreduce job, pro grammatically gathering statistics on cluster. so far, given file, have been able extract block locations associated file. each block there multiple replicas , need access blocks lying on replica. understand these remote read operations. i have done following: configuration conf = new configuration(); filesystem fs = filesystem.get(conf); path infile = new path(args[0]); filestatus status = fs.getfilestatus(infile); blocklocation[] locs = fs.getfileblocklocations(status, 0, status.getlen()); string[] hosts = locs[0].gethosts (); could tell me how can fetch block pointed locs[0] hosts[0] ?

javascript regex: `foo` -> **foo**? -

basically, hack markdown engine own website. now, i'm trying convert string wrapped single ` `foo` to **foo** using regex , far, can think of var data = data0.replace(/`.*`/g, '...'); and obviously, not work intend. and markdown has ``` ``` format, , want untouched- exclude regex match. can advise regex be? thank you. this attempt @ simple, clean regex: regex string `\b(.*?)\b`(?!`) replace string **$1** online demonstration regex101

c# - Event Paint Crash When Scrolling and Draw in TopLeftHeader datagridview -

Image
i have problem eventpaint in datagridview . eventpaint crashed when datagridview scrolling, , image show in topleftheader in datagridview . how can solved it? sorry can't show code. using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using system.globalization; using system.configuration; using system.data.sqlclient; using system.reflection; using system.diagnostics; namespace mdacs_aop_cfstl { public partial class mainformactivity : form { public string parameternamakaryawan { get; private set; } public string parametersesi { get; private set; } public datetime parametertanggal { get; private set; } public string headercell; public string headerrow; public string hari = ""; karyawan mykaryawan = new karyawan(); activity myactivity = new activity();

How to generate an animated gif within Codename One -

i wanting generate animated gif in codename one. combine user supplied image text transition across image in way. assume need create seperate images text , combine them user image. possible codename 1 , if so, how go it? codename 1 supports adding animated gif using add animation option in images section in designer. however, sounds looking achieve text transitions. suggest @ container.replace() , animatelayout() . can see samples of using them both in kitchen sink demo under effects , layouts.

java - Creating and chaining LinkedList in for loop -

i trying create new linkedlistnode object parse through char[] in reverse. want link these char[] totalnum = (total + "").tochararray(); (int = totalnum.length; > 0; i--) { linkedlistnode sum = new linkedlistnode(totalnum[i]); sum.next = null; } here linkedlistnode class: public class linkedlistnode { int data; public linkedlistnode next; // constructor public linkedlistnode(int newdata) { this.next = null; this.data = newdata; } } i wondering how can go doing this. new java has gotten me stumped! know should create new linkedlistnode object in each iteration far have gotten public class linkedlistnode { int data; private linkedlistnode next; public linkedlistnode(int data) { this.data = data; } public void setnext(linkedlistnode next) { this.next = next; } public linkedlistnode getnext() { return next; } } char[] totalnum =

Azure worker role.Sharepoint client sdk -

i using azure worker role , sharepoint 2013 client components access sharepoint lists , process them. works on development environment when upload azure cloud service. cannot create clientcontext. , error. catastrophic failure (exception hresult: 0x8000ffff (e_unexpected)) i have installed sharepoint 2013 client components remoting worker role machine. this worker role hence can't implement solutions app pool permissions :| any great! thank you. solved myself. for needs access registry or tasks require permissions.this might helpful just add following line worker .csdef file, workerrole tag <runtime executioncontext="elevated"></runtime> that should it.

javascript - remove item in ng-repeat using particular id -

assume got id, correct way of removing item of list? don't think because doesn't work. tried: $scope.postitem.splice(id, 1); my partial html , js here http://jsfiddle.net/jk7rb/ i don't understand $index method, post_id instead. it's easier because can straight away remove item id in backend. using jquery use remove method this: $('#your_id').remove();

php - How to fetch specific fields from array using file_get_contents -

i want fetch player fields: e.g id,name,tag,plat etc i have type of data: stdclass object ( [player] => stdclass object ( [id] => 179203896 [game] => bf4 [plat] => pc [name] => helltime [tag] => dk [datecheck] => 1391437377733 [dateupdate] => 1391437377733 [datecreate] => 1386696304438 [lastday] => 20140117 [country] => [countryname] => [rank] => stdclass object ( [nr] => 73 [imglarge] => bf4/ranks/r73.png [img] => r73 [name] => chief warrant officer 5 iii [needed] => 4920000 [next] => stdclass object ( [nr] => 74 [img] => r74

php - How to active the menu of modules in yii -

i'm trying active menu of modules in yii array( 'label'=>'manage news/events', 'url'=>array('/newsevent/newsevent/admin'), 'active'=> ((yii::app()->controller->id=='newsevent') && (in_array(yii::app()->controller->action->id,array('update','view','admin','index')))) ? true : false ), ), i've got news event module in side modules folder , trying active menu not happening

java - Finding out what the NewSize is from code -

is possible display java newsize parameter same way can find heap size? i know heap size can found using: runtime.getruntime().maxmemory(); is there similar newsize? you want memorypoolmxbean numerical values of eden space , survivor space: for(java.lang.management.memorypoolmxbean memorypoolmxbean :java.lang.management.managementfactory.getmemorypoolmxbeans()) { system.out.println(""); try { system.out.println("poolname\t" + memorypoolmxbean.getname()); system.out.println("commited\t" + memorypoolmxbean.getcollectionusage().getcommitted()); system.out.println("init\t" + memorypoolmxbean.getcollectionusage().getinit()); system.out.println("max\t" + memorypoolmxbean.getcollectionusage().getmax()); system.out.println("used\t" + memorypoolmxbean.getcollectionusage().getused()); } catch (nullpointerexception npex) { npex.printstacktrace()

c# - How do I implement caching in an immutable way? -

i've read , heard lot of things immutability , decided try out in 1 of hobby projects. declared of fields readonly, , made methods mutate object return new, modified version. it worked great until ran situation method should, external protocol, return information object without modifying it, @ same time optimized modifying internal structure. in particular, happens tree path compression in union find algorithm . when user calls int find(int n) , object appears unmodified outsider. represents same entity conceptually, it's internal fields mutated optimize running time. how can implement in immutable way? short answer: have ensure thread-safety yourself. the readonly keyword on field gives insurance field cannot modified after object containing field has been constructed. write can have field contained in constructor (or in field initialization), , read through method call cannot occur before object constructed, hence thread-safety of readonly . if want