Posts

Showing posts from March, 2013

javascript - Geolocation API doesn't work -

i trying few examples , none of them seems work @ all. chrome , firefox both ask me permissions, once give them rights nothing happens. i used example http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation too, doesn't work either. what problem , guys ?

sql - Get the row at 60% of the table -

i'd select row @ 60% of table oracle. can find number of 60% row with: select round(count(*)*0.60) sira (select to_date(time) tarih,lenght hiz table order length desc) i'm looking name column data row @ 60%. is, 60% of rows should have higher length selected row. for example, data: name time length r1 10:00 1 r2 10:02 2 r3 10:04 3 ... r10 10:20 10 i'm looking query prints r4 (row @ 60% ordered decreasing length .) select * ( select row_number() on (order yt.length desc) rn , count(*) on () cnt , yt.* yourtable yt ) subqueryalias rn = round(cnt * 0.60) example @ sql fiddle.

java - I manage to save, but not to LOAD (Serialization) -

i´m making small game , working serialization. have managed save current state of battleground object, can not seem load it. this method that´s giving me syntax errors: //reads battleground object disk. private object readfromfile() { fileinputstream savefile = new fileinputstream("savegame.obj"); objectinputstream restore = objectinputstream(savefile); object obj = restore.readobject(); string name = (string) restore.readobject(); restore.close(); } i error message "cannot find symbol - method objectinputstream(java.io.fileinputstream). looking method in oracle docs parameter in method supposed of type. have imported whole java.io library. inputs? wrong way it? need method load game. other save-method looks this: // saves battleground object disk. private void savetofile() { try{ // serialize data object file objectoutputstream out = new objectoutputstream(new fileoutputstream("savegame.obj")); out.w...

c# - Can button click event handler be invoked before Page_Load? -

i have following code has page load event handler , button click event handler. page load handler invoked before button click expected in page life cycle. is there scenario in button click handler called prior page load handler ? (due validation control or so). if guaranteed page_load called always, need not call mygetcount() function inside button click handler. public partial class webform1 : system.web.ui.page { int tabledatacount = 0; protected void page_load(object sender, eventargs e) { string val = system.security.principal.windowsidentity.getcurrent().name; //get count inside page load tabledatacount = mygetcount(); } protected void btnaction_click(object sender, eventargs e) { response.write(tabledatacount.tostring()); } private int mygetcount() { int count = 135; //logic count return count; } } there no scenario button click handler called before page-...

I need to find highest voters in each year Oracle SQL query -

i have 1 table lets ranking info has username mvid votedate john 1 23-sep-90 john 2 23-sep-90 smith 1 23-sep-90 john 3 24-oct-91 smith 3 24-oct-91 smith 4 25-dec-91 smith 5 25-dec-91 i need write sql query in sqldeveloper(oracle) give me member has given largest number of votes in each year. output should username,year, total number of votes in each year. lets consider above example: need output this. username year number_of_votes john 1990 2 smith 1991 3 because in 1990 john beat smith 1 vote while in 1991 smith beat john 2 votes. i point counted votes not maximum number of votes in year. this have done: select r1.username, extract(year r1.votedate)"year", count(username) rankinginfo r1 extract(year r1.votedate) not null group extract(year r1.votedate), r1.username; order extract(year r1.votedate), username; select * ( select ...

Application Error while loading the facebook SDK -

code on web page: <body class="popup"> <div id="fb-root"></div> <script> window.fbasyncinit = function() { // init fb js sdk fb.init({ appid : '476947702378530', // app id app dashboard channelurl : '//www.majorforms.com/fb_channel.php?_lang_id=1',// channel file x-domain comms status : true, // check facebook login status xfbml : true // social plugins on page }); // additional initialization code such adding event listeners goes here }; // load sdk asynchronously (function(d, s, id){ var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) {return;} js = d.createelement(s); js.id = id; js.src = "//connect.facebook.net/en/all.js"; fjs.parentnode.insertb...

php - i have error like bad request while add product in shopify using api -

following errors has occured: fatal error: uncaught exception 'shopifyapiexception' message 'bad request' in d:\xampp\htdocs\cutoutphoto\lib\shopify.php:87 stack trace: #0 d:\xampp\htdocs\cutoutphoto\lib\shopify.php(203): shopifyclient->call('post', '/admin/products...', '{"image":{"posi...') #1 d:\xampp\htdocs\cutoutphoto\requests.php(217): shopifyclient->update_image('134789371', 'd:\xampp\tmp\ph...', 'tango-featured....') #2 {main} thrown in d:\xampp\htdocs\cutoutphoto\lib\shopify.php on line 87 wrap method or lines have shopifyclient->update_image() in try...catch block eg: try { shopifyclient->update_image('134789371', '/location/of/the/file', ...); } catch(exception $e){ //do exception echo $e->getmessage(); } i think might getting bad request error because not passing parameters api or sending params in incorrect format. also, check if using...

objective c - How to link data between two UITableViews? -

i got trouble , need help, here is: on project, built taxi system , each taxi service shown pin in mapview. each pin has annotation show name , number of services. data parsed json. on annotationview, have right call out button view information of every single service. means annotationview, put button , moves view. how can that? code bellow shows how data json, in right call out button, how taxi service info shown in next view? example, annotation view shows abc taxi service, , in callout button, shows information of service. information parsed json. for (nsmutablearray *stationdictionary in stationdata) { station.name = [stationdictionary objectatindex:10]; station.number = [stationdictionary objectatindex:11]; station.info = [stationdictionary objectatindex:12]; } i hope point , appreciate helps. thanks. if wrap information wish display in class, can pass objects around (or arrays of multiple objects) view view. instance, in medical app i've written, ...

java - Pass String array values to sql IN condition -

i have string array string[] val=request.getparametervalues("names"); for(int i=0;i<val.length;i++){ //printval[i]; } i assign values of string array sql statement as how can pass string values sql condition? if array have following values james,smith, jake etc, pass sql = "where dept_name in('james','smith','jake')"; ideally want string array values passed inside in condition of sql. you can construct query filter , append query main query. stringbuilder sb= new stringbuilder(); string filter = ""; string[] val=request.getparametervalues("names"); for(int i=0;i<val.length;i++){ //printval[i]; sb.append( "'"+val[i]+"'," ); } filter = sb.tostring(); filter = filter.substring(0, filter.length()-1); sql = "where dept_name in("+filter+")";

javascript - Pop-up not showing (with magnific-popup) -

i'm trying implement magnific popup on website reason test image not opening in popup mode. issue? many thanks <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>document sans nom</title> <!-- scripts --> <link rel="stylesheet" href="magnific-popup/magnific-popup.css"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" /></script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js" type="text/javascript"></script> <script src="magnific-popup/jquery.magnific-popup.min.js"></script> ...

c# - Rhino Mock Stubbing method with ExpandoObject as parameter -

i want unit test method under test calls stubbed object , method right parameters. problem 1 of parameters dynamic (expandoobject). if "data" (variable below) typed object works expected. ... [test] public void methodtest_whensomething_expectresult() { ... dynamic data = new expandoobject(); data.id = param1; data.name = param2; var myclass= mockrepository.generatestub<imyclass>(); myclass.stub(x => x.mymethod("hello", data).returns(expectedresult); ... var actualresult = anotherclass.methodundertest(param1, param2); assert.isnotnull(actualresult); } any ideas how can this? btw, dont want "ignorearguments" testing right params being passed in. tia i assume need define stub returns expectedresult when the second parameter has right values in fields id , name . but stub defined return expectedresult when the second parameter same data object . if so...

using eclipse, java maven project compiles but gives error when running -

there large number of answers error i'm getting, each of solutions i've tried (that understand @ least) have not solved problem. project layout in eclipse looks this: mavenproject1 src resources etc. mavenproject2 src resources etc. mavenprojectx src resources etc. each project compiles , runs fine. i'm trying use 1 of projects, of code in mavenproject2, in mavenproject1. i've updated build path , information can import mavenproject2 mavenproject1 , reference methods want. reference mavenproject2 method in mavenproject1 enumerates , doesn't give error in editor (i.e. com.mavenproject2.method()), , mavenproject1 compiles. when try run it, error below. i've tried fixing classpath (as understand it, wrong), i've tried adding project, external jar, every option, in run configuration project, keep hitting same error on line in mavenproject1 calls method in mavenproject2. [warning] jav...

osx - scp folder structure and only files with a specific extension -

i have huge folder structure deep subfolders, , inside these folders there files different extensions ( .txt, .pdf, ... ). what want copy whole folder structure along files .pdf extension. i'm using scp there no option specify extension copy. i tried rsync exclude , include options did not worked , shell window forze p.s: i'm on macosx mountain lion , i'm trying copy fedora 16 what best way ? rsync -rav -e ssh --include '*/' --include='*.pdf' --exclude='*' server:path localpathpath

php - let the visitor download a remote file, chunk by chunk (range) -

it's recurring question on stackoverflow , i've browsed existing suggestions unsuccessfully. here's i'm trying achieve: - visitor comes webpage , have send him large file download. - file located on remote server, , requires either basic auth or cookie. me owns cookie/credentials. - managed download file using wget serve visitor via x-sendfile mod (apache), requires waiting end user before download. - i'd serve download asap, mean website act kind of proxy or something. - tried using bunch of codes curl, fsockopen/feof, etc either crashes apache once in while, either it's blocking connexion (visitor cannot browse website anymore long has not finished downloading), either it's destroying ressources since php tries put huge file in memory guess. so sum up: - should able serve remote file downloading possible - ideally serving chunk chunk / range range ? extra info: php 5.2.13, gentoo, libcurl 5.2.13 sending chunk chunk require kind of...

excel - How can I quickly remove unused formulae from the bottom of the spreadsheet? -

the person built spreadsheets used shortcut copy formulae down entire column, although of them have few hundred active rows. making file size huge , unworkable. how can remove make files more manageable? select entire row lowest row reference deleted ctrl + shift + down , delete, save.

nfc - mifare classic 1k - Android - Tranceive failed on reading block -

i trying read blocks mifare classic card 1k , android nfc (on galaxy nexus). private final int mmaxsize = 64; mclassic.connect(); boolean success = mclassic.authenticatesectorwithkeya(1, mifareclassic.key_default ); final bytearraybuffer b = new bytearraybuffer(mmaxsize); if (success) { b.append(mclassic.readblock(0), 0, 16); b.append(mclassic.readblock(1), 0, 16); b.append(mclassic.readblock(2), 0, 16); b.append(mclassic.readblock(3), 0, 16); } if want read sector 0, that's ok. if want read different sector (for example sector 1), success has true value, when app go readblock() , ioexception triggered , have returned tranceiver failed. what doing wrong? in code example you're authenticating sector 1 try read blocks sector 0 . remember sector , block numbers zero-based. may interested in blocktosector(int block) .

Facebook login behaviour - Chrome under Windows 8 -

using fb.login have 2 different results in chrome: 1. start chrome in windows 8 mode - result new tab 2. relaunch chrome on desktop - result login form /ok/ of course can not ask users switch mode. ideas hot solwe problem? update after removing channel file fb init - works fine - both modes show dialog, not new tab. i suggest make javascript check if using ie10 or browser. take @ link http://www.quirksmode.org/js/detect.html

Beta reduction in lambda calculus using Haskell -

i have defined following functions beta reduction i'm not sure how consider case free variables bounded. data term = variable char | lambda char term | pair term term deriving (show,eq) --substition s[m:x]= if (s=x) m else s ab[m:x]= (a[m:x] b [x:m]) lambda x b[m:x] = lambda x b lambda y p[m:x]= if x=y lambda y p else lambda y p (m:x) --beta reduction reduce [s]= s reduce[lambda x b]m = b[m:x] reduce[l1 l2] = (reduce [l1] reduce [l2]) the link hammar gave in comment describes solution in detail. i'd offer different solution. nicolaas govert de bruijn , dutch mathematician, invented alternative notation lambda terms . idea instead of using symbols variables, use numbers. replace each variable number representing how many lambdas need cross until find abstraction binds variable. abstraction don't need have information @ all. example: λx. λy. x is converted to λ λ 2 or λx. λy. λz. (x z) (y z) is converted to λ λ λ 3 1 (2 1) this notation ...

c# - Is it possible to override a validation ErrorMessage when you have a collection of the same model? -

for example, if have 2 person objects part of view... one parent , other child, don't want error message "gender required field" twice, rather have "please provide child's gender", etc. public class person { [required(errormessage="please provide gender")] public char gender; } but other object: public class parentchild { public person parent; public person child; } and in view it's @html.editorfor(model.parent.gender) @html.editorfor(model.child.gender) is there way dataannotations or should customizing view? i'm not somewhere can try it, yes, believe can that. think (or all?) of attributes in dataannotations namespace contains errormessage property. so, should able this: [required(errormessage="please provide parent's gender")] public char parentgender { get; set; } [required(errormessage="please provide child's gender")] public char childgender { get; set; } here...

Horizontal slide list jQuery -

i have following html markup <ul class="banner"> <li class="current" id="0"><img src="images/first.png"/></li> <li id="1"><img src="images/second.png" /></li> <li id="2"><img src="images/third.png" /></li> </ul> i want first item slide out & replaced second item & on. end item 'loop round' first item. math logic simple. the first item slides out list 'collapses' 0 height , second <li> not replace it. here's have in jquery: // globals $currentbannerimage; // before page created $(document).delegate("#indexpage", "pagebeforecreate", function() { // non current banner images $noncurrentbannerlistitems = $("ul.banner li").not(".current"); // hide them if ($noncurrentbannerlistitems.size() > 0) { $noncurrentbannerlistitems.each(...

sqlite - Android sqlight with multiple where -

i have following table column public static final string showid = "show_id"; public static final string showname = "show_name"; public static final string showseason = "season_name"; public static final string episodename = "episode_name"; public static final string episodestatus = "episode_status"; i want following query select episode_name , episode_status tv_show show_name='aname' , season_name='aseason'"; how this?? i don't want use db.rawquery(...) i want use this db.query( true, dbtable, new string[] {showseason}, showname + " ?", new string[] { string.valueof(shname) }, null, null, null, null ); this basic sql, quick search , find solution: select episode_name , episode_status tv_show show_name='aname' , season_name='aseason...

php - Drupal deployment - blog content separation from node table -

i have 3 environments : dev, staging , live . i use drupal , content pages need synchronized when deploy dev-> staging -> live . use python deployment script (migraine) copy drupal mysql tables want migrate . my problem don't want migrate blog articles dev because don't want force blog editors publish articles twice (on live , dev) when release don't destroy new blog posts. the problem blog posts stored in node mysql table . need deploy node table every time new pages improvements, etc. node table holds content pages on drupal website. how can sort out without having customize drupal blog module ? bare in mind can't customize deployment script deploy nodes don't have type='blog' because ids sequecial , blog articles erased when on dev add new pages. a couple of thoughts. if node id thing stopping excluding blog, use uuid module give each node universally unique identifier. rather relying on python script migrate content, ha...

BizTalk MQSeries adapter -

looking upgrade biztalk server host on windows 2008 r2 64 bit, websphere mq stays in 32 bit environment, problem? that shouldn't problem @ all. have 1 of 2 options: on 64-bit machine, mark biztalk host assigned run mqseries adapter '32-bit only' host (see http://msdn.microsoft.com/en-us/library/aa561079(v=bts.20).aspx ). allow execute adapter under 32-bit architecture on 64-bit machine under wow64 ( http://msdn.microsoft.com/en-us/library/windows/desktop/aa384249(v=vs.85).aspx ) use mixed 32-bit/64-bit environment - i.e. have 1 server in biztalk group 32-bit , 1 (or more) 64-bit. execute mqseries adapter in biztalk host configured host instance on 32-bit server. note: second option overkill, works if upgrading 64-bit environment , decommissioning older hardware.

c# - calling web method on window onbeforeunload event -

i working on basic asp.net website , want execute server side function when user try go away page. using onbeforeunload event of window. have check box on page , when user checked check box, executing sverside "checkedchange event". issue whenever user click on check box web method called, should not called postback happen, user not leaving page. can 1 suggest me avoid web method call when postback happen. wnat execute web method in following scenarios: 1) when user closes browser. 2) on click of “find more matches” button, when user landed on search results page no school listed. 3) when user changes url browser's address bar code on aspx page: function getmessage() { var urlstring = document.url; { pagemethods.message( document.url); } } </script> code on aspx.cs page [system.web.services.webmethod] public static void message() { string x="a"; } this link should hold ans...

c# - No embedded images in email -

i try send email embedded images. images going list<bitmap> , sure there 100%. somehow when email don't see images @ , html looks like <img alt="" hspace="0" src="http://image0" align="baseline" border="0"> <br /> <img alt="" hspace="0" src="http://image1" align="baseline" border="0"> <br /> any clue? c# var smtp = new smtpclient(); var msg = new mailmessage(new mailaddress("support@mysite.com", "mysite.com support"), new mailaddress(email, email)); msg.subject = "no worries, man"; msg.isbodyhtml = true; var bodybuilder = new stringbuilder(); (int = 0; < pages.count; i++) bodybuilder.appendline(string.format("<img alt=\"\" hspace='0' src='cid:image{0}' align='baseline' border='0'><br />",i)); var htmlview ...

javascript - link highlight JS library like In-Page Analytics in Google Analytics -

i want know link highlight javascript library in-page analytics in google analytics. in in-page analytics, every time hover mouse on link see pink border. want implement function javascript. what name of link highlighting javascript library? if not public library, want know similar library or similar browser plugin.

c# - A Generic Pass-Through Interface. Is this possible? -

what wouldn't give have work: public interface icallback { void handle<t>(t arg); } public class messagehandler : icallback { public void handle<t>(t arg) { string name = typeof(t).name; console.writeline(name); } public void handle(int arg) { string name = "wow, int"; console.writeline(name); } } public class worker { public void dosomething(icallback cb) { cb.handle(55); } } //... worker foo = new worker(); icallback boo = new messagehandler(); //i want print "wow, int" foo.dosomething(boo) unfortunately, calls generic entry point rather "specialized" entry point. well, thats interfaces you. i've tried same approach replacing int-specific signature generic signature mojo specific: public void handle<t>(t arg) t : mojo {} i hoping sufficient form "special override" if argument of type mojo . compiler complains have 2 me...

string - VBS - Ignoring the \ special character properties -

i'm struggling call command line correctly in vbs due \ escape character. the string output i'm looking write command line is, batch_name=\"mybatch\" which gets passed .exe file. unfortunately, due way \ character works can write, batch_name=\mybatch\ batch_name=\""mybatch\"" i can't \" in output! altered version of code below, batch_name = "mybatch" outputstring = "batch_name=\" & batch_name & "\" i've tried lots of methods - concatenating string chr(34), using multiple double quotes, trying replace() "" ", nothing seems work. any ideas? i gave shot and outputstring = "batch_name=\""" & batch_name & "\""" worked me giving result batch_name=\"mybatch\" does work you? how execute command in shell?

Protecting Source Code in Matlab vs. Python -

i need write program in either python or matlab contains proprietary information, not reveal proprietary information if program distributed. while realize determined hacker can reverse engineer source code, easier secure code written in python or matlab? in matlab can use command pcode , preparses matlab code form unreadable humans, runs same (actually, faster) original matlab code. happens each .m file pcode, you'll new file .p extension. .p file runs same .m file, unreadable. alternatively, can purchase matlab compiler, convert entire application standalone executable code encrypted.

javascript - Incorrect code syntax (scrollbar) -

i'm trying implement this scrollbar , change scroll inertia looks made syntax error in code below. know error is? many thanks <script> (function($){ $(window).load(function(){ $(".content_2").mcustomscrollbar() scrollinertia:150 }); })(jquery); </script> $(window).load(function(){ $(".content_2").mcustomscrollbar({ scrollinertia:150 }); }); you should see examples here proper usage - http://manos.malihu.gr/jquery-custom-content-scroller/

css - Background-Image size not working in all browsers -

the weirdest thing happened, had problem fixed footer , accidently left %sign after contain in code. take look. site usahvacsupply.com html, body{ overflow:auto; margin: auto; background-image:url('/images/testing1/bg2.jpg'); background-repeat: no-repeat; background-position:top center; -moz-background-size:100% 100%; -webkit-background-size:100% 100%; background-size:contain%; top: 0; left: 0; } without % sign after contain throws off. % satisfies firefox though. know fix browsers? ie % helps throws off top level navigation tabs. in chrome out of wack. i'm pretty baffled here appreciated. well, have different background-position rules different prefixes. if you'd use 'contain' value, try removing % , follow suit other rules. -moz-background-size: contain; -webkit-background-size: contain; background-size: contain;

c# - asp.net update textbox via JS based on other textbox value -

i have 2 textboxes on asp.net page. 1 today's date , 1 expiry date 1 year now. so if first textbox contains 23/04/2013 i want second textbox automatically populated 23/04/2014 how can update expiry date's date 1 year (without postback) suspect js needed right? this answer uses jquery read date, parse parts , add 1 year. doesn't, check validity of date entered, entering letters first textbox produce date of "nan/nan/nan". combine jquery ui's datepicker make sure input valid date. in case use change event instead of keyup . html: <input id="today" type="text" /> <input id="future" type="text" /> javascript: $(document).ready(function () { $('#today').keyup(function () { var today = new date($(this).val()); if (today != nan) { var dd = today.getdate(); var mm = today.getmonth(); var y = today.getfullyear(); ...

jquery - apostrophe problems with twitter share url -

so realized apostrophes gives "&#39" , i have js following: $(document).ready(function () { $('#share_buttont@(number)').click(function () { var loc = $(this).attr('href'); window.open('http://twitter.com/share?url=' + loc + '&text=' + "@item.title. news via www.test.com" + '&', 'twitterwindow', 'height=450, width=550, top=' + ($(window).height() / 2 - 225) + ', left=' + $(window).width() / 2 + ', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0'); }); }); if @item.title contains " 'flying' boat smash record? " , text apostrophes ruins text inside twitter share box. apostrophes turns &#39 . is there ways fix this, or need remove apostrophes on text? before js script triggers?

tfs2010 - In a TFS 2012 WIT, is there a way to show the full comment dates for System.History instead of the "fuzzy" ones? -

Image
having been using tfs 2012 year now, our team has started working on round of customizations our customized agile process template. received request today can't figure out. in tfs 2012 (this seems new thing), system.history field in each wit used history comments displays "fuzzy" date next each update, rather full date-stamp believe used in tfs 2010. there way show full date rather "a few minutes ago," "4 weeks ago," etc.? i've gotten word authority on tfs customization not possible. workaround kmoraz -- hovering on fuzzy date time-stamp pop-up in web access -- enough our team.

mysql - Cayenne "resets" primary key value? -

i using cayenne add records mysql database, , seeing strange behavior. when run application, create datacontext, perform series of adds, close application. works out well, because using integer primary key, , when add record database, key automatically increments. reason, starts @ 200 first record, goes 201 second record, etc. if, however, stop application, run again, primary key starts @ 200 again! this, of course, causes exception thrown because new record ends having duplicate primary key. looking when create new object using datacontext's newobject() after starting application, cayenne not "remember" how far primary key incremented when application run. does know causing reset of primary key values, , (more importantly) how stop happening??? or have found bug in current version of cayenne? using version 3.0.2. someone please advise... the last used pk given table stored in special table called auto_pk_support. please check contents of table betwee...

Arquillian Persistence Extension - Long execution time, is it normal? -

i'm writing tests arquillian persistence layer in app. use persistence extension database populating etc. problem 1 test takes ~15-25 seconds. normal? or doing wrong? i've tried run these tests on local postgres database (~10sec per test), remote postgres database (~15sec per test) , hsqldb @ local container (~15sec per test). thanks in advance p.s. when i'm not using "persistence extension" 12 tests takes ~11sec (and that's acceptable), have persist , delete entities code (hard maintain , manage). i going guess using ape (arquillian persistence extension) v1.0.0a6. if case experiencing result of refactoring done between alpha5 , alpha6 filed following ticket against: https://issues.jboss.org/browse/arq-1440 you try using 1.0.0a5 has different issues might encounter , need work around has 300% better performance alpha6.

performance - Possible with lua in redis to return all key stored in a set as a list of hashes? -

i have structure data_type:key1 - hash data_type:key2 - hash data_type:key3 - hash data_type:key4 - hash data_type:key5 - hash data_type:index - set(key1, key2, key3, key4, key5) is possible lua in redis build script iterate on set data_type:index , return data_type:key*'s list of hashes? still learning lua go in head think work like collect = [] key_name in redis.call.smemembers('data_type:index'): collect.append( redis.call.smembers('data_type:' + key_name) return collect generally of index's have 100 keys, each key 1kb, script have 100-120kb response size under ideal circumstances. and before asks, real keys 'some_data:status:{64 bit hex string}' , 'some_data:index:2013:05:09' {64 bit hex string} being member of :index set. check sscan command . something following should work in case: local collect = {} local match_pattern = "*" local results = redis.call("sscan", "data_type:index...

java - How to run TestNG tests from main() in an executable jar? -

i have executable jar contains dependencies , test classes. i've confirmed main() method called when execute jar. i'm trying add code main() can run specific testng test class. documentation on testng.org appears way it: testlisteneradapter tla = new testlisteneradapter(); testng testng = new testng(); testng.settestclasses(new class[] { com.some.path.tests.mytests.class }); testng.addlistener(tla); testng.run(); my folder structure typical: /src/main/java/main.java /src/test/java/com/some/path/tests/mytests.java however when try compile error: java: /src/main/java/main.java:46: package com.some.path.tests not exist is there anyway can alter project testng.settestclasses() in main() can access test class? i used following in main() method , worked. commandlineoptions options = new commandlineoptions(); jcommander jcommander = new jcommander(options, args); xmlsuite suite = new xmlsuite(); suite.setna...

go - Is there a way to do repetitive tasks at intervals in Golang? -

is there way repetitive background tasks in go? i'm thinking of timer.schedule(task, delay, period) in java. know can goroutine , time.sleep() , i'd stopped. here's got, looks ugly me. there cleaner/better way? func oneway() { var f func() var t *time.timer f = func () { fmt.println("doing stuff") t = time.afterfunc(time.duration(5) * time.second, f) } t = time.afterfunc(time.duration(5) * time.second, f) defer t.stop() //simulate doing stuff time.sleep(time.minute) } the function time.newticker makes channel sends periodic message, , provides way stop it. use (untested) : ticker := time.newticker(5 * time.second) quit := make(chan struct{}) go func() { { select { case <- ticker.c: // stuff case <- quit: ticker.stop() return } } }() you can stop worker closing quit channel: close(quit) .

c# - .NET Multi-thread a background process with a thread limit? -

i'm relatively new parallel programming , have need run background process on different threads. the scenario - cause first background process run - take 45 seconds (for example) complete. meanwhile, @ arbitrary point after first background process runs, event occurs in turn causes second background process run - 20 seconds in. don't want wait 25 more seconds first process complete, want second process running right away on thread. but, want limit number of threads can spurned up. do need create sort of queuing class backgroundworker objects or similar? best approach scenario? your best bet use task parallel library accomplish this. instead of spinning threads run tasks, start new tasks using task.run(), or similar. the task parallel library uses taskscheduler execute tasks on thread pool. taskscheduler tries optimize number of threads in thread pool increase throughput. because taskschedule reuses threads 1 task next, unlikely need limit number of thread...

Fragment android:visibility in xml layout definition -

how works? have layout below: <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <fragment android:id="@+id/search_form_fragment" android:name="fragmentclass" android:layout_width="match_parent" android:layout_height="match_parent" /> <fragment android:id="@+id/result_list_fragment" android:name="fragmentclass" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" /> </linearlayout> note second fragment has android:visibility="gone" , indeed not visible on screen. code: boolean bothvisible = firstfrag.isvisible() && secondfrag.isvisible(); returns true , not expected me. wonder if using android:visibility cor...

c# - Google Maps DOS attack -

we're using google's geocoding service on our website allow users enter zip code , find nearby locations. we've been having problem exceeding request limit of 25,000 per day (for 90 consecutive days). shouldn't getting traffic , i've found, when enabling logging, got 133 requests in 35 minutes. seems way much. i'm suspecting kind of scripted attack. can verify & prevent it? i ended reading through api docs again , finding should've been coded geocoding request occurs on client-side. updated our pages use client script make geocoding request. way if user wants abuse it, blocked, not server. client script sends page lat , long coordinates needed , goes there without having interface google on server side.

c# - Masked textbox mask causes data type mismatch -

i have masked textbox mask zip codes(00000-9999) , access database field long type. when enter zipcode 27101 entry added(though in access -27101), works. if add full zip 27101-1111, data type mismatch error. tried removing mask , entering 271012222 , added database. ?? mycommand.parameters.addwithvalue("@zip", mskzipcode.text); you have type mismatch not because of fact masking because entering invalid characters long type. i add full zip 27101-1111, data type mismatch error. tried removing mask , entering 271012222 , added database. ?? this problem. type in access long entering non numeric character '-'. reason able enter 271012222 because avoided entering '-'. if going zip code field , want full zip code, suggest changing type of field in access varchar(10) (or access equivalent).

How to change ColumnIndex in DataGridView when user selects a cell in Column 0 -

visual basic 2010 .net, datagridview, 2 columns. want force column 1 selected when user clicks, selects or puts focus 1 cell in column 0. if me.dgv.rows.count > 0 if me.dgv.currentcell.columnindex = 0 ' if columnindex 0 me.dgv.item(1, me.dgv.currentcell.rowindex).selected = true ' change columnindex 1 end if end if the code sample not work inside of cell events without throwing exceptions. works behind button need code run user interacts dgv?? the dgv's 'cellclick' event sort of works. when hold mouse button down, move pointer rows above or below , release mouse button messes up private sub dgv_cellclick(sender object, e system.windows.forms.datagridviewcelleventargs) handles dgv.cellclick if me.dgv.rows.count > 0 if e.columnindex = 0 me.dgv.item(1, e.rowindex).selected = true end if end if end sub the dgv's 'click' event works way want grid flickers when chan...

c# - Cannot save file after opening it -

i can save file infinitely. can open file infinitely. , can save open file. however cannot save file after opening it. following error: a first chance exception of type 'system.runtime.interopservices.externalexception' occurred in system.drawing.dll additional information: generic error occurred in gdi+. i tried disposing , temp bitmaps, did not seem work me. location file being opened , saved same place, perhaps maybe problem overwriting file? program breaks @ temp.save private void opentoolstripmenuitem_click(object sender, eventargs e) { //graphics.fromimage(bmap).dispose(); using (graphics g = graphics.fromimage(bmap)) { bmap = new bitmap(@"c:\users\nick\final.bmp"); g.drawimage(bmap, panel1.width, panel1.height); } panel1.invalidate(); } private void savetoolstripmenuitem_click(object sender, eventargs e) { graphics g = ...

sass - SCSS Partials for .css files without changing the filename -

i'm looking ways optimize wordpress instance. theme has 8-10 css files rendered in functions.php . consequently, not want change file names because mean have hack theme , want keep bare minimum. i want use scss combine these css files 1 css file , include new file in theme instead. when try... @import "style.css"; @import "reset.css"; @import "shortcodes-styles.css"; it renders as @import url(style.css); @import url(reset.css); @import url(shortcodes-styles.css); how can scss import css partials without changing file names? i'm using codekit if makes difference. not possible. sass compiles sass files: https://github.com/nex3/sass/issues/556

php array to string not working online server -

i have problem. have array of values database, when try pass string commas, works fine on localhost, when upload online server, string doesn't show values. example: select table in (,,) shows commas , in xampp server works excellent. ideas can be? here's code: <?php $sql = "select id users gid = 1"; $result = mysql_query( $sql); $cat_titles=array(); while( $row=mysql_fetch_assoc($result) ) { $cat_titles[] = $row['id ']; // stuff other column // data if want } mysql_free_result( $result ); echo "<p>\n"; foreach($cat_titles $v) { $cat_titles[]= $row['id']; } echo "</p>\n"; $cat_titles = implode(',',$cat_titles); $cat_titles = substr($cat_titles,0,-2); echo $cat_titles; echo "select * users in (".$cat_titles.")"; ?> a number of potential issues here: you not handling error conditions around database access, if having issue queries never know. your second sel...

c++ - Undefined reference with g++4.7.3 and g++4.8? -

consider code : #include <iostream> #include <array> template <typename type> struct constant { constexpr constant(const type source) : _data({{source}}) {;} constexpr constant(const std::array<type, 1> source) : _data(source) {;} constexpr constant<type> operator()() const {return _data;} constexpr operator type() const {return _data[0];} const std::array<type, 1> _data; static constexpr constant<type> pi = 3.1415926535897932384626433832795028841971693993751058209749445l; }; int main(int argc, char* argv[]) { std::cout<<constant<double>::pi()<<std::endl; return 0; } i compiler error g++4.7.3 , g++4.8.0 (which undefined reference pi (sorry it's in french)) : /tmp/cctdvpfq.o: dans la fonction « main »: main.cpp:(.text.startup+0xd): référence indéfinie vers « constant<double>::pi » collect2: erreur: ld retourné 1 code d'état d'exécution as system fresh install (f...

firebird - How ibase_restore working with php? -

i'm trying restore firebird database using ibase_restore, , nothing. found no documentation on internet. need help! this code used, gbak command console have restored perfectly. $servidor = 'localhost'; $usuario = 'sysdba'; $password = '*******'; if (($service = ibase_service_attach($servidor, $usuario, $password)) !== false) { $result = ibase_restore($service, '/folder/backup.fbk', $servidor.':/folder/restore.fdb'); var_dump($result); ibase_service_detach($service); }

in app purchase - Unlock feature after buying from website in iOS app -

i have question on in app purchase have requirement user can premium account in app purchase in app extend usage of the existing functionality. same feature can brought website logging account in web. if user buys product web , login in iphone app, suppose unlock feature in iphone? apple doesn't abut these kind of flows in docs. since premium account subscription based product purhasing 1 month or 1 year , not auto renewal. user has buy premium service once expires. so server has maintain status logged in user premium user or not? thanks it depends on content - in guidelines doc - @ 11.14. approved content ok if pruchased outside app (magazines, newspapers, books, audio, music, video , cloud storage) , can purchase content inside app (apple take cut) what can't link website purchase check out apps kindle , comixology

wcf - Public certificate, private key asymmetricsecurity element -

my wsdl says asymmetric binding. initiator token , receipienct tokenhow can generate binary security token both client , server. can implement kind of security 1 private key. . here wsdl <sp:asymmetricbinding> <wsp:policy> <wsp:exactlyone><wsp:all><sp:initiatortoken><wsp:policy><wsp:exactlyone> <wsp:all><sp:x509token><wsp:policy> <wsp:exactlyone><wsp:all><sp:wssx509v3token11/></wsp:all> </wsp:exactlyone> </wsp:policy></sp:x509token></wsp:all> </wsp:exactlyone></wsp:policy></sp:initiatortoken> <sp:recipienttoken><wsp:policy><wsp:exactlyone><wsp:all><sp:x509token><wsp:policy><wsp:exactlyone><wsp:all> <sp:wssx509v3token11/> </wsp:all> </wsp:exactlyone> ...

java - Substitutes for unix shell commands for windows? -

i developing source code judging software.i have developed on linux platfrom ubuntu 12.04 lts. now want deploy on windows. software creating commands per unix shell,saving them in file , executing commands through file. here part of code: package codejudge.compiler.languages; import java.io.bufferedwriter; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import java.io.outputstreamwriter; import codejudge.compiler.timedshell; public class c extends language { string file, contents, dir; int timeout; public c(string file, int timeout, string contents, string dir) { this.file = file; this.timeout = timeout; this.contents = contents; this.dir = dir; } public void compile() { try { bufferedwriter out = new bufferedwriter(new outputstreamwriter(new fileoutputstream(dir + "/" + file))); out.write(contents); out.close(); ...

Haskell: Using map with a function that returns a list? -

i have encode function: class encode encode :: -> [bit] and have problems writing function encodes list of type a list of bits. want recursively encode elements of list. in understanding can use map function purpose. problem encode returns list [bit], whereas map expects bit. how can solve this? here relevant part of program. instance encode => encode [a] encode [] = [i, o, o, i, o, i] encode m = ([i, o, o] ++ (map encode m) ++ [i, o, i]) use concatmap . concat enates results after map ping them. instance encode => encode [a] encode [] = [i, o, o, i, o, i] encode m = ([i, o, o] ++ (concatmap encode m) ++ [i, o, i]) how have found out yourself: if search type of function want, (a -> [bit]) -> [a] -> [bit] , using hoogle , concatmap first result.

sql - Using IF / ELSE to determine a SELECT INTO statement -

i'm having strange issues using if / else determine 1 or 2 select statements execute. error message i'm getting when running full statement temporary table exists, not occur if run 2 separate executions of 2 separate if statements. here code in sql server: if (select businessdaycount calendartbl) <= 1 begin select * #temp1 previousmonthtbl end else begin select * #temp1 currentmonthtbl end it's "feature" of syntax checking in sql server. cannot "create" #temporary table twice within same batch. this pattern need. select * #temp1 previousmonthtbl 1=0; if (select businessdaycount calendartbl) <= 1 begin insert #temp1 select * previousmonthtbl end else begin insert #temp1 select * currentmonthtbl end if prefer, can express branch (in case) clause: select * #temp1 previousmonthtbl (select businessdaycount calendartbl) <= 1 union select * currentmonthtbl isnull((select business...

javascript - Difference between dojo/on and dojo/aspect -

in dojo javascript library, dojo/on , dojo/aspect used functions listen events. however don't see how differ 1 another. can explain when use on , when use aspect? dojo/on used listening events. dojo/aspect used intercept calls javascript functions. with aspect, can intercept function call , before function call, after, or both. events, being notified occurred. technically, if target object not domnode, dojo/on ends calling aspect.after(...) in <=1.6, there not distinction , dojo.connect used. functions used notify event occurred , there still remnants of in code base. example using on click event on dijit/button . dojo/evented http://dojotoolkit.org/reference-guide/1.9/dojo/evented.html

cakephp - CLI cron job sending get request to URL but 404 for everyone else -

i setup cron job cakephp sends request url in cake application, (or runs function in controller). however, if user visits url, 404 prevent abuse. how can accomplish this? this work well? note: using cakephp 2.3.0 the easiest (and reasonably secure) way check user agent . (sample assumes you're using "wget" cron). in crontab, use have run @ 7 minutes after each hour: 7 * * * * cd /tmp; /usr/bin/wget http://domain/controller/cron; rm cron if cron job running on same server website, can use "localhost" instead of "domain"; otherwise, use name of domain (ex: "www.example.com"). substitute name of controller want cron method in word "controller". next, in controller's php: public function cron() { if (substr($_server['http_user_agent'], 0, 4) != 'wget') $this->redirect('/'); ... it's "reasonably" secure, because it's not hard spoof user a...

c# - MVC [Authorize] Extension to only check an 'enabled' bit flag -

i'm using ef code first , asp.net mvc 4. users sign in site exclusively oauth providers, not native accounts. i've got working no problem, users table part of standard model , webpages_oauthmembership holding oauth data. i've added 'enabled' bit field on users table that, while site still in 'alpha', users not have access site unless approve it. users can create oauth accounts want isolate specific controllers using annotation prevent use. instance, have 'widgets' controller. right set [authorize] users must logged in. want own custom annotation, [approved] or [enabled], logged in, users cannot proceed unless i've flipped bit 'on' in users table. while write own helper method , inject manually, i'd rather use annotations it's easier roll out , remove once site live. in future, if website ever charged money, i'd love swap out [enabled] check see if user date, payments wise. feel annotation right way go, not sure 100% how ...

java - Endorsed directory isn't working in Tomcat6 -

even though seems endorsed directory configured properly, keep getting following message. opensaml requires xml parser supports jaxp 1.3 , dom3. jvm configured use sun xml parser, known buggy , can not used opensaml. please endorse functional jaxp library(ies) such xerces , xalan. instructions on how endorse new parser see http://java.sun.com/j2se/1.5.0/docs/guide/standards/index.html in tomcat6.conf have following: catalina_opts = "... -djava.endorsed.dirs=/etc/tomcat6/endorsed ..." in endorsed folder, have following files: resolver-2.9.1.jar xalan-2.7.1.jar xml-apis-2.9.1.jar serializer-2.9.1.jar xercesimpl-2.9.1.jar i've restarted tomcat6, redeployed war file , keep getting aforementioned error message. update 1 i ran following command jps -v gave me this: 3786 jps -dapplication.home=/usr/java/jdk1.6.0_45 -xms8m within web application print endorsed dirs out console system.out.println("-djava.endorsed.dirs = " +...

grammar - antlr left recursion for nesting boolean expressions -

i writing antlr grammar in i'd able have nested expressions, can either "simple" expressions or boolean expressions (with optional parentheses). simple expression 1 lhs , rhs, such a = 5 i'd able support these types of expressions: a = 5 = 5 or b = 10 = 5 or (b = 10 , c = 12) (a = 5 , b = 10) or (c = 12 , d = 13) my grammar looks like: string: char+; fragment char: ('a'..'z' | 'a'..'z' | '0'..'9'); booleanop: 'and' | 'or'; simpleexpr: string '=' string; expr: simpleexpr | parenexpr | booleanexpr; parenexpr: '(' expr ')'; booleanexpr: expr (booleanop expr)+; i'm getting error expr , booleanexpr mutually left recursive. understand why happening, i'm not sure how work around if want able nest boolean expressions within each other. on homepage of www.antlr.org can see sample grammar: grammar expr; prog: (expr newline)* ; expr: expr ('*'...

vb.net - Instance variables and local variables confusion -

please take @ sample1 below: public class localvariable public sub run() dim testvariable integer testvariable = method1(testvariable) testvariable = method2(testvariable) testvariable = method3(testvariable) end sub private function method1(byval x integer) integer return x + 1 end function private function method2(byval x integer) integer return x + 2 end function private function method3(byval x integer) integer return x + 3 end function end class and sample 2 below: public class instancevariable dim testvariable integer public sub run() method1() method2() method3() end sub private sub method1() testvariable = testvariable + 1 end sub private sub method2() testvariable = testvariable + 2 end sub private sub method3() testvariable = testvariable + 3 end sub end class the outcome same after e...

How to make a RPN calculator (Java) -

i have assignment , need bit of help, there seems error when doing more 1 calculation using rpn format. use example input given in link below. on first input (16 3 7 + *) gives me correct answer (160). but, next 2 inputs (4 32.125 13 – * 20 +) , (5 –3 * 4 2 / 6 3 1 – / + +) return "error." in advance, if need more information don't afraid ask. assignment details: details my code far: import java.io.*; import java.util.*; public class rpncalculator { public static void main(string[] args) { string filename="rpninput.txt"; string filename2="rpnoutput.txt"; scanner inputstream = null; printwriter outputstream = null; //read try{ inputstream = new scanner(new file(filename)); //try open file } catch(exception e){ system.out.println("could not open file named "+ filename); // if doesn't find it, tell them system.exit(0); // , exit. } //write try{ outputstr...