Posts

Showing posts from February, 2014

.htaccess - What's wrong with my RewriteRule? It seems ok, but it doesn't work -

i have rewrite rule on webpage. rewriteengine on rewriterule ^(.*) index.php?p=$1 [l] i want work rewrites urls this: http://example.com -> index.php http://example.com/home -> index.php?p=home http://example.com/lol -> index.php?p=lol but when use following php code inside index.php print_r($_get) it gives this: array ( [p] => index.php ) it gives same results in urls (i tried these: http://example.com , http://example.com/ , http://example.com/about , http://example.com/about/ can me debig this? i got figured out: the correct code this: rewriteengine on rewriterule ^([^.]+)/?$ index.php?p=$1 [nc,l] sorry question.

java - Android, Adapter adding extra element to array? -

Image
i have adapter create 16 buttons in gradview, buttons being created im give tag , add array, reason when print log shows me 17 elements...any ideas why contains 17 elements when create 16 buttons... public class buttonadapter extends baseadapter { private context mcontext; arraylist<string> colorsarray = new arraylist<string>(0);// add button tags public buttonadapter(context c) { mcontext = c; } public int getcount() { int = 16;// how many tiles adapter display , create in // grid view, refrenced in oncreate method below return a; } public object getitem(int position) { return null; } public long getitemid(int position) { return 0; } public view getview(int position, view convertview, viewgroup parent) { final button button; if (convertview == null) { int r = 1 + (int) (math.random() * 5); button = new button(mcontext)

javascript - Very simple jquery custom function throws error -

i have following code: $(document).ready(function() { $.fn.addremovebutton = function() { alert(1); }; $.addremovebutton(); }); and following error message firebug: typeerror: $.addremovebutton not function $.addremovebutton(); why , how can fix this? you need define selector, try this: $(document).ready(function() { $.fn.addremovebutton = function() { alert(1); }; $(document).addremovebutton(); }); here working jsfiddle.

How to access Redis log file -

have redis setup ruby on ubuntu server, can't figure out how access log file. tutorial says should here: /var/log/redis_6379.log but can't find /var/ folder found with: sudo tail /var/log/redis/redis-server.log -n 100 so if setup more standard should be: sudo tail /var/log/redis_6379.log -n 100 this outputs last 100 lines of file. where log file located in configs can access with: redis-cli config * the log file may not shown using above. in case use tail -f `less /etc/redis/redis.conf | grep logfile|cut -d\ -f2`

Garbage collector in Ruby on Rails? -

i have tried google lot rails garbage collector, didn't reliable answer. has got source show how garbage collection implemented in rails? how can control it? rails framework, not language. language behind rails called ruby. this means there no notion of garbage collector in rails. should search documentation ruby garbage collector. you can start ruby gc module . gc module provides interface ruby’s mark , sweep garbage collection mechanism. depending on ruby language version, garbage collector may have different behavior. article how ruby manages memory , garbage collection describes ruby 1.9 garbage collector. in ruby 2.0 gc has been improved , implementation changed bit .

jquery - jqm+backbone.Js+require.Js show loading message before page load -

i' m using jquery mobile 1.1, want show loading message before page load using backbone router. mobile init code is $(document).bind("mobileinit", function() { $.mobile.ajaxenabled = false; $.mobile.linkbindingenabled = false; $.mobile.hashlisteningenabled = false; $.mobile.pushstateenabled = false; $.mobile.showpageloadingmsg="loading";} but loading message not shown. suggestions? usual way not going because jquery mobile show loader if page loading dom more 10ms, hide when page loaded dom. if page complex long before page show. but can manually show/hide it. here's working example: http://jsfiddle.net/gajotres/qx7yn/ $(document).on('pagebeforecreate', '[data-role="page"]', function(){ var interval = setinterval(function(){ $.mobile.loading('show'); clearinterval(interval); },1); }); $(document).on('pageshow', '[data-role="page"]', function(

javascript - Regex for valid url -

i require validate urls should like google.com or yahoo.co.uk etc i mean dont require http or www. regex code this.but doesnt work me. /^[a-za-z0-9][a-za-z0-9-][a-za-z0-9]\.[a-za-z]{2,}$/ your current regex doesn't work because expects 3 characters before . : first character matches [a-za-z0-9] , character matches [a-za-z0-9-] , character matches [a-za-z0-9] . regex permits single . anywhere in input. for variable length strings need use + or * or {} syntax last part of regex. to keep same validation seem shooting have work varying lengths, try: /^[a-z\d-]+(\.[a-z\d-]+)*\.[a-z]{2,}$/i that is: [a-z\d-]+ match 1 or more letters, digits or hyphens, followed by (\.[a-z\d-]+)* 0 or more instances of dot followed 1 or more of characters, followed by \.[a-z]{2,} final dot 2 or more of a-z. note can upper-case a-z range if add i flag regex make case-insensitive.

ios - Image not showing up in UITabBarItem -

i using uitabbar , uitabbaritem . have url of image . set uitabbaritem's image image using url. image not showing up. if use other image macbook, works. url correct, verified copy pasting in browser. below code. can see problem? uiimage * iconimage = [uiimage imagewithdata:[nsdata datawithcontentsofurl:[nsurl urlwithstring:singlematch.imageurl]]]; // add uitabbaritem array [tabs addobject:[[uitabbaritem alloc] initwithtitle:singlematch.realname image:[self convertimage:iconimage tosize:cgsizemake(40, 30)] tag:i]]; [self.chattabbar setitems:tabs animated:yes]; i use below method resize image fit in uitabbaritem // resizes given image specified cgsize - (uiimage *)convertimage:(uiimage *)image tosize:(cgsize)size { uigraphicsbeginimagecontextwithoptions(size, no, 0.0); [image drawinrect:cgrectmake(0, 0, size.width, size.height)]; uiimage * resizedimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); return resizedimage; }

how to disable the automatic mapping of std::vector<std::vector<double> > to tuple of tuples in swig python? -

apparently, swig transform automatically std::vector<std::vector<double> > tuple of tuples. want prevent this, , want type kept is. how can achieve it? tried specifying definition type %template(stdvectorstdvectordouble) std::vector<std::vector<double> >; but apparently not work. two techniques: %clear typemap type before function processed swig. declare %template after function processed swig. example 1 %module x %begin %{ #pragma warning(disable:4127 4211 4701 4706) %} %include <std_vector.i> %template(vd) std::vector<double>; %template(vvd) std::vector<std::vector<double> >; %clear std::vector<std::vector<double> >; %inline %{ #include<vector> std::vector<std::vector<double> > func() { std::vector<std::vector<double> > temp; std::vector<double> a; a.push_back(1.5); temp.push_back(a); return temp; } %} example 2 %module x %begin %{

select value of 2 html select element witht the jquery -

i have situation have select dropdown value this $(this).parent().parent('div').find('option:selected').val(); later realized need put 2nd ddl there in same div, become confuse how fetch value of each of ddl. there way apply id code $(this).parent().parent('div').find('option:selected').val(); so can fetch each. following code first ddl. <select style="width:30px" name="ddlqty" id="ddlqty" class="positive-integer"><option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9"

java - How to reverse a String array based on it's index value -

i want reverse this: customarray = myarray; namearray = new string[myarray.size()]; (int = 0; < myarray.size(); i++) { idarray[i] = myarray.get(i).getunitid(); namearray[i] = myarray.get(i).getunitname(); } if (sorttype == sort) arrays.sort(idarray, collections.reverseorder()); arrays.sort(namearray, ...); i know how reverse using arrays.sort(stringarray, collections.reverseorder()); not index value. how can reverse order of namearray based on it's namearray[i] ?.. or better, since idarray list of unique id's sort namearray based on idarray. the solution problem use oop approach. after all, java oop language. instead of having 2 arrays: int[] unitid string[] unitname which can't sort in way indexes stay corresponding, write class unit implements comparable<unit> , use 1 array: unit[] units then arrays.sort(units); will job. you need own class: public class unit implements comparable<unit> { priv

JBoss AS6.1 will not use log4j appenders - probably a bug? -

i want use log4j appenders in jboss 6.1 deployment. having trouble getting work, wrote test code , noted org.apache.log4j.logger.getlogger(string) returning object of type org.jboss.logmanager.log4j.bridgelogger. so figured had 2 options: (1) try getlogger call return apache log4j type rather jboss bridgelogger, or (2) accept jboss doing sort of bridging , use log4j appenders have written need use. so trying first of options: logger.getlogger() delegates logmanager.getlogger(string), does: return getloggerrepository().getlogger(string); the repositoryselector static in logmanager , set this: hierarchy h = new hierarchy(new rootlogger((level) level.debug)); repositoryselector = new defaultrepositoryselector(h); but logmanager has setrepositoryselector, conclusion came in jboss startup process calling setrepositoryselector. test called setrepositoryselector test logging code (setting ti defaultrepositoryselector static initializer of logmanager does), , checked type of lo

Android Camera Issue -

hi helper new android programming ,i developing simple app in 1 image button 1 imageview,and 2 normal buttons name save , confirm working: per idea app launched 1 image button when user click on button camera intent opened user click image finished activity gets starting intent 1 more control imageview in pic capture displayed plus button named save user clicks on save button save button gets invisible , confirm button gets visible when user click on confirm image in imageview must saved in sd card . bug: when user clicks on confirm display toast "something went wrong",i tried explore emulator pic capture not available ,even no error in log-cat ,nor app gets crash please tell me wrong in code public class mainactivity extends activity implements onclicklistener { imagebutton ib; button bconfirm, bsave; imageview iv; intent i; final static int cameradata = 0; bitmap bmp; file path = null; file file = null; string folder = "/sdcard/propertypic"; @

javascript - Why doesn't ko.observableArray.length return length of underlying array? -

using knockout, when working observablearray , must grab underlying array ( myarray() ) in order read length. don't understand why myarray.length wouldn't return underlying array's length (instead returns 0). bug or there reason i've missed? jsfiddle: http://jsfiddle.net/jsm11482/ljvwe/ js/model var data = { name: ko.observable("test"), items: ko.observablearray([ { name: ko.observable("first thing"), value: ko.observable(1) }, { name: ko.observable("second thing"), value: ko.observable(2) }, { name: ko.observable("third thing"), value: ko.observable(3) } ]) }; ko.applybindings(data, document.getelementsbytagname("div")[0]); html <div> <h1 data-bind="text: name"></h1> <ul data-bind="foreach: items"> <li data-bind="text: value() + ': ' + name()"></li> </ul> <div&g

Java - Floating point with limited decimal places but without coma -

i'm developing graphics computing application computer science course. i'm doing many calculations on vectors, i'm getting severe truncations since it's float arithmetics. the problem tried ways of limiting decimal places of float numbers to, example, 2 places. here things tried: 1 - divide , multiply 100. not work times. never works me. 2 - use decimalformat. way of formating works if have numbers under 1000. when have numbers such 1003.3124 formats 1,003.31 . since formating returns string, parse function floats not works because of coma. tried set decimalformatsymbols() setgroupingseparator different chars, includind no space , no lenght char ( '\u0200b', '\u0000', ... ), '?' instead of desired char. 3 - set locale us. since windows running in brazillian portuguese ( here dot , coma have different papers: yours 1,300.42 ours 1.300,42! ) think stupid, it's not question here. solved nothing too. 4 - take string, remove comas ,

c# - How to get keydown/press event in windows service? -

i want develop windows service detect pressed key or start when key pressed. possible? i have created service runs after period of time , update database table. here code have done update database after time time. system.timers.timer timer1 = new system.timers.timer(); private void initializecomponent() { ((system.componentmodel.isupportinitialize)(timer1)).begininit(); timer1.enabled = true; ((system.componentmodel.isupportinitialize)(timer1)).endinit(); } protected override void onstart(string[] args) { try { writelog("test services started @ : " + system.datetime.now); // time elapsed event timer1.elapsed += new elapsedeventhandler(onelapsedtime); int intonelapsedtime = convert.toint32( system.configuration.configurationmanager .appsettings["intonelapsedtime"] .tostring()); timer1.interval = 1000 * 10 * intonelapsedtime; timer1.enable

Why not void is a datatype in C? -

this question has answer here: is void data type in c? 3 answers today 1 student came me , asked me, sir have int , float , char , datatypes in c. when write int i , means i variable of type integer , on float f , char c . similarly have int *i means i pointer integer . same float *f , char *c . and have void* v; in c. void pointer called generic pointer. he asked me can have void pointer, why can't have void v (as datatype)? i speechless. so, requesting pls me. how make him understand. here's how explain it: in higher-level languages, variables represent abstract things, , it's language decide how represent them in bits , push bits around act on things. makes sense allow variable represent concept of "nothing". c not that. c variables actual collections of bits stored in memory. represent programmer. makes no se

android - Change text color of Context Menu item -

this issue, want make text of item in underline turn black color, in white, don't know how change text color these item. me ! could see picture issue : images here ! (focus on red underline item) create xml layout context menu. post below might you. how create context menu using xml file?

wpf - ViewModel support in Portable Class Library -

Image
i trying out pcl in vs 2010 project in support wpf (4 , higher) , silverlight (4 , higher). ms documentation excerpt below confusing me. it seems saying reference system.windows in pcl project, don't see how that. what must have icommand , inotifypropertychanged in pcl project? supporting view model pattern when target silverlight , windows phone 7, can implement view model pattern in solution. classes implement pattern located in system.windows.dll assembly silverlight. system.windows.dll assembly not supported when create portable class library project targets .net framework 4 or xbox 360. the classes in assembly include following: system.collections.objectmodel.observablecollection system.collections.objectmodel.readonlyobservablecollection system.collections.specialized.inotifycollectionchanged system.collections.specialized.notifycollectionchangedaction system.collections.specialized.notifycollectionchangedeventa

java - How do eclipse core plugins update eclipse ui plugins? -

in eclipses plugin architecture, core or model plugin exists handle backend, , ui plugin handles presentation. ui plugin depends on core plugin, core plugin not depend on ui plugin. core plugin not see types in ui plugin. how can notify debug swt widgets of changes occur in core plugins? selectionlistener not valid because want widgets update new changes come in, not when selected in window workbench. not see how general/simple listener can registered model object model object created. gui event based, unless somehow wakes every few milliseconds , seeks out last idebugtarget , registers 1 of views listener, don't see how going work. , bad design smell (manual polling).

wpf - is it possible to list all xaml image tags in c#? -

is there way list of xaml tags (or other tag) in c# in windows phone without giving them names? something : var list = this.getelementsbytagname("image"); you this. foreach(uielement item in yourcontainer.children){ messagebox.show(item.gettype().tostring()); } it return system.window.control.image

ios - How to protect my application data in Documents directory -

how can protect files in application "documents" directory? using ifunbox, or application it, can see, application store in it's documents directory. if want store private data, or information in-apps status, gold, achievments or else in .plist-files not safelly. maybe there best-practices ios application how secure , protect data? it not possible secure data user. naturally secured other applications, user able access on-disk or in memory. that said, if have data user not supposed access, should not store in documents , since backed via itunes. should store in library . see "the library directory stores app-specific files" in file system programming guide details on each possible location , how treated system.

cocos2d iphone - Error in xcode after adding adWhirl/adMod SDK -

i compiling xcode cocos2d project after including adwhirl/admod sdk. getting below error when don't clue. saw similar error? duplicate symbol _main in: /users/rameshjangama/library/developer/xcode/deriveddata/smarty_sg-bevjqrzchdoqlherhrgqjvyiscvk/build/intermediates/smarty sg.build/debug-iphonesimulator/smarty sg.build/objects-normal/i386/main-1c64db92f3446c47.o /users/rameshjangama/library/developer/xcode/deriveddata/smarty_sg-bevjqrzchdoqlherhrgqjvyiscvk/build/intermediates/smarty sg.build/debug-iphonesimulator/smarty sg.build/objects-normal/i386/main-ed4e1b3dcbd8732e.o duplicate symbol _objc_class_$_rootviewcontroller in: /users/rameshjangama/library/developer/xcode/deriveddata/smarty_sg-bevjqrzchdoqlherhrgqjvyiscvk/build/intermediates/smarty sg.build/debug-iphonesimulator/smarty sg.build/objects-normal/i386/rootviewcontroller-214b0a37fe12675b.o /users/rameshjangama/library/developer/xcode/deriveddata/smarty_sg-bevjqrzchdoqlherhrgqjvyiscvk/build/intermedia

sql server 2008 - Group by, Over or other SQL tools to get value corresp to Min or Max -

my here table type | price | date chair| 10 | 04/05/2013 chair| 15 | 03/07/2012 chair| 11 |01/01/2011 sofa | 100 |01/08/2011 sofa | 120 |03/09/2013 sofa | 150 |07/07/2010 for each distinct type pull latest price, result of query should be type | price | date chair | 10 | 04/05/2013 sofa | 120 |03/09/2013 i tried group , over, far no luck you can use subquery max(date) each type: select t1.type, t1.price, t1.date yt t1 inner join ( select max(date) date, type yt group type ) t2 on t1.type = t2.type , t1.date = t2.date; see sql fiddle demo alternatively, can use max(date) on (partition ...) this: select t1.type, t1.price, t1.date ( select max(date) on (partition type) maxdate, type, price, date yt group type ) t1 t1.date = t1.maxdate; sql fiddle demo

Jquery Dialog Too Big? -

the jquery dialog box ridiculously huge , i'm not sure why. manually setting css not appear work either. click 'sign-in' button see dialog box. here site i'm working on. http://crowdfundersecrets.com/wwwteamcrowd/www/index.php for reference later code change here code. <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>teamcrowdfund</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="keywords" content=""> <meta name="author" content=""> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <!--[if lt ie 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"><

web config transform - Powershell Script: prompt a file (by mask) and use that file in a command line -

disclaimer: don't know enough ps accomplish in reasonable amount of time, yes, asking else dirty job. i want able run web.config transformation without opening command line. i have following files in folder: web.config - actual web config web.qa.config - web config transformation qa env web.production.config - web config transformation production env transform.ps1 - powershell script want use run transformation here want: ps file shall enumerate current directory using .*\.(?<env>.*?)\.config , let me choose <env> interested in generate web.config for. in example presented 2 options: "qa", "production". after (user) select environment (let's "qa", selected environment stored $env, , corresponding filename stored $transformation) script shall following: backup original web.config web.config.bak execute following command: . echo applying $transformation... [ctt][1].exe source:web.config transformation:$transforma

ios - Will changing product name in build setting affect update? -

i've changed product name in building settings of app. existing app, want submit update soon. affect how submit app? there no "product name" in build settings, it's little hard know you've changed. did change name of project ? in case, name of product merely name of .ipa file produced when build. apple doesn't know or care is. product name has nothing names public sees, are: the name @ app store (this not part of build process) the display name in springboard (this info.plist setting) for example, take recent app, "diabelli's theme". product name, based on original project name, (for historical reasons) "momapp2.app". when make archive build, upload store, archive's name is, example, "diabelli's theme 4-23-13 10.09 am", , inside .ipa file called "momapp2". neither apple nor public knows or cares of that.

sql server - Why would this table allow a PK id of 0? -

Image
in sql server 2008 r2, have table allows 0 foreign key. odd because primary key constraint specified, , identity(1,1) descriptor used. when first record inserted table, it's pk ( regionid ) 0. i don't have identity-insert turned on when doing insert. (normal operation) here's table definition: create table [dbo].[tdfregions]( [regionid] [int] identity(1,1) not null, [regionname] [nvarchar](50) not null, [regiondescription] [nvarchar](50) not null, [active] [bit] not null, constraint [pk_tdfregions] primary key clustered ( [regionid] asc )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary] ) on [primary] go i have been acting under assumption first record inserted table have regionid of 1. insert tdfregions (regionname, regiondescription, active) values ('test','test', 1) produces: regionid regionname regiondescrip

Where to run scheduled jobs in the cloud? -

i have couple of simple jobs running on old laptop everyday. laptop wakes up, run jobs , go sleep. of jobs c# / python programs collecting couple of information on web , send me need in email or file. i move away model of running jobs on old laptop. move jobs in cloud, don't want pay $50+ month run jobs on vm use 5 minutes day. my question following: there cloud service runs jobs on specific schedule pay use? far know, azure requires vm, same amazon. if willing learn bit aws features, there way launch ec2 instance on cron-type schedule, passing in script run, , have terminate when it's done processing. the basic steps include: create user-data script batch job (can install software, download data, etc.) create auto scaling launch configuration defines instance type, ami, , user-data script above. create auto scaling group above launch configuration, , assign schedule start instances. i've detailed exact steps including sample, working commands in

c# - ASP.NET Webforms routing with extension -

i have simple asp.net webapplication project url-routing , want "allow" routes fileextension ".html", e.g... http://www.mywebsite.com/cms/test.html http://www.mywebsite.com/cms/sub/test.html http://www.mywebsite.com/cms/sub/sub/test.html my global.asax routes looks this: routes.mappageroute("", "cms/{a1}", "~/default.aspx"); the route matched when access website this: http://www.mywebsite.com/cms/test if try one, doens't work too: routes.mappageroute("", "cms/{a1}.html", "~/default.aspx"); edit: 404 error. think .net looks physical file... any ideas? i've fixed on over following property "runallmanagedmodulesforallrequests" inside this: <system.webserver> <modules runallmanagedmodulesforallrequests="true" /> <handlers> <remove name="urlroutinghandler" /> </handlers> </system.webserve

java - How can I get the name of the class that throws a custom made Exception -

i'm preparing project college need write custom made exception thrown couple of classes in same package when not initialized properly. problem must let user know of classes wasn't initialized (and throwed exception)... thinking this: class initializationexception extends exception { private static final string default_msg = "this " + classname-throwingme + " had not been initialized properly!"; protected string msg; initializationexception() { this.msg = default_msg; } initializationexception(string msg) { this.msg = msg; } } (btw, can achieved via reflection?) look @ throwable.getstacktrace() . each stacktraceelement has getclassname() . can @ element [0] determine origination of exception.

Android Challenge: skipped frames... shutdown VM... NULLPointerException.. on return of Intent data to onActivityResult -

i've got bit of challenge... here following high level: from user perspective: they activity (stockcountlistactivity) shows them list of open stock counts - choose 1 , go activity (stockcountactivity) shows them items can update qtys on. behind scenes: the data both activities comes web service... i've written following class helper: public class webservicetask extends asynctask<string, integer, string> with customary async methods... magic no problem... , in end calls @override protected void onpostexecute(string result) { resultstring = result; _listener.handleresponse(tasknumber,scode,result); pdlg.dismiss(); } where _listener interface i've written hook go calling class (either activity)... per following: public interface webtasklistener { public void handleresponse(int tasknum, int scode, string result); } private webtasklistener _listener; all of works great far... comes challenge... in handleresponse of child activity

Match content of a report where column names dynamic using java -

i have dynamic report generate column names fetch database table displays rooms booked employee on given period. below, name dept room1(2) room2(2) room3(3) total d1 1 1 2 b d2 2 1 3 b d3 1 1 1 3 rooms can dynamic can have room4 or room5 if there booking identified period. i made roomheaderdto list has names ordered capacity of room (in brackets of room name display capacity). name , dept column made hard coded , populate room names iterating list. now problem how place values on number of booking in relevant room. have list of dto names contentdto have each rows values populate with. example, contentdto string name; //a string dept; //d1 string roomname; //room1(2) int noofbooking; //1 so instance of dto contains values a, d1, room2(2), 1 wise. so above how dto looks first row. (i have commented values initialized) since column name dynamic, how should identify re

domain driven design - How can class invariant strengthen pre and post-conditions? -

link you can think of class invariant health criterion, must fulfilled objects in between operations. precondition of every public operation of class, can therefore assumed class invariant holds. in addition, can assumed postcondition of every public operation class invariant holds. in sense, class invariant serves general strengthening of both precondition , postcondition of public operations in class. effective precondition formulated precondition in conjunction class invariant. similarly, effective postcondition formulated postcondition in conjunction class invariant. public class server { // other code ommited public output foo(input cmdin) { ... return cmdout; } } public class caller { // other code ommited /* calls server.foo */ public void call() {...} } public class input { // other code ommited public int length {...} } public class output { // other code ommited pub

java - Storing Data from File into an Array -

so have text file items this: 350279 1 11:54 107.15 350280 3 11:55 81.27 350281 2 11:57 82.11 350282 0 11:58 92.43 350283 3 11:59 86.11 i'm trying create arrays values, in first values of each line in array, second values of each line in array, , on. this code have right now, , can't seem figure out how it. package sales; import java.io.file; import java.io.filenotfoundexception; import java.util.scanner; public class sales { public static void main (string[] args) throws filenotfoundexception { scanner reader = new scanner(new file("sales.txt")); int[] transid = new int[reader.nextint()]; int[] transcode = new int[reader.nextint()]; string[] time = new string[reader.next()]; double[] trasamount = new double[reader.hasnextdouble()]; } } it's difficult build array way, because arrays have fixed size... need know how many elements have. if use list instead, don't have worry knowing n

javascript - AngularJs - cancel route change event -

how cancel route change event in angularjs? my current code is $rootscope.$on("$routechangestart", function (event, next, current) { // validation checks if(validation checks fails){ console.log("validation failed"); window.history.back(); // cancel route change , stay on current page } }); with if validation fails angular pulls next template , associated data , switches previous view/route. don't want angular pull next template & data if validation fails, ideally there should no window.history.back(). tried event.preventdefault() no use. instead of $routechangestart use $locationchangestart here's discussion angularjs guys: https://github.com/angular/angular.js/issues/2109 example: $scope.$on('$locationchangestart', function(event) { if ($scope.form.$invalid) { event.preventdefault(); } });

cmake ignores static library link request -

i've searched hours on how solve , tried did not work. i'm trying link statically libraries, (libpoco, libmysqlcpp, libmysqlclient, libssl). i'm using cmake, , although defining static library, cmake looks dynamic one. know have required libraries in static archive in filesystem, , know are. set(cmake_library_path ${cmake_library_path} /lib /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 /usr/lib/x86_64-linux-gnu) find_library(poco_net names libpoconet.a paths cmake_library_path static imported) find_library(poco_util names libpocoutil.a paths cmake_library_path static imported) find_library(poco_xml names libpocoxml.a paths cmake_library_path static imported) find_library (mysql_client names libmysqlclient.a paths cmake_library_path static imported) find_library (mysql_cpp names libmysqlpp.a paths cmake_library_path static imported) find_library (libssl names libssl.a paths cma

Adding days and time to a timestamp in MySQL -

i have 3 fields in table: start_time: timestamp , days_prior: int , , time_open: time . want retrieve value of start_time - days, set time portion of result 00:00:00 , add time that. that is, original timestamp might '2013-05-02 14:57:00' , days 1, time '09:30:00' , want return '2013-05-01 09:30:00'. i realize can done splitting out date portion of timestamp, , concatenating time. however, if wanted use result in same query part of statement, need result of concatenation timestamp well. my query, ideally, following: select t1.id, t1.start_time, concat(date_sub(date(t1.start_time), interval t2.days_prior day), ' ', t2.time_open) t1, t2 t1.t2_id = t2.id this, however, producing results looking like: 1, 2012-10-30 18:00:00, 323031322d31302d33302030393a30303a3030 i try avoid string operation concat when dealing dates , times. there proper date , time func handle instead. try if works you. gives real datetime

html - Dynamic sidebar width depending on the main div -

Image
i have following code <div id="content"> <div id="sidebar"></div> <div id="main"></div> </div> and css #main{ width: 840px; margin: 0 auto; } #sidebar{ float: left; width: ?; -> need fill dhe auto space } the problem how can make #sidebar div fill space left main div? image shows want you can use #sidebar{ float: left; width: calc(100% - 840px); }

html - Firefox not expanding DIV container horizontally containing image with auto-width -

i have markup 2 containers. first 1 set "position:absolute" 4 "coordinates" expand on site (left=right=bottom=top=30px). inside container container height set "100%" , "display:inline-block" ("inline-block" because 2nd container should expand horizontally required width). inside 2nd container image height set "100%" , width set "auto", image tall 2 containers , still has correct proportion. i need 2nd container because want place absolute positioned elements inside container appear on right side of image. the problem following: in firefox 2nd container not grow/expand horizontally auto-width of image. stays @ original width of image. no problem in safari/chrome, firefox. here can find example-fiddle: http://jsfiddle.net/egrcq/ 1st container blue one. inside find 2nd container (red) , inside container example image. if reduce height of output window below 180px see problem (red container becomes visible

android - Strange behavior of inflated buttons when changing one's color -

Image
i trying implement dynamic button inflation android application, based on input specified user in real time. when clicked, button changes color blue red. the code responsible goes follows: layoutinflater layoutsinflater = (layoutinflater) getsystemservice(context.layout_inflater_service); linearlayout linearlayout = (linearlayout) findviewbyid(r.id.layout_for_buttons); // let's need 3 buttons: (int = 0; < 3; i++) { relativelayout buttonlayout = (relativelayout) layoutsinflater .inflate(r.layout.button_layout, linearlayout, false); button button = (button) buttonlayout.getchildat(0); button.settext("button " + i); button.setonclicklistener(new onclicklistener() { @override public void onclick(view buttonview) { button button = (button) buttonview; gradientdrawable gradientdrawable = (gradientdrawable) button .getbackground(); gradientdrawable.setcolor(color.red)

java - Spring security does not work -

i getting error when try login (or, when abort http basic dialog escape) http status 401 - preparedstatementcallback; bad sql grammar [select username,authority authorities username = ?]; nested exception org.postgresql.util.psqlexception: error: relation "authorities" not exist position: 32 however, shouldn't enough 2 query attributes below when want use group based security? need define query attribute to? authorities-by-username-query="" why isn't working? <security:authentication-manager> <security:authentication-provider> <security:jdbc-user-service data-source-ref="datasource" users-by-username-query="..." group-authorities-by-username-query="..." /> </security:authentication-provider> </security:authentication-manager> source jdbcdaoimpl: if (enableauthorities) { dbauthsset.ad

asp.net - How to create a PageStatePersister object that saves view and control state on the Web server -

reading book managed create class used base class override load , save methods extract , save view state information server. in book author suggests going following link , viewing example following: instead of using page base class, use page adapter. modify functionality of pages without having change base classes. that's great if want store viewstate on server pages. find out how store viewstate pages using getstatepersister method of pageadapter class, visit: all trying find way save viewstate without manually changing base class on each page. i following error: [argumentnullexception: value cannot null. parameter name: stream] system.io.streamwriter..ctor(stream stream, encoding encoding, int32 buffersize, boolean leaveopen) +10409245 system.io.streamwriter..ctor(stream stream) +30 dev.streampagestatepersister.save() in a:\project\application\web\dev\streampagestatepersister.cs:57 system.web.ui.page.savepagestatetopersistencemedium(object state) +108 s