Posts

Showing posts from May, 2010

bash - Time zone to 24 hours -

i trying convert time zones usual format date +%z giving, 24 hour system. what mean when ask for # date +%z +0300 i want get # date +%z | something_in_awk_or_perl 3 but, when # date +%z -0700 i want # date +%z | something_in_awk_or_perl 17 p.s. prefer one-line solution thanks! how using awk: $ tz=utc-1 date +%:::z | awk 'begin{fs=ofs=":"}{$1=(24+$1)%24}1' 1 $ tz=utc+7:30 date +%:::z | awk 'begin{fs=ofs=":"}{$1=(24+$1)%24}1' 17:30 if want decimal output, change output separator , divide 6: $ tz=utc-1 date +%:::z | awk -f: 'begin{ofs="."}{$1=(24+$1)%24;$2/=6}1' 1.0 $ tz=utc+7:30 date +%:::z | awk -f: 'begin{ofs="."}{$1=(24+$1)%24;$2/=6}1' 17.5

c++ - How to avoid multiple print in screen? -

i wrote sample program on c++ print student's markdetails using while loop. print records properly. last record print 2 times in screen. have checked in file, there correct. sample code below. fread.open("marks.inf",ios::in); { fread>>name1>>mm1>>mm2>>mm3>>mm4>>mm5; cout<<name1<<'\t'<<mm1<<'\t'<<mm2<<'\t'<<mm3<<'\t'<<mm4<<'\t'<<mm5<<'\t'<<endl; } while(fread); fread.close(); my output is: dinu 90 90 90 90 88 venis 96 49 90 88 78 veni 89 89 88 78 66 veni 89 89 88 78 66 in output, veni print 2 times in screen. how avoid issue?

ios - How do I use CoreLocation to get multiple iBeacons? -

i'm trying use corelocation multiple ibeacons specified ios app- idea if they're in range, it'll notify me each 1 finds them. the problem in didenterregion , didexitregion methods, have provide clbeaconregion object. there's 1 of these every ibeacon, , if using 1 ibeacon, use one, since there several, need know how find each clbeaconregion methods. maybe i'm misunderstanding how works; if so, please let me know. - (void)getforuuuids:(cdvinvokedurlcommand *)command { //get array of uuid's filter self->locationuuids = [self getargsobject:command.arguments]; self->locationmanager = [[cllocationmanager alloc] init]; self->locationmanager.delegate = self; scancallback = command.callbackid; for(nsinteger = 0; < [locationuuids count]; i++) { nsstring *identifier = [nsstring stringwithformat:@"bleregion %d",i]; clbeaconregion *thisregion = [[clbeaconregion alloc] in...

python - how to enable a plugin within django-tinymce? -

i have started using tinymce in django project. need enable plugins come bundled django-tinymce (for example, template). so, within settings.py, have added following configuration: tinymce_default_config = { 'theme': 'advanced', 'relative_urls': false, 'plugins': 'template', 'toolbar': 'template' } max_upload_size = 512000 thinking might enable template plugin, seems not. how enable plugin within django-tinymce? have not found anywhere. thanks suggestions! update: i think had misunderstood how configuration done. have created config.js configuration: tinymce.init({ theme: 'advanced', plugins: 'template', height: '350px', width: '1000px' }); then, have linked mymodeladmin.media. (i'm loading editor django-admin.) class mymodeladmin(modeladmin): class media: django.conf import settings js = ( settings.static_url + ...

SQL Datetime Convert Error -

i have have sql statement returns following error: the conversion of varchar data type datetime data type resulted in out-of-range value. select * ebv_platz (adrid = 4436) , (id <> 5) , (status = 1) , (convert(datetime, '01.03.2014', 102) >= placefrom) , (convert(datetime, '01.03.2014') <= placeto) or (convert(datetime, '31.03.2014') >= placefrom) , (convert(datetime, '31.03.2014') <= placeto) but 1 works fine , difference date values: select * ebv_platz (adrid = 4436) , (id <> 5) , (status = 1) , (convert(datetime, '01.01.2000', 102) >= placefrom) , (convert(datetime, '01.01.2000') <= placeto) or (convert(datetime, '01.06.2001') >= placefrom) , (convert(datetime, '01.06.2001') <= placeto) i don't understand this. can me? i'm betting second 1 not work fine, rather converts dates january 06 , january 01. you need give hint using day month y...

c# - Use mutext to detect and call started process -

how can use mutex find first process guid , call function in ? in web browser when try start second time open new window. // appguid const string containing app guid using (mutex mutex = new mutex(false, "global\\" + appguid)) { if (!mutex.waitone(0, false)) { // code find , call first process , exit environment.exit(0); } else { app app = new app(); app.initializecomponent(); app.run(); } } i think there lot of ways tackle " oh opened second instance, allow one, lets proxy request first instance " problem. you have host process listening on socket , when mutex detects been opened call listening socket. maybe use simple .net remoting, no real need go full blown wcf here or raw socket writing you have shared memory buffer , write using shared memory. require synchronization between 2 processes, can kinda messy you trigger file , have host process listening file events in known locati...

Sort an array in Javascript/JQuery -

this question has answer here: how sort array of objects jquery or javascript [duplicate] 6 answers there array emails having few attributes to, from, subject, description . retrieve records database , populate rows in array. use access rows follows: (var = 0; < emails.length; i++) { var = emails[i].to; var sender = emails[i].sender; var subject = emails[i].subject; var description = emails[i].description; } now need sort array alphabetically to values , store sorted emails in array sortedemails . how can in easiest possible way in javascript/jquery? thanks. arrays in javascript have sort function. emails.sort(function(a, b) { if (a.to < b.to) { return -1; } else { return 1; } }

sql - @gmail SQLite Error Android Email ID Key -

this part of code: string selectquery = "select * " + table_conv + " " + key_emailid + " = " + user_emailid; while trying query using: cursor cursor = db.rawquery(selectquery, null); i'm getting: sqlite error code 1 @gmail try .. appending ' . might solve ur problem string selectquery = "select * " + table_conv + " " + key_emailid + " = '" + user_emailid +"'";

Creating a Facebook share button with customized url, title and image -

facebook used allow custom parameters in facebook share button, not working now. need create facebook share button have custom title, url, image, description, etc. cannot done using meta tags because there multiple share buttons on single page. each should have different title, urls, images etc. heard can done using facebook app - using app id or something. i tried it's not working: <a title="send facebook" href="http://www.facebook.com/sharer.php?s=100&p[title]=your_title&p[summary]=your_summary&p[url]=your_url&p[images][0]=your_image_to_share_object" target="_blank"> unfortunately, appears can't post shares individual topics or articles within page. appears facebook wants share entire pages (based on url only). there's new share dialog , though claim can of old sharer.php do, doesn't appear true. and here's facebooks 'best practices' sharing.

Progammically change multiple buttons with for loop C# -

im trying this: list<int> listname = new list<int>(); for(int i; <= listname[0];i++) { button(i).enabled = false; } ... disable buttons 1 i. best way of doing this? thanks. there few ways bulk modify controls. example 1 (putting them in list) list<button> buttonstodisable = new list<button>() { button1, button2 }; foreach (var button in buttonstodisable) { button.enabled = false; } example 2 (putting them in same container iterating on controls in container) foreach(var button in groupbox1.controls.oftype<button>()) { button.enabled = false; } example 3 (subfixing controls id) list<int> buttonsubfixid = new list<int>() { 1, 2 }; foreach (var id in buttonsubfixid) { var controls = this.controls.find("button" + id.tostring(), true).oftype<button>(); if (controls.count()>0) { foreach (var button in controls) { button.en...

java - Coverting roman numeral exceptions to decimal -

for class homework need create program converts roman numerals decimal form. can convert fine long there no exception characters such iv or ix. how check these exceptions? attempt translate both current character , next 1 decimal, compare them , if next 1 (going right left) smaller subtract it. problem out of bounds errors this. my current code this: scanner keyboard = new scanner(system.in); string roman; int decimal = 0; int number = 0; system.out.print("enter roman numeral convert decimal form: "); roman = keyboard.next(); roman = roman.touppercase(); (int count = roman.length()-1; count >= 0; count--) { char numeral = roman.charat(count); switch (numeral){ case 'i': decimal = 1; break; case 'v': decimal = 5; break; case 'x': decimal = 10; break; case 'l': decimal = 50; break; case ...

php - Ignore Slash while using encryption in codeigniter -

i have problem encrypt/decrypt email, send link on mail this http://www.domain.com/mycontroller/myfunction/mcvbsce........etc the last segment encrypted email id, decrypt email , update stus in db when user click on link.all done right. problem: when url this http://www.domain.com/mycontroller/myfunction/mcvb/sce it shows 404 error, because slash included in generated encryption key.how can ignore slash while generate encryption, that's main problem, rest working fine. you need use class, include file in applicatio/libraries folder, had same issue: class my_encrypt extends ci_encrypt { /** * encodes string. * * @param string $string string encrypt. * @param string $key[optional] key encrypt with. * @param bool $url_safe[optional] specifies whether or not * returned string should url-safe. * @return string */ function encode($string, $key="", $url_safe=true) { $ret = paren...

php - Inserting Record into Database with CakePHP Results in Foreign Key Violation -

i'm cakephp (a few days) , i'm having issues inserting records foreign keys. basic idea, warehouses. i have warehouses table holds available warehouses , have warehouse_types table hold different types of warehouses. warehouse_types table has data in it. i have simple add view (based off blog example in cakephp's cookbook) , have displaying names of different types database. when save page database error. error: sqlstate[23000]: integrity constraint violation: 1452 cannot add or update child row: foreign key constraint fails (`kvs`.`warehouses`, constraint `warehouses_ibfk_1` foreign key (`warehouse_type_id`) references `warehouse_types` (`id`)) the sql being generated is: sql query: insert `kvs`.`warehouses` (`name`, `location`, `modified`, `created`) values ('name text', 'location text', '2014-04-02 12:07:13', '2014-04-02 12:07:13') if output information in request->data object, shows getting value warehousetype_...

cuda - CUBLAS: Incorrect inversion for matrix with zero pivot -

since cuda 5.5, cublas library contains routines batched matrix factorization , inversion ( cublas<t>getrfbatched , cublas<t>getribatched respectively). getting guide documentation, wrote test code inversion of n x n matrix using these routines. code gives correct output if matrix has non 0 pivots. setting pivot 0 results in incorrect results. have verified results using matlab. i realize providing row major matrices input while cublas expects column major matrices, shouldn't matter transpose result. sure, tested on column major input, getting same behavior. i confused as, cublas<t>getribatched expects pivot exchange information array p input, output cublas<t>getrfbatched . so, if 0 pivots eliminated row exchange, inversion routine should handle automatically. how perform inversion of matrices contain 0 pivot using cublas? following self contained compile-able example different test cases: #include <cstdio> #include <cstdlib> ...

javascript - How to measure client side performance in single page application -

we developed complex single page application based on sencha ext.js framework. there many "pages" in application changing dynamically without refreshing browser's url. user's interaction , content changing dynamically created , destroyed. we want measure client side stability , performance along time. test should focus on client side behavior , responsiveness. don't need test server side response time - same response time granted during test. all tools saw exists dealing xhr response time , based on load time per url not relevant on our case - because same url continuing , doing work along time. any suggestion practice , tools kind of test? thanks in advanced. if think ajax monitoring , page load time not you, can suggest can use transaction monitoring. can done measuring time between 2 states or 2 pages. to test locally, using console.time : console.time('page_name'); // goes here console.timeend('page_name'); usi...

javascript - Does interrupting ajax function stop it from being completed? -

what i'am trying converting video using ffmpeg take long time complete sending ajax request server without making user wait until video conversion done. if user refresh page after request sent dose stop function form completing ? way or should make queue video converting ? you can use following structure; when user started video conversion, send request backend via ajax convert when request sent, can set cookie on server side (it can readable on browser also). after request sent, can show processing bar. when user refresh page, check cookie value if video conversion started or not. if exists, can continue showing progress bar again. when conversion finished, can set cookie value done, , ajax check call tell status of conversion user. i assume making ajax call in specific time interval status of conversion. if not using ajax poll , can use websockets send result browser client. cookie values can modifiable client, if encrypt cookie value, or make video con...

Creating a secure login script in PHP and MySQL without HTTPS -

question is this post on wikihow reference create secure login script in php , mysql? in warnings section, author(s) emphasizes code can used https. not able use https, need implement relatively secure login script in php , mysql, , therefore wondering if script implemented http connection well. solved a third party solution best solution create secure login script in php , mysql. utilizing php framework (e.g. symfony, ulogin) or external parties (e.g. facebook, google), need create entirely new working login script plus authorization (the remember-me functionality) can avoided. if others have done thorough research , gained experience create login functionalities, safer , easier use work. although create login system yourself, recommended let external parties you. it takes lot of experience right, , done wrong. although tutorial looks okay me, there many factors consider, , seems semi-old. php 5.5 offers password_hash , password_verify , recommend on page su...

c++ - (extract from istream and insert into ostream) operation: is >><T> os; -

i trying overload operator>> in order extract type t istream x; , insert ostream y; , i.e. x >><t> y; . with template<class t> istream& operator>>(istream& is, ostream& os) { t a; >> a; os << a; return is; } the prefix notation operator>><string>(x,y); compiles, postfix notation x >><string> y; fails compile with test.cpp:29:9: error: expected expression x >><string> y; ^ test.cpp:29:10: error: unexpected type name 'string': expected expression x >><string> y; ^ 2 errors generated. and guess >><t> notation not valid. just curious if there way postfix version compile? or maybe thoughts whether extract/insert operator makes sense @ all? short answer, no. operator overloading proceeds according strict grammatical rules, binary operator @ , expression a @ b considers overloaded functions (a).operat...

qt - How to add data to a created form? PyQt/Python/SQL -

i have created basic form layout using splitters qlistwidget , qtextbrowser. wanted know how import data sql database (or add simple text i.e. string) listwidget boxes. once user clicks on piece of data within listwidget box, how show (in detail) expansion of data in textbrowser box?? also, how fix splitter, user cannot move, adjust splitters?? the code below: import sys, random, time, math, re pyqt4 import qtgui, qtcore class mainwindow(qtgui.qmainwindow): def __init__(self, parent=none): super(mainwindow, self).__init__(parent) self.grouplist = qtgui.qlistwidget() self.messagelist = qtgui.qlistwidget() self.messageview = qtgui.qtextbrowser() self.messagesplitter = qtgui.qsplitter(qtcore.qt.vertical) self.messagesplitter.addwidget(self.messagelist) self.messagesplitter.addwidget(self.messageview) self.mainsplitter = qtgui.qsplitter(qtcore.qt.horizontal) self.mainsplitter.addwidget(self.grouplist) ...

binary search tree - TreeNode cannot be cast to java.lang.Comparable? -

i trying write method returns parent specified node (bst), keep getting this: treenode cannot cast java.lang.comparable any suggestions on how fix this? thanks! here method (is located @ end!) - (the whole code): import java.util.arraylist; import chapter27.abstracttree; public class test<e extends comparable<e>> extends abstracttree<e> { protected treenode<e> root; protected int size = 0; /** create default binary tree */ public test() { } /** create binary tree array of objects */ public test(e[] objects) { (int = 0; < objects.length; i++) insert(objects[i]); } @override /** returns true if element in tree */ public boolean search(e e) { treenode<e> current = root; // start root while (current != null) { if (e.compareto(current.element) < 0) { current = current.left; } else if (e.compareto(current.element) > 0) { current = current.right; } else // element matches current.element return true; // element f...

vb.net - Data tables failed to join together with SQL JOIN INNER command -

i'm trying join 2 data tables in vb contained in same ms access database file , process series of data binding process new merged table system return me error message says following: an unhandled exception of type 'system.data.oledb.oledbexception' occurred in system.data.dll additional information: cannot join on memo, ole, or hyperlink object (students.stid=grades.stid). the following code: private sub form3_load(sender object, e eventargs) handles mybase.load dim constr string = "provider = microsoft.ace.oledb.12.0;" & "data source = c:\users\johnnycheng\documents\gradebook.accdb" dim sqlstr1 string = "select firstname, lastname students inner join grades on students.stid = grades.stid" dim da = new oledb.oledbdataadapter(sqlstr1, constr) dim dset new dataset() dim source new bindingsource() da.fill(dset) da.dispose() source.datasource = dset.tables(0) bindingnavigator1.bindingsource = sour...

memory management - Make objects created inside loop available for GC in java -

object ready garbage collection, java says object becomes available gc when function ends. if creating objects inside loop, how make sure become available gc before termination of function e.g void foo{ for(int = 0; < 10000; i++){ object o = new object(); /*some operation*/ } } since there many objects created inside loop, want objects available gc before function ends. will making null after use make available gc or have same effect above. e.g void foo{ for(int = 0; < 10000; i++){ object o = new object(); /*some operation*/ o = null; } } object ready garbage collection, java says object becomes available gc when function ends. no doesn't. wrote answer, , doesn't such thing. what says stack slot remains until function exits. in case of code, objects created inside loop except last 1 become unreferenced next 1 created, because prior reference in same stack slot overwritten. see comment @thilo, ...

excel - To import data from file to existing workbook using Vlookup -

i have main workbook , sub workbook macro commands open 1) main workbook = database worksheet in main workbook = customer database sub workbook = orders these 2 books open macro run. 1) need import data range c:f orders customer database b:e if cell b orders contains new member 2) worksheet in database contains data. hence, want add on existing sheet in database please help. dim wssource worksheet dim wbsource workbook dim wstarget worksheet dim wbtarget workbook dim findrange range dim lastline integer dim file string file = "orders.xlsx" set wbsource = thisworkbook set wssource = wbsource.sheets(1) set wbtarget = workbooks.open(file) set wstarget = wbtarget.sheets(1) wstarget.activate set findrange = wstarget.range("c2:f389") findrange.replace what:="xxx-string",replacement:=wssource.range("b2:e2").value, lookat:=xlpart, searchorder:=xlbyrows, matchcase:=false lastline = wbsource.sheets(1).range("x65536")....

objective c - How to use Retain and Release in IOS Application? -

i working on ios application.when using flicker api's in application getting semantic issues can't use libraries bcoz os release , retain used in library.i working on xcode 5.1? please me how can use such library in application? select project in sidebar > build phases > compile sources add flag -fno-objc-arc files in question.

How to write path redirect in ruby on rails and angularjs -

Image
sorry new ruby on rails. i trying create directive in angularjs. doing create html file in folder view/forms, named topright-buttongroup.html then created simple directive test: app.directive('toprightbuttontools', function(){ return { restrict: 'c', templateurl: 'topright-buttongroup.html' }; }); but getting error message in console is: get http://localhost:3000/forms/topright-buttongroup.html 404 (not found) am missing should done on ruby on rails? or should write redirect code , save in somewhere? my full folder structure is: if need form accessible so, create folder inside public / forms / , have file placed there. content inside public dir rendered directly. unlike core php or other such scripting languages, ror requires controllers render actions arent merely files interpreted. also, routes defined in config/routes.rb. refer: http://guides.rubyonrails.org/routing.html http://www.xyzpub.com/...

git svn - Branch name starting with '-' in git -

i moving svn git using git-svn, , of branches names started '-'. form this question , this migration documentation able pass parameters starting '-'. on creating branch git returns error stating: fatal: '-closed-mybranch' not valid branch name. i using gitlab. command running create branches is: git for-each-ref refs/remotes | cut -d / -f 3- | grep -v @ | while read branchname; git branch -- "$branchname" --"refs/remotes/$branchname"; git branch -r -d -- "$branchname"; done this articles explains legal branch names , think branch name legal. can tell me problem be? ps: branch name not starting '-' imported. it doesn't seem can create branch name starts dash: $ git branch "-test" error: unknown switch `e' it apparently thinks i'm trying set git branch option -t , , gives error on following e . it doesn't work command: $ git checkout -b "-test" fatal: ...

java - Use Tomcat connection pool in JAR (shared conf from web app, spring configuration) -

i have few web applications deployed on tomcat use same database access configuration tomcat connection pool: <bean id="datasource" class="org.springframework.jndi.jndiobjectfactorybean"> <property name="jndiname" value="java:comp/env/jdbc/postgres"/> <property name="lookuponstartup" value="true"/> <property name="proxyinterface" value="javax.sql.datasource"/> </bean> (web.xml in each project , context.xml in tomcat set properly, because works :)). i use connection jar files run on same server. in jar use spring, following error if use above datasource definition in code this: string[] springconfig = { "file:/var/pro/conf/data-access.xml"}; context = new classpathxmlapplicationcontext(springconfig); i following error: exception in thread "main" java.lang.exceptionininitializererror @ java.lang.class.forname0(nat...

javascript - Angular JS - How to add extra DIV in ng-repeat -

i have array a=[1,2,3,4,5,6] . using ng-repeat on array, creating 6 divs . please refer plunker is there way add 1 more div after each row. after 3 divs want add 1 div . i looked this example. creating child div . possible create sibling div in ng-repeat let's try ng-repeat-start & ng-repeat-end. <div class="example-animate-container"> <div class="square" ng-repeat-start="friend in a"> {{$index}} </div> <div ng-if="$index % 3 == 2" ng-repeat-end> div </div> </div> please note ng-repeat-start directive included since angular 1.2.1. plnkr demo ng-repeat: repeat series of elements of "one" parent element <!--====repeater range=====--> <any ng-repeat="friend in friends"> </any> <!--====end of repeater range=====--> ng-repeat-start & ng-repeat-end: using ng-repeat-start , ng-repeat-end define start poin...

having problems with mysql statement where and or based on user input -

$query = "select username, email, password, salt tbl_memembers (username = $resetuser) or (email = $resetuser)"; this keeps returning there nothing in database, when know fact there matching details entered ($resetuser = $_post previous page) try query $query = "select username, email, password, salt tbl_memembers username = '$resetuser' email = '$resetuser' ";

api - How can I extract artist and song information from Youtube music videos? -

Image
i know "extracting song or artist names youtube" not possible using youtube's data api. however, have found several websites have extracted artist or song names successfully. guess using machine learning or else. is there common practice extracting artist or song names? you can extract artists , song titles description, though there 1 downside, information may not appear in countries (outside of united states), need proxy located in u.s, can use yahoo's yql service avoid issue. div element "watch-description-extra-info" have information need.

javascript - Toggling button classes and text -

i trying change text , icons jquery. when click @ button changes, when click button again struggles. icon , text not change default. code behind string box = "<div class=\"alter-wrp\"> <div class=\"alert alert-danger {0}\">{1}</div></div>"; if(count > 0) litalert.text += string.format(box); asp.page <button class="btn btn-dangerr btn-lg" type="button"><span class="glyphicon glyphicon-bell beee"></span> <span class="text">show alarm</span> </button> <asp:literal id="litalert" runat="server"></asp:literal> jquery $('.btn-dangerr').click( function(e) { var tgl = $('.btn-dangerr'); var box2 = $('.alter-wrp'); var icon = $('.glyphicon'); var text = $('.text'); var toggleclass = '.beee...

javascript - Number TypeError with Mongoose Model? -

there's 500 internal server error, error: typeerror: path must string the browser console points itemctrl.js:35 console.log('error: ' + data); the stack trace error looks this: typeerror: path must string @ query.where (/users/name/downloads/dev/v16/node_modules/mongoose/lib/query.js:593:11) @ function.where (/users/name/downloads/dev/v16/node_modules/mongoose/lib/model.js:1040:18) @ model. (/users/name/downloads/dev/v16/app/models/item.js:44:35) ... it seems error derives line in /app/models/item.js in else if statement.. because else if commented out, both if works , else works.. // load mongoose since need define schema , model var mongoose = require('mongoose'); var itemschema = mongoose.schema({ title : string, position: number }); // before validation starts, number of items counted..afterwards, position set itemschema.pre("validate", function(next) { var doc = this; // if 'position...

python - How to find multiple instances of my training image with OpenCV and SIFT -

Image
so far i've been able detect key points training image within query image accurately using bfmatcher. however, have dozens of instance of training image (a bee) occurring within query image (the frame of beehive). possible use sift multiple independent instances of image? ideally, i'm hoping point wit above image can match 4 key points query image against multiple independent bees. i don't know opencv enough know if offers routines help. said, math diy isn't bad if have numerical library svd e.g. numpy. in lowe's 2004 paper, match determined ratio of 2 closest matches. if compute keypoints in 'query image' , apply criteria return multiple results if present (any 2 keypoints in database same ratio +/- epsilon match). however, can result in spurious matches. so, in addition basic test lowe paper, ransac can used discard candidate matches not consistent homography between 'training image' , 'query image'. see 'distinctive imag...

javascript - lineTo on HTML 5 canvas not working properly -

i'm trying learn canvas. i trying draw lines using moveto() , lineto() on canvas. the co-ordinates give , point rendered on canvas not matching i have taken canvas of size 500px x 500px for (0,0) coming fine. for other points not matching co-ordinates for (300, 150) painting @ (500,500). i'm not getting why happening because if set canvas size t0 300px x 150px painting correctly here js var context = document.getelementbyid("mycanvas").getcontext("2d"); context.moveto(0, 0); context.lineto(100, 100); context.lineto(100, 100); context.lineto(200, 100); context.lineto(300, 150); context.stroke(); jsfiddle here can 1 please tell me i'm wrong set height , width of canvas element directly: <canvas id="mycanvas" width="500" height="500"> </canvas> fiddle: http://jsfiddle.net/nluex/2/

mysql - Check row exist or not in Ruby on Rails -

i new ruby on rails , have basic knowledge of mysql. using mysql db. question -- how check if row exists or not in table. have tried code it's not going straight else block, not if block: @tasks = user.find_by("user_name = ? , password = ?", params[:user_name], params[:password]) if @tasks redirect_to action: 'index', status: 302 else redirect_to action: 'detail', status: 302 end if want find if user given name , password exists using ruby on rails, can this: user.where(user_name: params[:user_name], password: params[:password]).exists? see railsguides: existence of objects . the cause of original problem? so code original poster submitted: user.find_by("user_name = ? , password = ?", "#{params[:user_name]}", "#{params[:password]}") i removed string interpolation because unnecessary user.find_by("user_name = ? , password = ?", params[:user_name], params[:password]) and apparently ...

Javascript eventListener keydown not working EVERY time I click -

i have following code should execute each time hit f9 or f10, every other time hit it? i have onchange event attached select box not firing every time hit f9 or f10, every other time or so. can tell alerts firing every other time hit key. what gives? document.addeventlistener('keydown', function(e){ if( e.keycode == '120' ){ alert("yo"); var curposition = document.getelementbyid('unpostedorders').options.selectedindex; document.getelementbyid('unpostedorders').selectedindex =(curposition-1); var invoice = document.getelementbyid('unpostedorders').value; getordertomodify(invoice); } if( e.keycode == '121' ){ alert("gibear"); var curposition = document.getelementbyid('unpostedorders').options.selectedindex; document.getelementbyid('unpostedorders').selectedindex =(curposition+...

java me - Command issue in J2ME -

currently working on j2me app , facing command issue in j2me. when adding command on form coming under options, not coming directly on screen. command selcommand = new command("select"); this select command not coming directly on screen, options coming on screen click on option command select command coming. i want select command on screen instead of option. high level gui coding in javame doesn't let decide how command should displayed. same code may display command directly on screen on devices, under options on other devices. don't have control of that. your best chance priorities. setting high priority on command , may lucky displays directly on screen instead of under options. not should count on though, since it's not required specification, suspect @ least many devices that.

directory structure - Location for 3rd party component that will be used during the build (gradle) -

we have 1 project reuses 3rd party war (it's shindig-server-2.0.2.war if asks:). war sits in project root , current ant tasks unzips temp folder, performs several changes (like applying fixes, modifies web.xml etc.) , build war our sources , war content. 3rd party checked source repo. we migrating gradle. should put file in maven directory structure? it not belongs /src/main/resources not packed withing artifcat; also, imho not belong /src , too. should have /lib/resources folder in root store such files? i don't think maven directory structure defines place local dependencies, , since gradle build, doesn't matter either. wouldn't put under src , lib sounds fine.

android - Error NoSuchMethodError: com.example.new.MainActivity.getActionBar -

this question has answer here: nosuchmethoderror error getactionbar() (api-8) 6 answers i writing app in getting nosuchmethoderror: getactionbar , app supports minimum 9 api level. i using android-support-v7-appcompat.jar java.lang.nosuchmethoderror: com.example.new.mainactivity.getactionbar @ com.example.new.mainactivity.oncreate(mainactivity.java:48) @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) @ android.app.activitythread.performlaunchactivity(activitythread.java:1611) @ android.app.activitythread.handlelaunchactivity(activitythread.java:1663) @ android.app.activitythread.access$1500(activitythread.java:117) @ android.app.activitythread$h.handlemessage(activitythread.java:931) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:130) @ android.app.activitythread.main(activitythread.java:368...