Posts

Showing posts from March, 2014

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException | JAVA -

i want number of entries in table in java project. this code: int count = 0; statement st = mysql.con.createstatement(); resultset rs= st.executequery("select count(*) keys spieler =" +p.getname()); while (rs.next()){ count = rs.getint(1); } i getting following sqlexception : com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'keys spieler =pit910' @ line 1 what worng? thanks! keys reserved mysql keyword needs escaped (either or alter table give different name). try this preparedstatement preparedstatement = con.preparestatement("select count(*) `keys` spieler = ?"); preparedstatement.setstring(1, p.getname()); resultset rs= preparedstatement.executequery(); ...

spring - Choose between muliple transaction managers at runtime -

i have 2 clients using same spring based rest application deployed in tomcat. depending on client need choose between data sources , transaction manager. how choose @ runtime, transaction manager use? <bean id="first_datasource" class="org.apache.commons.dbcp.basicdatasource" destroy-method="close"> <property name="url" value="${first_jdbc.url}" /> <property name="driverclassname" value="${first_jdbc.driverclassname}" /> <property name="username" value="${first_jdbc.username}" /> <property name="password" value="${first_jdbc.password}" /> <property name="removeabandoned" value="true" /> <property name="initialsize" value="20" /> <property name="maxactive" value="30" />

AngularJS showing intermediate page while saving -

while saving new invoice using angularjs app, there noticeable time taken while api checking products balances, saving data...etc wondering there way in angularjs can show intermediate (page...example: #/processing) users routed once user click save button depending on save new invoice $http result (failure or success) either route user invoice page (ex. #/new-invoice) or success saving page (#/thanks-for-ordering) ? any example highly appreciated. thanks you can use ng-if switch between input , saving state. example template: <div ng-if="issaving"><img src="spinner.gif"> saving...</div> <form ng-if="!issaving" ng-submit="savethething(thing)> <input ng-model="thing.title" type="text"/> ... </form> example controller: angular.module('app').controller('examplectrl', function ($scope, $location) { $scope.savethething = function(thing) { $scope.is

objective c - iOS 7.1 NSString drawInRect -

i have code worked fine until built project ios 7.1. before, text correctly showed on pdf page. [strsometext drawinrect:rectfortext withattributes:[nsdictionary dictionarywithobjectsandkeys:font, nsfontattributename, mutparagraphstyle, nsparagraphstyleattributename, colorred, nsforegroundcolorattributename, nil]]; but now, in formatting dictionary being disregarded. pdf document shows black text of default font , size. thank responses. i try using nsattributedstring , find whether works. not have reason why code has stopped working, try this: // these variables examples, keep whatever variables using uifont *font = [uifont fontwithname:@"whatever_font" size:16.0f]; nsparagraphstyle *paragraphstyle = [nsparagraphstyle defaultparagraphstyle]; nsdictionary *attributes = @{nsfontattributename : font, nsparagraphstyleattributename : paragraphstyle, nsforegroundcolorattributename : [uicolor redcolor]}; nsattributedstring *attributedstring = [[nsattributed

sql - MySQL select lowest timedate for each id -

i have table : create table if not exists `event_showtime` ( `id_show` int(11) not null auto_increment, `id_event` int(11) not null, `latitude` double not null, `longitude` double not null, `event_date_time` datetime not null, primary key (`id_show`), key `id_event` (`id_event`) ) values this, example : insert `event_showtime` (`id_show`, `id_event`, `latitude`, `longitude`, `event_date_time`) values (1, 1, 49.2016762922894, 18.7615620750428, '2014-03-31 16:13:17'), (2, 1, 49.2016762922894, 18.7615620750428, '2014-04-01 20:00:00'), (3, 2, 49.2113914818564, 18.7520992416382, '2014-03-31 15:00:00'), (4, 2, 49.0545135142313, 20.2952223676682, '2014-04-16 11:00:00'), (5, 2, 49.2113914818564, 18.7520992416382, '2014-04-23 11:00:00'), (6, 2, 49.0545135142313, 20.2952223676682, '2014-04-30 11:00:00'), (7, 2, 49.2016762922894, 18.7615620750428, '2014-04-29 12:00:00'), (8, 1, 49.2016762922894, 18.7615620750428, '

viewport - How to change the view port in javafx? -

Image
i have created screen gui . now after program starts want show user firstbtn this: and after button clicked screen moves in direction of arrow in picture , goes secondbtn now how should move screen , change view port. you may use different scenes same stage. primaystage.setscene(yourscene1); and same when needed yourscene2 primaystage.setscene(yourscene2);

python - unit testing with mock for google apps api - Admin Directory API -

i followed tutorial here , can retrive emails domain application. now want write unit tests mock application, dont know start. i have read here unit testing mock , google api admin directory api comes own mock library. dont understand how use correctly. my application test_email_user.py contains import real application email_user.py what? i have fake google api directory responses real application, how? greetings, sam i'm not familiar google client api own mock library mention mock library : import mock class directoryhelper(): ... #real method calls api def get_users(self): user_list = [] request = self.service.users().list( customer=self.customer_id, maxresults=500, orderby='email', fields="nextpagetoken,users(id,orgunitpath,primaryemail,name(givenname,familyname),agreedtoterms,suspended)" ) while request: logging.debug('retrieving page of users directory...') rep

long doesn't equal another long in C++ -

it never goes in if statment when 0 == 0 sizeof() of both function return long , regular long both 8, don't know else wrong here. declarations: long remotestep; // next packet number to-be-processed long getlong(byte * message, const short offset) { // long char * return *(long*)&(message[offset]); } debug code: printf("id = %d remotestep = %d \n", getlong(packet->message, 2), remotestep); printf("id = %d remotestep = %d \n", getlong(packet->message, 2), remotestep); printf("id = %d remotestep = %d \n", getlong(packet->message, 2), remotestep); printf("equals = %d \n", getlong(packet->message, 2) == remotestep); printf("sizeof = %d - %d\n", sizeof(getlong(packet->message, 2)), sizeof(remotestep)); // process if expected if (getlong(packet->message, 2) == remotestep) { printf("in.............\n"); ...

java - How to open xml by clicking button -

so have made new layout in res/layout called about , want is, when clicking button directed layout. simplified. when press button on "activity_main.xml" opens "about.xml". how can achieve this??? don't have access resource heavy websites, stackoverflow last option. appreciated if know how. if don't want start new activity, invoke: setcontentview(r.layout.about); when button clicked. set current activity new layout located @ res/layout/about.xml . work if change activity presentation without changing functionality. if want launch activity, should create new activity class implements functionality of new activity , keeps about.xml layout. on button click, start new activity.

javascript - What is the fastest way to auto open hash tab on page load? -

i want open hash #home automatically on page load. tried <body onload=window.location='#home'> js way: <html> <head> <script type="text/javascript"> function load() { window.location.href = "#home"; } </script> </head> <body onload="load()"> <h1>hello world!</h1> </body> </html> and html redirect <meta http-equiv="refresh" content="0; url=#home" /> all ways slow (about 2-3 sec. redirect after page load). there better (faster) way automatically open #home on page load? do this: <body onload="window.location.hash='home'"> i think fastest way.

android - How to view,compare and refresh current time? -

the aim of current application current time of phone , compare list of timerange i've set , view time remaining between current time , time range ( need refresh of view each seconds ). example : current time = 11 pm time range = 11:10 pm i view : x = 11h = 11h10min view ( x); // refreshing each seconds view ( a- x); // refreshing each seconds for moment suceeded view current time : public class horairetempsreel extends activity { private textview tvdisplaytime; private int hour; private int minute; private string curtime; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.horairetempsreel); setcurrenttimeonview(); } // display current time public void setcurrenttimeonview() { tvdisplaytime = (textview) findviewbyid(r.id.tvtime); final calendar c = calendar.getinstance(); hour = c.get(calendar.hour_of_day); minute = c.get(calend

javascript - CKEditor - retrieve data as text instead of html -

this question has answer here: getting non-html text ckeditor 5 answers i using ckeditor allow user create html templates , save in database. have 2 types of templates - html & text . using ckeditor manage template content. problem able save html tempaltes, not text templates. use editor.getdata() in javascript extract html content. how can use ckeditor return text content? try code ckeditor.instances.editor1.document.getbody().gettext() reference: http://ckeditor.com/forums/ckeditor-3.x/can-i-get-editors-data-plain-text-format

android - Java Socket throws IOException Sometimes -

i making android application needs print receipts on network printer. printer using "thermal receipt printer tysso prp 300". my problem prints , after printing 2 or 3 times stops printing , start receiving ioexception. tried restarting mobile/application/force-stop/printer/pinged-printer nothing. using asynctask communication. below socket code: private class myprinter extends asynctask<string, string, string> { socket sock; printwriter ostream; datainputstream dis; public myprinter() { } protected string doinbackground(string... params) { try { sock = new socket(params[0], integer.parseint(params[1])); sock.setsotimeout(300); if(sock.getremotesocketaddress() != null) { ostream = new printwriter(sock.getoutputstream()); ostream.println(params[2]); } ostream.flush(); ostream.close();

Adding records to Data Grid View from text files. No text adding to DGV with lists VB.net -

i'm looking issue having. have multiple text files in folder. folder can have "unlimited" amount of text files in it, although typically 2-150 files. http://gyazo.com/5f314d1ca374abf9f813914609dd931d (images + below, can't embed due lack of reputation) each file contains "unlimited" (although typically 0-20 lines) amount of data inside it. line 1 being "test number" , line 2 being "test result" - seen in image above my data grid view has 3 columns in [username, test number , test result] named (column_username, column_testnumber, column_testresult) - seen in image above when running current code have, there correct amount of grids in data grid view, although of cells empty. http://gyazo.com/e08f9f2f4ab3971695feffe60503e8a9 (image of this) one thing don't want change of text file/ folder structures, though i'm aware inefficient storage. although i'm more happy use instead of lists function if think there better

OnClickListener in android app fails -

when start android application on smartphone system closing app , says: "sorry. yourapplication closed." it because of onclicklistener, why? here code: @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button addtodo = (button) findviewbyid((r.id.addtodobutton)); button cancel = (button) findviewbyid(r.id.cancel); cancel.setonclicklistener(new onclicklistener() { @override public void onclick(view view) { system.out.println("seas!"); } }); } stack trace: java.lang.runtimeexception: unable start activity componentinfo{sstodo.app/sstodo.app.mainactivity}: java.lang.nullpointerexception @ android.app.activitythread.performlaunchactivity(activitythread.java:2266) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2316) @ android.app.activitythread.access$600(activit

JQuery - I can't clone my form events -

Image
i'm trying clone form events cant, created script tags, , working that: and created script duplicate form, i'm using jquery clone(), , when click @ duplicate link, duplicates form not events, resuming, script created write tags works first form, doesn't work cloned forms here tags text fields <label>tags<a class="required_field">*</a></label> <div id="wrapbox"> <div id="box"> <span id="checktags"></span> <input type="text" class="to-be-clicked" id="tags" maxlength="230"> </div> </div> the code scripts, created hidden textbox inside script $('#tags').keypress(function(e) { //check if space clicked, , create new tag if(e.which == 32) { var tx = $('#tags').val(); if (tx) { $(this).val('').parent().before('<li class="tags"><sp

filtering - NaN values in Android filter -

i use following function filter signal. code works order 4, when use higher order, 5, nan values in output. highlly appreciated void filt(int ord, double a[], double b[], int np, double x[], arraylist<double> array) { int i,j; // y[0]=b[0]*x[0]; array.add(0, b[0]*x[0]); (i=1;i<ord+1;i++) { array.add(i, 0.0); (j=0;j<i+1;j++) array.add(i, array.get(i)+b[j]*x[i-j]); (j=0;j<i;j++) array.add(i, array.get(i)-a[j+1]*array.get(i-j-1)); } (i=ord+1;i<np;i++) { array.add(i, 0.0); (j=0;j<ord+1;j++) array.add(i, array.get(i)+b[j]*x[i-j]); (j=0;j<ord;j++) array.add(i, array.get(i)-a[j+1]*array.get(i-j-1)); } } i tried same functionality of matlab, , got nan values. dig in matlab documentation , found following explains nan values: "f

Android application stops on button click -

Image
i making application , stops when press buttons public class menu3 extends themenu{ button buttons[] = new button[21]; intent open = new intent("com.frosti.lidraedi.open"); int clicked; boolean found; int po1; int goon; int s,e; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); actionbar actionbar = getactionbar(); actionbar.setdisplayhomeasupenabled(true); bundle b = getintent().getextras(); po1 = b.getint("po", 0); switch (po1) { case 21: //when press these buttons works setcontentview(r.layout.menu21); s=0; e=11; break; case 22: //the layout loads without error //but when press buttons int layout stops setcontentview(r.layout.menu22); s=12; e=15; break; case 23: setcontentview(r.layout.menu23); s=16; e=20;

javascript - Toggle container open when click on link -

i'm trying create website navigates trough links. when click on highlighted text sends me different part on website. part of text inside toggle container opens when clicked. i'm using following code, not working. <div class="toggle-wrap"> <span id="eindhoven" class="toggle-title">eindhoven</span> <div class="toggle_container"> lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat </div> </div> <script> $(document).ready(function(){ if (window.location.hash.indexof('eindhoven')==1) { $('toggle_container').show(); } }); </script> not sure if it's solution, you're not specifying kind of selector want show: $('.toggle_container').show(); you need "." specify it&

php - How to sort results from two databases -

i have 2 web services; asp/sql server web service , php/mysql web service. i need results both services combined in xml , results need paginated (limited 10 results page). how order results (e.g., alphabetically) when coming 2 separate databases? it's not clear technology using fetch both queries here, nevertheless: you query both databases, , merge query result manually (perhaps creating hash results both queries in php). sort hash, , output results needed current page. you'll want cache these results somehow if working lot of data, , doing often. or, pull data need 1 database other, , perform union query. require fetch data every often, , time depend on doing , how fresh need data be.

c# - Accessing ListBox and other children in a LongListSelector -

i'm building app there's arbitrarily long list of items can click on of them , edit in place. edit of these items want programmatically change focus next item in list. <grid x:name="contentpanel" grid.row="1" margin="12,0,12,0"> <phone:longlistselector x:name="mainlonglistselector" margin="0,0,-12,0" itemssource="{binding items}" selectionchanged="mainlonglistselector_selectionchanged"> <phone:longlistselector.itemtemplate> <datatemplate> <stackpanel margin="0,-10,0,-12"> <textbox x:name ="tb" text="{binding thetext}" textwrapping="wrap" textchanged="textbox_textchanged" /> </stackpanel> </datatemplate> </phone:longlistselector.itemtemplate> </phone:longlistselector> </grid> as user types in fi

2d - Java rendering bug -

i'm using simple rendering method in java render tiles. looks fine, notice rows grow 1 pixel when move, , shrink back, have no idea why. infos: i'm using 16 x 16 tiles, render method runs around 500 times per second, use triple buffering, code of tile rendering method (located in screen class): public void rendertile(int xpos, int ypos, tile tile) { xpos -= xoffset; ypos -= yoffset; (int y = 0; y < 16; y++) { int ypixel = y + ypos; (int x = 0; x < 16; x++) { int xpixel = x + xpos; if (ypixel < 0 || ypixel >= height) continue; if (xpixel < 0 || xpixel >= width) continue; pixels[(xpixel) + (ypixel) * width] = tile.sprite.pixels[x + y * tile.sprite.size]; } } } i load sprites sprite sheets, , contain pixel data in array, can help? (if additional info needed, tell me) image issue: http://i59.tinypic.com/330y34i.png

How to set the current date in the gnuplot title -

it's possible set current date in gnuplot title? something like... set title "date of execution = datetime() " thanks in advance. alexandre. use strftime , time(0) add time/data title, e.g.: set title "data of execution ".strftime("%a %b %d %h:%m:%s %y", time(0)) alternatively, if doesn't have in title can use set timestamp

php - Random linebreaks when using file() -

i'm creating flatfile database, in 1 of functions use add fields pre-existing table, use file() table, first line contains fields of table can append new field pre-existing fields public function addfields($table_fields) { // make sure opened connection table if(empty($this->table_name)) throw new exception('there no connection table opened.'); // make sure table_fields array if(is_array($table_fields) === false) throw new exception('table_fields must array'); // build data $table_data = file($this->table_name); $table_header = $table_data[0].self::$field_deliemeter; $table_header .= implode(self::$field_deliemeter, $table_fields); $table_data[0] = $table_header; // put data in table file_put_contents($this->table_name, implode(self::$linebreak, $table_data)); } } the problem that, after adding fieldname pre-existing fieldnames using this $table_data = file($this->table_name); $table_hea

sql - How To Join Different tables and sort according to most occuring record -

Image
i have following tables: i make query counts users registered since 1995 city_name , sort project registration. have tried far (pls note still bit new sql): select count (userid), users.userid users full join p.projectid project registration_date >= '01/01/1995' group (select * project project.projectid = user.projectid) however, not returning right result. help do mean this: select project.projectid, city.cityid, count(userid) usercount project inner join users on users.projectid = project.projectid inner join city on city.cityid = users.cityid users.registration_date > '1/1/1995' group project.projectid, city.cityid order count(userid) desc you said 'sort project registration'; sorts project+city has registrations. you can sub-select total registrations project, , include in order by, strikes me bit of odd output, made assumption :-)

paypal - Instant Payment Notification -

i want have vip buy button, have button text box (generated pp) , code(its not full, classic ipn code paypal give u in tutorial, showing part changes): ........... // step 3: inspect ipn validation result , act accordingly if (strcmp ($res, "verified") == 0) { // ipn verified, process it: // check whether payment_status completed // check txn_id has not been processed // check receiver_email primary paypal email // check payment_amount/payment_currency correct // process notification // assign posted variables local variables $item_name = $_post['item_name']; $item_number = $_post['item_number']; $payment_status = $_post['payment_status']; $payment_amount = $_post['mc_gross']; $payment_currency = $_post['mc_currency']; $txn_id = $_post['txn_id']; $receiver_email = $_post['receiver_email'];

javascript - Equalizing Heights of Divs -

:) have little problem: i have div, , inside it, have 2 divs, 1 next another. 1 of left varies height keep relation width while resizing, , want 1 of right have same height left one; have code in jquery @ end of document: <script> $("#right").css("height",$("#left").height()); </script> the left 1 has content (that gives height) takes time load, so, code, when load page 1 of right has 0px of height, think that's because left 1 hasn't loaded content when code runs. so, should make sure i'm running code when left 1 has content loaded? and, how can make code refresh every time left's height changes? although code doesn't work, created function (called equalize) code, , created button onclick="equalize()", , when press button, right's height gets left's height. .-. try this: <script> $(document).ready(function(){ $("#right").css("height",$("#left

php - sql statement or while loop drawing a blank -

my code below should populating list of 7 items, nothing showing up. can tell me error is, maybe in sql statement? thanks <?php $page_title = 'view sites'; include ('includes/header.html'); include ('includes/functions.php'); include ('includes/config.inc.php'); if (isset($_get['id']) && is_numeric($_get['id'])){ $id = $_get['id']; } elseif (isset($_post['id']) && is_numeric($_post['id'])) { $id = $_post['id']; } else { echo '<p class="error">this page has been accessed in error.</p>'; include ('includes/footer.html'); exit(); } if (isset($_session['userid'])){ require (mysql); $w = "select s.sitetypeid, s.sitetype, u.url sitetypes s left join sites u using (sitetypeid) userid=$id"; $k = mysqli_query($dbc, $w)or trigger_error("query: $w\n<br />mysqli error: " . mysqli_error($dbc)); if (mysqli

R, DataFrame - group by multiple rows -

i have data.frame posts looks this: post_id group_id hour(when posted) likes 1 1 13 5 2 1 13 6 3 1 23 3 4 2 12 30 5 2 13 34 6 2 22 10 i want plot likes distribution hours in each group, need data.frame one: 0 ... 12 13 ... 22 23 <- hours gorup#1 0 11 3 <- sum of likes in group#i in xx hour group#2 30 34 10 0 how can group post group , hour? assuming data.frame called "mydf", perhaps can try xtabs (since you're looking sum ): > xtabs(likes ~ group_id + hour, mydf) hour group_id 12 13 22 23 1 0 11 0 3 2 30 34 10 0 to levels "hour", if sum "0" groups, factor "hour" column first. another convenient alternative use dcast "reshape2"

c# - Get Specified row index of a column from a data table having values contained in a string -

i have data table having 2 columns select , value. select value 0 213 0 314 0 282 i have integer array called ids={213,314} if values of ids occur in data table column "values" update "select" column 1. have using linq. please help linq querying, not updating. have task in 2 steps. first querying rows should updated: var rows = r in table.asenumerable() ids.contains(r.field<int>("value")) select r; // or lambda syntax // rows = table.asenumerable().where(r => ids.contains(r.field<int>("value"))) second part updating selected rows, not involve linq: foreach(var row in rows) row.setfield("select", 1);

checkbox - vb.net get row index id by row or cell value -

hi trying index of row through value . tried code not working there way can indexof row value. dim dgr new datagridviewrow() dgr.createcells(datagridview1, new object() {"name", "dfd", "sdfdf"}) datagridview1.rows.add(dgr) txtnameindex.text = datagridview1.rows.indexof(dgr) i want add value , remove value check box when check box checked value should added in datagridviewd , when same check box unchecked value should removed datagridview if chkbox.checked = true row = new string() {"2", "product 2", "2000"} datagridview1.rows.add(row) else value = new string() {"2", "product 2", "2000"} datagridview1.rows.remove(value) end if this how index: dim integer = datagridview1.rows.add(dgr) or dim integer = dgr.index for checkbox code recommend top 1 since aren't creating object datagridviewrow.

emacs - elisp warning "reference to free variable" -

i wandering how rid of elisp warning. setup following: i have init.el file sets "emacs-root" variable: ;; root of emacs-related stuff (defvar emacs-root (if (or (eq system-type 'cygwin) (eq system-type 'gnu/linux) (eq system-type 'linux) (eq system-type 'darwin)) "~/.emacs.d/" "z:/.emacs.d/" "path emacs configuration root is.")) then in init.el have ;; load plugins el-get (require 'el-get-settings) in el-get-settings.el loading packages el-get , appending "el-get/el-get" folder load-path: ;; add el-get load path, , install if doesn't exist (add-to-list 'load-path (concat emacs-root "el-get/el-get")) the problem have lips warning on 'emacs-root' in last expression add-to-list : "reference free variable 'emacs-root'" what doing wrong here , there way make compiler happy? this setup works ok btw - don't have iss

asp.net - HttpApplication.Init vs HttpModule.Init -

i trying understand why init method available in both httpapplication , httpmodule , , when use 1 on other. you can have 1 application, can have multiple httpmodules within 1 application. modules used handle separate blocks of functionality can added application (few real life examples - elmah - handles error logging, identitymodule - handles impersonation, etc.). since can attach same module (lets error logging) different application (lets mycompany.crm, mycomany.publicweb, mycomany.intranet), makes sense handle initialization on own, intepended on application you're adding them to.

sql server - Clear SSRS cache with SQL code -

to solve problem - ssrs shows wrong form tried clear ssrs cache. 1 post suggested use sql - http://social.msdn.microsoft.com/forums/sqlserver/en-us/58caa380-ece8-4507-9ff3-684c93685e72/how-to-clear-a-report-cache-in-ssrs-2008?forum=sqlreportingservices the code - use reportserver exec flushreportfromcache @path exec cleanexpiredcache @path need give path report need clear cache. which path enter here ? entered folder contains rdlc files , sql gave me 0 rows returned. doing simple beginner exercises on local system. this path report want clear cache. can querying dbo.catalog table in reportserver database follows: use reportserver; go select name --<-- report name ,[path] --<-- report path [dbo].[catalog] go

android - Changing ProgressBar visibility from inside onClick -

my activity_main.xml contains progressbar, starts hidden ("gone") <progressbar android:id="@+id/progressbar_sendingphonenumber" style="?android:attr/progressbarstylelarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/button_sendphonenumber" android:layout_centerinparent="true" android:visibility="gone" /> and mainactivity.java has this, onclick handler button have final context context = this; sendphonenumberbutton.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { progressbar progressbar = (progressbar) findviewbyid(r.id.progressbar_sendingphonenumber); progressbar.setvisibility(view.visible); // simulate http connection try { thread.sleep(3000); } cat

JSF 2.2 java.lang.IllegalStateException: Cannot create a session after the response has been committed -

i've developed web apps using jsf 2.0 , decided write app using myfaces 2.2 , tomcat 7.0.35 . exceptions , can't understand reason of this. khow stacktrace similar mojara bug use myfaces. java.lang.illegalstateexception: cannot create session after response has been committed org.apache.catalina.connector.request.dogetsession(request.java:2881) org.apache.catalina.connector.request.getsession(request.java:2316) org.apache.catalina.connector.requestfacade.getsession(requestfacade.java:898) org.apache.myfaces.context.servlet.servletexternalcontextimpl.getsession(servletexternalcontextimpl.java:150) org.apache.myfaces.view.impl.defaultviewscopehandler.generateviewscopeid(defaultviewscopehandler.java:128) org.apache.myfaces.view.viewscopeproxymap.getwrapped(viewscopeproxymap.java:76) org.apache.myfaces.view.viewscopeproxymap.isempty(viewscopeproxymap.java:94) org.apache.myfaces.renderkit.errorpagewriter._writevariables(errorpagewriter.java:787)

Wordpress Search URL messing up for posts -

i set search in header.php, , on main site search works properly. when search within story, however, never can search results page because tacks on /?s=searchterm in url after post slug. how can circumvent issue? what have provided in action of search form? use action="<?php echo home_url( '/' ); ?>" i think solve problem. if not provide site url easier trace actual problem.

c# - Are there any virtual printer driver for ESC/POS commands to test while programming? -

i writing sample program send raw data esc/pos printers (not specific printers supporting esc/pos in general) using c# .net. here link: http://support.microsoft.com/kb/322091 so, can using above guide send raw data. but, not have physical printer available while coding. so, looking temporary solution basic testing. are there virtual printer drivers available can send raw data application , see how looks? example: can install virtual pdf printers etc. but, need 1 can parse esc\pos , output in either *.pdf or images or text formats. i'm not sure if still applicable you, i've found solution: http://www.colorpilot.com/emfprinter_pos.html i hope that's looking for.

python - Hangman code python3 -

i have python 3 hangman code works not know how can allow user select difficulty (easy (9), medium (7), hard(5)) in main function. there simpler code used this? import random wordlist = ("phone", "laptop", "desktop", "sewer", "television", "never", "guess", "nice", "chair", "car"); word = random.choice(wordlist) acceptable = ("abcdefghijklmnopqrstuvwxyz") guessed = [] state = 0 haswon = 0 playedonce = 0 def menu (): print(""" 1. easy (9 misses) 2. medium (7 misses) 3. hard (5 misses) """) return int(input("what level want play?:")) def wantstoplay(): if (not playedonce): return 1 l = input("\nwould play again? (y/n)") while (l != "y" , l != "y" , l != "n" , l != "n"): l = input("\nwould play again? (y/n)") if (l.lo

java - How do I extract words from a string? -

i did research , find answers search results. trying extract word string , adding word string, replacing 1 removed. each situation different, can't make constant. i'd appreciate help! package rudolph; import javax.swing.joptionpane; public class ifblankwasblank { public static void main(string[] args) { string charinput = ""; string thing = ""; string pun = ""; charinput = joptionpane.showinputdialog(null, "enter person or thing you'd make fun of:"); thing = joptionpane.showinputdialog(null, "enter thing " + charinput +" doing:"); pun = joptionpane.showinputdialog(null, "enter pun " + charinput + " doing:"); string msg = "if " + charinput + " " + thing + ", they'd " + pun + "."; joptionpane.showmessagedialog(null, msg); }

javascript - Toggle button isn`t working?(Uncaught SyntaxError: Unexpected identifier ) -

there problem code. use button hide , show menu isn't working. didn't understand problem. uncaught syntaxerror: unexpected identifier :: par. 3 $(function() { $(".but").click( { if $("#div").hasclass("class"){ //problem here $("#div").removeclass("class").addclass("anotherclass"); } else{ $("#div").removeclass("anotherclass"").addclass("class"); } }); });' as others have said you're missing function, "but" not valid selector, , added () in if statement, that's coding preference $(function () { $("button").click(function () { //but not valid selector, button if ($("#div").hasclass("class")) { //problem here $("#div").removeclass("class").addclass("anotherclass"); } else { $("#div").removeclass(&q

html - Get radio checked in an array in jquery -

i got next html code , want array of checked radio buttons: <tr> <td>¿cómo te llamas?</td> <td><input class="radio" type="radio" name="respuesta1" value="female"> pablo</td> <td><input class="radio" type="radio" name="respuesta1" value="female"> christian</td> <td><input class="radio" type="radio" name="respuesta1" value="female"> alberto</td> </tr> <tr> <td>¿cuánto es 2 + 2?</td> <td><input class="radio" type="radio" name="respuesta2" value="female"> 2</td> <td><input class="radio" type="radio" name="respuesta2" value="female"> 3</td> <td><input class="radio" type="radio" nam

date - PHP datetime formatting in echo -

php noob. having trouble getting php date format execute here: echo "<div class='column'>"; echo $row['date']; echo "</div>"; i tried below no luck. echo ".date('d/m/y', strtotime($row['date']))"; it should be echo date('d/m/y', strtotime($row['date'])); the problem is echo ".date('d/m/y', strtotime($row['date']))"; ^............ $date = '2014-01-31'; echo ".date('d/m/y', strtotime($date))"; the output .date('d/m/y', strtotime(2014-01-31)) it treat string except variable inside "".

javascript - Issues with google closure library and angularjs -

i'm in middle of refactoring ngtrader game following angularjs-google-style have controllers, services, directives, ect... defined classes, functions defined prototypes on classes, registering class angular. the issue getting these changes work closure-library's goog.provide() , goog.require() . setup below, angular error says failed instantiate module ngtrader due to: error: [$injector:modulerr] failed instantiate module ngtrader.account due to: error: [ng:areq] argument 'fn' not function, got undefined index.html <body ng-app="ngtrader"> .... <script src="bower_components/closure-library/closure/goog/base.js"></script> <script src="components/account/accountsrvc.js"></script> <script src="components/account/account.js"></script> <script src="app.js"></script> </body> i've tried various orders of these files, thinking

c++ - Unexpected results from bitwise operation why (1 | 1 & 2) gives 1 instead of 2? -

cannot simple calculation straight using visual studio 2010 std::cout<<(1 | 1 & 2); //gives value 1, expecting 2 since 1 | 1 = 2 , & 2 gives 2 std::cout<<( (1 | 1) & 2); //gives value 0, why different above? first case: 1 & 2 // since & has higher precedence | 01 &10 ---- 00 and or result 1, 1 or 0 ----- 1 in second case 1 | 1 01 or 01 ---- 01 and , result 2, 01 & 10 ----- 0

Split radio button values using jquery / Javascript -

i want split radio button values form know option chosen is, price. value before | separator price , value after | option chosen. <input type="radio" name="arm" value="50|1" id="split" required> option: 1<br> <input type="radio" name="arm" value="100|2" id="split" required> option: 2<br> <input type="radio" name="arm" value="150|3" id="split" required> option: 3<br> <input type="radio" name="mechanism" value="50|1"> option: 1<br> <input type="radio" name="mechanism" value="100|2"> option: 2<br> <input type="radio" name="mechanism" value="150|3"> option: 3<br> <input type="radio" name="base" value="50|1"> option: 1<br> <input type="radio" name=&quo

c# - SharpPcap - Drop packet or alter outgoing packet -

is possible either drop packet or alter response using sharppcap? i've been looking online , i've seen older posts make seem not possible drop packet. can't tell if possible alter 1 though. if not, can point me in direction of resources on how this? nope. libpcap/winpcap/airpcap provide observation of packets in system not @ level of firewalls in aren't given access packet stream coming in/out of network adapter. there other pieces of software provide support doing want, , still use packet.net them (the packet analysis library used sharppcap).

ascii - Java symbol not found when it should be -

here's code: for(int i=0; i<plaintextupper.length()-1; i++) { system.out.println(charcodeat(i)); } it won't compile though, because says charcodeat's symbol not found. missing library? 1 have imported right java.util.* assuming java , not javascript, want this: for(int i=0; i<plaintextupper.length()-1; i++) { system.out.println(plaintextupper.codepointat(i)); } note not process last character of plaintextupper . want either rid of -1 or change comparison operator <= in for termination test.

Can I set a variable to a variable combination in javascript? -

this question has answer here: access javascript variables dynamically 4 answers here's code: var album1 = "first album name"; var album2 = "second album name"; var album3 = "third album name"; var album4 = "fourth album name"; var album5 = "fifth album name"; var currentalbumctr = 1; var currentalbum = album + currentalbumctr; currentalbum should set album1 if currentalbumctr 1. can help? you use eval achieve want, wrong way it. why not use array: var album = []; album[1] = "first album name"; album[2] = "second album name"; album[3] = "third album name"; album[4] = "fourth album name"; album[5] = "fifth album name"; currentalbumctr = 1; currentalbum = album[currentalbumctr]; or, alternatively, var album = { "1": "first al

javascript - Time Graph in Flot issue? -

i trying graph month out in flot (per day) or possibly every other day, have tick. to time values, doing this: $date = strtotime($rowdata[0]); // 2013-01-01 $mydata = json_encode(array($date*1000, 1234)); // echo out array javascript var. for reason, can change line: minticksize: [1, day] 2 (label every other tick think) , nothing change. also, time values not showing well? doing wrong? here jsfiddle here update every 2 days...is there rendering issue? also, why oct 10, date shown? : jsfiddle update here have far javascript goes: var mydata = [[1380603600000,0],[1380690000000,0],[1380776400000,0],[1380862800000,0],[1380949200000,0],[1381035600000,0],[1381122000000,0],[1381208400000,0],[1381294800000,0],[1381381200000,0],[1381467600000,0],[1381554000000,0],[1381640400000,1],[1381726800000,0],[1381813200000,0],[1381899600000,0],[1381986000000,0],[1382072400000,0],[1382158800000,0],[1382245200000,0],[1382331600000,0],[1382418000000,0],[1382504400000,0],[1382590800000,0]