Posts

Showing posts from 2013

java - I am trying to build a sample App from a Third Party SDK. I am getting a class not found exception and I am not able to figure out why? -

below logcat : 06-26 21:31:41.352: d/androidruntime(9911): shutting down vm 06-26 21:31:41.352: w/dalvikvm(9911): threadid=1: thread exiting uncaught exception (group=0x4114b930) 06-26 21:31:41.372: e/androidruntime(9911): fatal exception: main 06-26 21:31:41.372: e/androidruntime(9911): java.lang.runtimeexception: unable instantiate application com.counterpath.sdkdemo.audiocall.phoneapp: java.lang.classnotfoundexception: didn't find class "com.counterpath.sdkdemo.audiocall.phoneapp" on path: /data/app/com.counterpath.sdkdemo.audiocall-1.apk 06-26 21:31:41.372: e/androidruntime(9911): @ android.app.loadedapk.makeapplication(loadedapk.java:504) 06-26 21:31:41.372: e/androidruntime(9911): @ android.app.activitythread.handlebindapplication(activitythread.java:4364) 06-26 21:31:41.372: e/androidruntime(9911): @ android.app.activitythread.access$1300(activitythread.java:141) 06-26 21:31:41.372: e/androidruntime(9911): @ android.app.activitythread$h.handle

javascript - using setTimeout to execute function excatly at specified time -

here code below.. settimeout(executequery, 5000); iam aware executequery run after 5 second... want run @ e.gethours()+':'+e.getminutes() console.log(e.gethours()+':'+e.getminutes()); display 1:30 ,iam trying run a function today @ 1:30 anyways fix this??? set date , time when want run function using new date(year, month, day, hours, minutes, seconds, milliseconds); . current new date() , , substract difference in milliseconds count, assign settimeout function. see following snippet:- window.onload=function(){ var date1=new date(); var date2=new date(2014,05,27,11,45,00); var diff=date2.gettime()-date1.gettime(); settimeout(executequery, diff); } function executequery(){ alert("hello"); } fiddle

Why I cannot prompt for a variable that will be shared by multiple plays (ansible 1.6.5) -

i have distilled playbook has 3 plays. goal collect database password prompt in 1 play , use same password in other 2 plays. --- - name: database password hosts: - webservers - dbservers vars_prompt: - name: "db_password" prompt: "enter database password databse user root" default: "root" - hosts: dbservers tasks: - command: echo {{db_password | mandatory }} - hosts: webservers tasks: - command: echo {{db_password | mandatory }} it fails shown below. enter database password databse user root [root]: play [database password] ****************************************************** gathering facts *************************************************************** ok: [vc-dev-1] play [dbservers] ************************************************************** gathering facts *************************************************************** ok: [vc-dev-1] task: [command echo {{db_password | mandatory}}] **

perl - Net::OpenSSH::Gateway->find_gateway fails when ControlPersist option is set -

Image
i trying create persistent gateway connection using net::openssh::gateway. below code snippet using same. my %proxy_opts = ( host => $host, port=>$port, password=>$password, user=>$user , scheme=>"ssh", ssh_cmd => '/usr/bin/ssh', master_opts => [ -o=>"stricthostkeychecking=no", -o=>"tcpkeepalive=no", -o=>"serveraliveinterval=30", -o=>"serveralivecountmax=90", -o=>"controlpath=/tmp/ssh-master-%h_%p_%r", -o=>"controlpersist=yes" ] ); %gateway_settings = ( proxies=>[ {%proxy_opts} ]); $gateway = net::openssh::gateway->find_gateway(%gateway_settings, errors=>$errors); i error below. if remove option controlpath , controlpersist entire thing works fine. [error ] unable establish master ssh connection: bad ssh master @ /root/.libne

Python enum implementation -

this question has answer here: how can represent 'enum' in python? 43 answers i have declared enum follows in python.i don't know how use them.when create instance of class gives error 2 arguments required 1 given. class cbarreference(enum): thisbar = 0, nextbar = 1, undefined=2 a=cbarreference() i know error don't know give second argument other self. you should never have create instance of enum; they're accessed directly class, , can assign them variables like: a = cbarreference.thisbar b = cbarreference.nextbar c = cbarreference.undefined d = cbarreference.thisbar assert(a == d) assert(b != a) assert(b != c)

python - Why do I only get the last value of a for loop in view in django? -

lets say: y = [go, cat, jump, see] if did: view: x in y: x template: {{x}} i x=see , no other result, 1. why that? 2. how can make work? know doing in template works need values each item in array or dicitonary (unless, done in template too). thoughts? edit. have this: session = {4,5,6,7,} saved in session, comes form full of check box choices, primary keys. views: form = inlinefactory_formset(model1, model 2,extra = len(sesssion) formset = form(instance=none ) in views have {% x in session%} {{x}} {{formset}} {%endfor%} so prints number , form number. want, x pk mentioned above, want use pk name x instance , print form people know form editing. inside loop x updated. after has run value of x last value in list. what want loop through in template: {% x in y %} {{ x }} {% endfor %}

multithreading - Process is a thread or thread is a process? -

i asked interview question. replied thread process after thinking process superset of thread interviewer didn't agree it. confusing , i'm not able find clear answer this. a process executing instance of application. a thread path of execution within process. also, a process can contain multiple threads . 1. it’s important note thread can process can do. since process can consist of multiple threads, thread considered ‘lightweight’ process. thus, essential difference between thread , process work each 1 used accomplish. threads used small tasks, whereas processes used more ‘heavyweight’ tasks – execution of applications. 2. another difference between thread , process threads within same process share same address space, whereas different processes not. allows threads read , write same data structures , variables, , facilitates communication between threads. communication between processes – known ipc, or inter-process commun

css - How to combine slide-in panels with sticky header? -

i'm working on css-based 3-column layout has following requirements: on desktop… …all columns shown. on mobile devices… …only middle column shown. …the left column can slide in left, triggered swipe or tap on button. …the right column can slide in right, triggered swipe or tap on button. independent of device… …the middle column contains 3 rows: main header, sub header, , actual content. …the main header scrolls away when scrolling down. …the subheader sticky on top of screen when scrolling down. now tried implement this: creating 3-column layout , hiding left , right columns easy, using bootstrap. having 3 rows in middle column easy, too. to make subheader sticky, have 2 options: use position: sticky (best solution in technical terms, not supported browser). use script, attach scroll event , change position: fixed on demand. bootstrap offers ootb affix plugin. using plugin, it's easy task, too. creating 2 sidebars , sliding them in easy w

java - Calling repaint for specific JPanel in JFrame repaints also JDialog -

below small example describe well, have simple jframe jpanel contentpane repaint swingworker every 20 ms panel.repaint() . also, have jdialog opened shows own graphics opengl (i use awtglcanvas lwjgl library) swaps buffers , repaint() every time paint content (faster 20ms). the big problem in way repainting jpanel affects jdialog meaning if remove panel.repaint() (which have done) works fine! when have panel.repaint() jdialog shows strange lines have cut graphics in 2 , try move them no success. dont know if call flicker may problem. public testframe(){ panel = new jpanel(){ protected void paintcomponent(graphics g){ //do painting jpanel here } } setcontentpane(panel); updatetime(); } public void updatetime(){ swingworker worker = new swingworker(){ @override protected object doinbackground() throws exception { while(stoptimer == false){ thread.sleep(20);

java - RandomIterator not producing random outputs -

public static void main(string args[]) { // build queue containing integers 1,2,...,6: randomizedqueue<integer> q= new randomizedqueue<integer>(); (int = 1; < 7; ++i) q.enqueue(i); // autoboxing! cool! // print 30 die rolls standard output stdout.print("some die rolls: "); (int = 1; < 30; ++i) stdout.print(q.sample() +" "); stdout.println(); // let's more serious: behave die rolls? int[] rolls= new int [10000]; (int = 0; < 10000; ++i) rolls[i] = q.sample(); // autounboxing! cool! stdout.printf("mean (should around 3.5): %5.4f\n", stdstats.mean(rolls)); stdout.printf("standard deviation (should around 1.7): %5.4f\n", stdstats.stddev(rolls)); // let's @ iterator. first, make queue of colours: randomizedqueue<string> c= new randomizedqueue<string>(); c.enqueue("red"); c.enqueue("blue"); c.enqueue(

unity3d - https://api.parse.com/crossdomain.xml not found error -

i'm using parse platform unity3d game development. , receive 404 not found error when i try run game in safari web player on facebook canvas. looking console gave me error 404 on https://api.parse.com/crossdomain.xml but same thing works on chrome , firefox, though when try open xml file directly using url in chrome incognito still can't found. has met or knows how fix ? thxs. could error on parse's side? i'm getting same issue, never seen before. looks file doesn't exist.

ios - How do you add a UICollectionViewController to a UIScrollview within a UIViewController? -

i trying use starting point learn collection view: creating uicollectionview programmatically i have viewdidload has uiscrollview created so: uiscrollview *scrollview = [[uiscrollview alloc] initwithframe:cgrectmake(0.0, 64.0, screenwidth, screenheight)]; how add in uicollectionviewcontroller following below doesn't work: acollectionviewcontrollerr *vc = [[acollectionviewcontroller alloc] init]; [self.view addsubview:vc]; do need uiscrollview scroll down or uicollectionview have functionality already? uicollectionview inherits uiscrollview , don't need add uiscrollview . add uicollectionview uiviewcontroller directly. if use uicollectionviewcontroller don't require uiviewcontroller . see documentation of uicollectionview

c# - Can not resolve symbol of mocked object -

so learn more unit tests , mocking created following simple interface want mock , test in unit test: namespace testprojekt { public interface icsvfile { string filename { get; } int getfilesize(); } } and test using nunit , moq namespace nunittests { using moq; using nunit.framework; using testprojekt; [testfixture] public class unittests1 { private const string filename = "0030001744_14224429_valuereport_20140527000012_1104.csv"; private const int filesize = 155; [test] public void exampletest() { var file = new mock<icsvfile>(); file.setup(m => m.getfilesize()).returns(filesize); file.setupget(m => m.filename).returns(filename); assert.areequal(filename, file.filename); assert.areequal(filesize, file.getfilesize); } } } i made based on tutorial found online , quite interesting . pro

cordova - How to add Emoji smileys for phonegap -

i trying build app messenger. have add smileys whatsapp. searched web , got github link emoji icons . android native app. want add functionality in phonegap application. how can this. 1. there other plugin phonegap ? 2. can modify given library adding phonegap application ? 3. or have build custom plugin ? i beginner in phonegap. don't have idea in building plugins. please me suggesting ideas , providing useful links. in advance. you cant that. in app dont have access native textview, working in webview.

asp.net - Configuring Quartz.Net to stop a job from executing, if it is taking longer than specified time span -

i working on making scheduler, windows scheduler using quartz.net. in windows scheduler, there option stop task running if takes more specified time. have implement same in scheduler. but not able find extension method/setting configure trigger or job accordingly. i request inputs or suggestions it. you can write small code set custom timout running on thread. implement iinterruptablejob interface , make call interrupt() method thread when job should interrupted. can modify following sample code per need. please make necessary checks/config inputs wherever required. public class mycustomjob : iinterruptablejob { private thread runner; public void execute(ijobexecutioncontext context) { int timeoutinminutes = 20; //read config or db. timespan timeout = timespan.fromminutes(timeoutinminutes); //run job here. //as job needs interrupted, let create new task that. var task = new task

Eclipse Android App - The Application has stopped unexpectedly. Please try again -

i have problem application android (telephonymanager service). when run app code without getters works, if use get() function app send me message "the application has stopped unexpectedly. please try again". don't know what's wrong. my "bad" code: package com.example.tc; import android.support.v7.app.actionbaractivity; import android.support.v7.app.actionbar; import android.support.v4.app.fragment; import android.telephony.telephonymanager; import android.content.context; import android.os.bundle; import android.view.layoutinflater; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.viewgroup; import android.widget.textview; import android.os.build; public class tc1 extends actionbaractivity { textview textview1; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_tc1); if (savedinstancestate == null) {

How to add Android SDK for Android L in IntelliJ -

when go project structure -> sdk, [+] button (add) android sdk, can't see android l on dropdown list. is there way that? it hasn't appeared me well, updated sdk tools, sdk platform-tools , build-tools, entered sdk manager once again - , there.

php - Doctrine Resolve_target_entity in config -

i found on doctrine website page: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/resolve-target-entity-listener.html a way let entity communicate interface can configurable. problem cant find anywhere how put in array config. checked configuration source there nothing in docs: https://github.com/doctrine/doctrineormmodule/blob/master/docs/configuration.md hope can help thanks you can use this: 'doctrine' => array( 'entity_resolver' => array( 'orm_default' => array( 'resolvers' => array( 'mymodule\entity\foointerface' => 'othermodule\entity\foo', ), ), ), we use e.g. here (as live example) in soflomo\blog .

How To Send Email With PHP 5-5.5.9 Smtp Send( ) Function On Ubuntu 14.04 -

i want send e-mail on ubuntu 14.04 smtp php. can't send e-mail because smtp-->send function doesn't work. decided install pear mail packages. when ı want install php pear mail packages on terminal error occurs. for example error occurs below when ı entered sudo pear install mail_mime command terminal. downloading mail_mime-1.8.9.tgz ... starting download mail_mime-1.8.9.tgz (33,796 bytes) .........done: 33,796 bytes not extract package.xml file "/tmp/pear/install/mail_mime-1.8.9.tgz" download of "pear/mail_mime" succeeded, not valid package archive error: cannot download "pear/mail_mime" download failed install failed because of errors decided upgrade pear in system.i entered "pear upgrade" command error occurs below.. pear/pear dependency package "pear/xml_util" downloaded version 1.2.3 not recommended version 1.2.1, may compatible, use --force install pear/xml_util cannot installed, conflicts installed package

linux - How can I use a dot file in a bash script unix -

i trying install git's autocomplete (and not want use homebrew this), placed following in bash_profile if [ -f ~/.git-completion.bash ]; source ~/.git-completion.bash fi the .git-completion.bash install script donwload github, specifically: https://github.com/git/git/raw/master/contrib/completion/git-completion.bash the .git-completion.bash file exists, can see when run ls -la however, every time open terminal window, see -bash: /users/username/git-completion.bash: no such file or directory (i not know why not have "." in error) i appreciate guidance on how fix without homebrew. thanks

jdbc - What are the options to use cassandra 2.0.8 in Java -

i used cassandra-jdbc 1.2.5, when query timestamp columns shows 'asserterror'. due incompatibility of cassandra-jdbc-1.2.5 cassandra-2.0.8. works cassandra-1.x series. need know other ways use cassandra in java preparedstatement. saw clients thrift cannot execute sql type queries. at point in time, don't think there jdbc driver works casandra 2.x. "casandra-jdbc" driver looks has not been touched since april 2013. there issue in tracker says "doesn't works cassandra 2.0" hasn't been assigned anyone. unless intend work (or pay else you), looks pretty grim. according question ( cassandra client java api's ) there number of java apis casandra don't involve jdbc. advised switch 1 of these. there page on official casandra site lists client drivers: apache casandra client drivers

Place image in front of html video -

i want place image in front of html video. , here code far: <style> video.videos { background-image: url(image.png); background-repeat: no-repeat; z-index:1; } </style> <video id="video1" class="videos" > <img src="image.png" align="absmiddle" style="z-index:2;" > <source src="video1.mp4" type="video/mp4"></source> browser not support html5. video not loaded. </video> but using z-index not make working. mean, image still remains behind video file. there possibility fix this? maybe other way? place outside video tags , use style position it: top: 100px; left: 100px; z-index: 0; position: absolute; naturally, you'll need adjust values specific application. if absolute positioning doesn't work you, can use relative positioning, can more flexible. see jsfiddle example of positioning image i

rest - ElasticSearch Not returning all results -

i have set of data { "took" : 2, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 16, "max_score" : 1.0, "hits" : [ { "_index" : "tenant1", "_type" : "consultation", "_id" : "100038", "_score" : 1.0, "_source" : {"id":"100038","patientpin":"2012010000000020","prescriptions":[],"diagnosis":["amoebiasis"],"patientfirstname":"scooby","patientlastname":"doo","documentdate":"06/13/2014"} }, { "_index" : "tenant1", "_type" : "consultation", "_id" : "100007", "_score" : 1.0, &

sip - How to tunnel voip traffic in blocked networks -

i have android voip application. networks block voip traffic wold find way bypass block. think vpn can this, there no vpn solution can implemented easily. vpn api android provides need implement (e.g. there no protocol implementation there). so there other ways achieve need? may ssh tunneling or other type of tunneling? any kind of advice help, because don't know start from. many countries have implemented strict voip blocking in last years. example in iran streams voip characteristics (around 3-60 kbits, same upload , download) blocked now. in other countries voip not blocked quality lowered (dropping few packets, changing delay of others). because companies owns internet network owns telecom infrastructure, way trying keep customers away voip. traditional vpn’s filtered nowadays recent improvements in various deep packet inspection software , devices. encryption not enough, have obfuscate voip traffic. so, voip servers can found , traffic lowered. if need overc

html - Display image on a gradient background on hover via css -

i have background: .background:hover { background: #f4f4f4 url(../images/arrow_down_over.gif) no-repeat right; } that change gradient 1 : .background:hover{ background: -moz-linear-gradient(top, #f4f4f4 0%, #eeeeee 100%); /* ff3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f4f4f4), color-stop(100%,#eeeeee)); /* chrome,safari4+ */ background: -webkit-linear-gradient(top, #f4f4f4 0%,#eeeeee 100%); /* chrome10+,safari5.1+ */ background: -o-linear-gradient(top, #f4f4f4 0%,#eeeeee 100%); /* opera 11.10+ */ background: -ms-linear-gradient(top, #f4f4f4 0%,#eeeeee 100%); /* ie10+ */ background: linear-gradient(to bottom, #f4f4f4 0%,#eeeeee 100%); /* w3c */ filter: progid:dximagetransform.microsoft.gradient( startcolorstr='#f4f4f4', endcolorstr='#eeeeee',gradienttype=0 ); } /* ie6-9 */ but keep arrow image. can't find way it. did try this: background: -moz-l

publish subscribe - Autojoin option of xmpp bookmark does not work -

i trying auto-join rooms using xep-0048 - bookmarks ( http://xmpp.org/extensions/xep-0048.html ). i using robbiehanson xmppframework, ejabberd v13.x far, have been able add bookmark room using following code : -(void) createbookmarkforroom:(nsstring *)roomjid { nsxmlelement *nick = [nsxmlelement elementwithname:@"nick" stringvalue:@"marge"]; nsxmlelement *conference = [ddxmlnode elementwithname:@"conference"]; [conference addattributewithname:@"name" stringvalue:@"bookmarkname"]; [conference addattributewithname:@"autojoin" stringvalue:@"true"]; [conference addattributewithname:@"jid" stringvalue:roomjid]; [conference addchild:nick]; nsxmlelement *storage =[ddxmlnode elementwithname:@"storage"]; [storage addattributewithname:@"xmlns" stringvalue:@"storage:bookmarks"]; [storage addchild:conference]; nsdictionary *options = [ns

c# - Encode error in while showing data -

when tried show data in view data rendered wrong. data : "kn\326" and output : knÖ the data coming via viewbag. the way escape " \ ", since \xxx special char before "printing" on screen, juste apply regex on string ( "s/\/\\/g" correct regex, i'm not sure)

Laravel - Blade: @include a template with automated "filename-comment" -

i wondering if there way include template in way blade automatically writes html-comment filename @ beginning of included template. helpful in project lots of templates. example: // file 1 <div class="bla"> @include('folder.subfolder.templatename') </div> // file 2 ( folder/subfolder/templatename.blade.php ) <p>lorem ipsum dolor sit amet</p> // resulting file <div class="bla"> <!-- folder/subfolder/templatename.blade.php --> <p>lorem ipsum dolor sit amet</p> </div> imagine developer needs implement feature 2 years later. generated comments able view sourcecode in browser , know every temolate located in project. that can achieved extending blade, though it's bit hacky. think laravel should provide cleaner interface extend blade. well did, extending blade , creating @commentinclude directive. logic of include extracted laravels compileinclude() method . added comment , li

Sum in C cannot solve -

ok,so wrote program , compiled it. it's ok, when run in windows 7 get's me error c0000005. have no idea why. overview of program i want program give me sum of numbers depends of given "n" : 1-1x3+1x3x5-...+-1x3x5x...x(2*n-1). please me,i begginer. #include <stdio.h> #include <conio.h> int main() { int n, sum=0, i, signum; printf("give n: "); scanf("%d", n); for(i=1, signum=1; i-(2*n-1); sum+=(signum*(sum*i)),i+2,signum=-signum) ; printf("sum is: %d", sum); getch(); return 0; } you write code this, think lot clearer. #include <stdio.h> int main() { int i, n, sum = 1, term = 1; printf("give n: "); scanf("%d", &n); // address of n (i = 2; <= n; ++i) { // simple loop term *= -(2 * - 1); // multiply previous , flip sign sum += term; } printf("sum is: %d", sum); return 0; } i'm on l

sql - How to Select Multi line text as different single line texts? -

update tbl set col1='multi \r\nline \r\ntext' i'm using above query set col1 value multiline value. i wish select col1 3 rows. i want output for select col1 tbl like col1 multi line text to separate string elements use nodes() method of xml data type . use should convert string xml format. replace '\r\n' '</x><x>' : with t ( select id, cast('<x>'+replace(col1,'\r\n','</x><x>')+'</x>' xml) xmldata tbl ) select t.id, a.c.value('data(.)', 'varchar(100)') col1 t cross apply xmldata.nodes('x') a(c) sqlfiddle demo

html - Slider with fixed height and variable width images -

i'm trying create slider fixed height , variable width images. need slider 100% width of page, , responsive browser viewport. i prefer not use js. html <div id="photoframecontainer"> <div id="photoframe"> <div class="imagecontainer"><img id="theimage" src="uploads/picture02.jpg" alt=""></div> <div class="imagecontainer"><img id="theimage" src="uploads/picture03.jpg" alt=""></div> <div class="imagecontainer"><img id="theimage" src="uploads/picture04.jpg" alt=""></div> <div class="imagecontainer"><img id="theimage" src="uploads/picture05.jpg" alt=""></div> <div class="imagecontainer"><img id="theimage" src="uploads/picture06.jpg" alt=""></

php - Show message if inserted successfully PDO -

i wrote php code insert records in mysql database. want display message indicating whether records added database or not. tried several times failed. code: <?php try { $db_user = 'root'; $db_pass = 'cea123'; $db = new pdo( 'mysql:host=localhost;dbname=symposium', $db_user, $db_pass ); $form = $_post; $sql = "insert app ( firstname, lastname, company, homepage, contactno, addressline1, addressline2, city, postalcode, country, email, abstractdetails ) values ( :firstname, :lastname, :company, :homepage, :contactno, :addressline1, :addressline2, :city, :postalcode, :country, :email, :abstractdetails )"; $query = $db->prepare( $sql ); $query->execute( array( ':firstname'=>$firstname, ':lastname'=>$lastname, ':company'=>$company, ':homepage'=>$homepage, ':contactno'=>$contactno, ':addressline1&#

How to send huge amounts of data from child process to parent process in a non-blocking way in Node.js? -

i'm trying send huge json string child process parent process. initial approach following: child: process.stdout.write(myhugejsonstring); parent: child.stdout.on('data', function(data) { ... but read process.stdout blocking: process.stderr , process.stdout unlike other streams in node in writes them blocking. they blocking in case refer regular files or tty file descriptors. in case refer pipes: they blocking in linux/unix. they non-blocking other streams in windows. the documentation child_process.spawn says can create pipe between child process , parent process using pipe option. isn't piping stdout blocking in linux/unix (according cited docs above)? ok, stream object option? hmmmm, seems can share readable or writable stream refers socket child process. non-blocking? how implement that? so question stands: how send huge amounts of data child process parent process in non-blocking way in node.js? cross-platfor

ajax - Server side form don't work -

i have form in server side, witch downloads every page refresh, form has submit button. writing code below html catch submit handler, got fault.. how should it? friend told me had execute script submit catch when form loaded.. p.s. form loads js after button "edit" push. $test variable holds html code buttons, divs etc. passing json. every row creates button. http://postimg.org/image/p1ugsfw4f/ . @ same file if(isset($_request['update'])){ $vardas = $_post['vardas']; $id = $_post['id']; $sqel = mysql_query("update `client_objects` set ob_name = '$vardas' ob_id = $id");} i have post request.. in form after button "save changes" pushed, got redirected php file. isset works perfectly. want not open php file. better solution alarm. $("#update").submit(function() { $.ajax({ type: 'post', url: 'demo/client_view_search_content.php', data: $("#formaclient&q

Inner join within Common Table Expression in PostgreSQL -

i have table "table1", contain following rows: cola colb ------------- p4 x1 p4 z p4 z p5 s p5 t p5 y1 p8 x1 p8 y1 p8 x1 p9 x1 p10 z1 p1 z1 p2 z1 p3 z1 now need display table this:(as expected) cola colb result ---------------------- p4 x1 0 p8 x1 0 p9 x1 0 p5 y1 0 p8 y1 0 p1 z1 0 p10 z1 0 p2 z1 0 p3 z1 0 for writing query: with cte ( select colb,cola,dense_rank() over(partition colb order cola asc) tem table1 ) select s.cola, s.colb, 0 result tem_table table1 s inner join cte c on c.colb = s.colb tem > 1 group s.cola,s.colb order s.colb; but dont want use inner join in above query because of low perfromance. trying query: with cte ( select colb,cola,dense_rank() over(partition colb order cola asc) tem table1 ) select cola,colb,0 result tem

parsing - macros not rendering in NVelocity -

i have simple set of velocity templates. when trying merge using nvelocity, macros other templates not executing. template contents follows: v1.vm #parse("v2.vm") #foreach( $customer in $customers) hello $customer.name! #set($a =$customer.getage()) #age($a) #end v2.vm #macro ( age $a ) #if($a<18) minor #else major #end #end on merge, output is: hello user1! #age(33) hello user2! #age(13) the macro doesn't work because nvelocity (and ancestor velocity) determine if #age directive or macro @ parse time, while #age macro gets discovered @ runtime jumps other template, , passed through text. to around need make macro available parser before parses v1.vm 's #foreach . can putting macro inline in file, assume intend reuse in other templates why you've got separate now. the other option put macro in macro library, either 1 nvelocity automatically load ( vm_global_library.vm ) or custom o

python - How to efficiently convert numpy values to array of range indexes -

i'm trying figure out efficient way of taking numpy array of float values , converting them index associated specific range. eg numpy array of x floats [ -999.99, 433.000, -56.00....] (this array quite large typically 6000 25000 values. the range info consists of smaller around 3 20 rows (y) of range start values (arranged in ascending sequence) . eg [-9999.0, 0.0, 0.0, 500.0 99999.0]. value can repeated shown 0.0 value. this used build set of ranges such start of range = [:yrows - 2] , end = [1:yrows -1] such gives series of ranges [(-9999.0, 0.0), (0.0, 0.0), (0.0, 500.0), (500.0, 99999.0) total number of rows of yrows -1 (an index can generated corresponding each row what need derive equivalent of index of y row original x float value in (there 1 per x float). use index derive further information associated specific range. eg indexes of [ -999.99, 433.000, -56.00....] yield indexvalues[ 0, 2, 0...] note clarity x values not in way sorted larger lowest array range

ios - How to compare SSL certificates using AFNetworking -

in iphone app i'm using https connection self-signed ssl certificate download sensible data (username , password) server. this app private use only, not meant production. i'm using afnetworking manage https connection but, since certificate isn't signed ca, in order make work had add following header of afurlconnectionoperation class: #define _afnetworking_allow_invalid_ssl_certificates_ 1 but app allow certificate. is there way allow certificate server maybe bundling in app , comparing certificate provided server in https connection? , if possible, there significant advantage in terms of security? i'm new security , i'm kind of confused. the term you're looking ssl pinning , app verifies known certificate or public key matches 1 presented remote server. afnetworking supports both pinning certificates or public keys. you'll need add certificate(s) or public key(s) app's bundle, , enable feature setting either defaultsslpin

c# - How to deserialize a tag nested within a text section of another tag? -

how represent structure of following xml further deserialization classes? <headelement id="1"> text in headelement start <subelement samp="0"> text in subelement </subelement> continue text </headelement> my current code looks this: [datacontract] public class claimtext { [datamember, xmlelement(elementname = "claim-ref")] public claimref claimref; // { get; private set; } public void setclaimref(claimref claimref_) { this.claimref = claimref_; } [datamember, xmltext()] public string txt; // { get; private set; } public void settxt(string txt_) { this.txt = txt_; } } given following xml contents: <claim id="clm-00016" num="00016"> <claim-text>16. midgate assembly of <claim-ref idref="clm-00015">claim 15</claim-ref>, further comprising second ramp member connected opposite s

How to detect the fundamental frequency in a signal using wavelets? -

Image
i have noisy sine signal want extract fundamental frequency of sine. should use? the signal in discrete time domain known sampling frequency. trying corroborate answer got fft analysis cannot use fft. here piece of r code implements continuous wavelet transform on signal (using biwavelet package). the signal composed of sine wave frequency 40 hz , random noise. result spectrum showing frequency 40 hz dominates in whole signal. signal.len <- 1024 # input param. sin.freq <- 40 # input param. # noise + 40 hz sine wave signal <- rnorm(signal.len) + sin(sin.freq*2*pi/signal.len * 1:signal.len) library(biwavelet) w <- wt(cbind(index(signal), signal)) # continuous wavelet transform # rendering results par(mfrow=c(2,1)) plot.default(signal, type = "l", xaxs = "i") # signal plot.biwavelet(w, useraster = true) # spectrum of signal

Symfony - Twig - dateTime HH:MM:SS.MMM in SS.MMM? -

how convert datetime hh:mm:ss:mmm in ss.mmm filter in twig please ( `` )? exemple : 00:01:30.600 => 90.600 i tried {{ object.time | date("s") }} doesn't work ... thanks ! as @john smith told in comment (unfortunately can't +1 deserves it), can use: {{ object.time | date("s.u") }} to change microseconds miliseconds, have 2 choices: round 3 digits: {{ object.time | date("s.u") | round(3) }} slice 3 last chars: {{ object.time | date("s.u") | slice(0, -3) }}

precompiled - C# Switch enum at runtime -

i have 2 projects reference same precompiled (c#) dll. .dll contains public enum in namespace but: both projects have use different values in enum. is there possibility define that? (pseudo code) namespace module { #if configurationmanager.appsettings["project"] == "extern" public enum roles { admin = 0, user = 1, vip = 2 } #else /* "intern" */ public enum roles { admin = 0, staff = 1, user = 2 } #end } important: code has precompiled, preprocessor directive not possible. you can have that, both can't in same namespace. have 1 module.extern.roles , , other module.intern.roles , if want them in same namespace, you'd have combine values single enum or change name of 1 of them.

mysql - Trying to fetch all data with a while loop but the first data is already fetched, don't know how to change my code. (Php) -

update 2 - fixed: i figured out how fix myself after long hard think haha it's easy way might call ugly works me! i've created variable $row , called $post: $post = $row and used other variable show other stuff of article. update: thanks niels helping me out! facing problem if try echo code after while loop won't appear if in front of it show nicely? how can fix issue? thanks my question so here's example code use show categories linked postid. example post 1 has categories: apple, green , yellow linked it. but can't seem fetch data correctly since has been fetched once @ top can't proper while loop @ categories: part of code try while loop. while loop works , fetches categories except first 1 , when place while loop $row['posttitle'] and $row['postcont'] won't appear anymore because it's being skipped. how fix this? thanks. <?php require('includes/config.php'); $stmt = $db-&

Database vs static html files for storage solution (Site Builder) -

project description: learning exercise asp mvc 4, i'm creating site builder / multitenancy site. it's nothing fancy wysiwyg editing on templates custom routing direct users correct template based on subdomain. usr1.mysite.com directed template edited usr1. main concern @ moment method of storing edited templates. storage dilemma: @ first going make templates views , store changes made user in database. when usr1's template displayed system pull view , populate usr1's data. instead i've implemented system takes user's modified template , saves whole thing static html files in file system. path usr1's site (and other details) saved in database. when usr1.mysite.com called have "content" controller retrieve correct html file. question: there reason choose database/view method on static html file method? i'm not concerned having dynamic content in end user pages. 1 reason tried file method. decision (edit): i'm implementing fil

php - How to write IF ELSE statements in MySQL -

i have tables posts , users basically want query if column privacy of posts table 0 means post public , want show everyone. if privacy column 1,2,3,4 means post users id 1, 2, 3 , 4 this not conditional problem it's sql join through table association problem. you need create join table associates post user. can use join select posts based upon assignment user. the sql might this to select posts assigned user id = 4 select * `posts` left join `posts_users` on (`posts`.`id` = `posts_users`.`post_id`) `posts_users`.`user_id` = 4; you have made assumption if post has no users assigned it, it's public post. requires check null associations. select * `posts` left join `posts_users` on (`posts`.`id` = `posts_users`.`post_id`) `posts_users`.`user_id` null; if want find both public , associated posts, use logical or match both rules. select * `posts` left join `posts_users` on (`posts`.`id` = `posts_users`.`post_id`) `

c# - Referencing DLL's among different environments -

i trying create powershell cmdlets can placed on few different environments. these environments have various versions of sharepoint installed , location of microsoft.sharepoint dll file changes depending on version installed. within cmdlets looking use sharepoint objects e.g. spfarm.buildversion; can tailor rest of cmdlet. my problem dont't know how reference dll when location can change between environments, , need add using statement in code access sp objects. i hope makes sense....any ideas?

unit testing - Cannot mock grails domain class -

someone, please, explain why domain class behaves different when mocked new mockfor(..)? use grails 2.4.1. have create domain class gtest: class gtest { static constraints = { } string amethod() { return "gtest.amethod" } } and groovy class dtest: class dtest { string amethod() { return "dtest.amethod" } } and here groovy test: class groovyjunittest { @test void testdtestamethod() { def mock = new mockfor(dtest) mock.demand.amethod { return "mock dtest" } mock.use { def dtest = new dtest() // here dtest.metaclass=groovy.mock.interceptor.mockproxymetaclass@... def ret = dtest.amethod() // assertation successes assertequals "mock dtest", ret } } @test void testgtestamethod() { def mock = new mockfor(gtest) mock.demand.amethod { retur

multithreading - Python Threads. Serial Port. KeyboardInterrupt -

i'm implementing multithreaded program 1 of threads reads serial port. i'm having trouble when trying end program keyboardinterrupt. have main thread , 1 reads serial port. code looks this: import threading import time def reader(name, port, run_event): while run_event.is_set(): port.read(1) #process data............... if __name__ == "__main__": run_event = threading.event() run_event.set() port=serial.serial(port=args.serialport,baudrate=921600) port.flush() port.flushinput() t1 = threading.thread(target = timed_output, args = ("reader",port,run_event)) t1.start() try: while 1: time.sleep(.1) except keyboardinterrupt: print "bye bye" run_event.clear() t1.join() port.close() print "threads closed" sometimes works fine other times not. of logs. why 1 not caught try-except block? ^ctraceback (most recent call