Posts

Showing posts from April, 2010

python - Clientside Scripting Language -

is javascript language can utilise dom api? there dom wrapper python? there in-browser implementations of python: http://www.skulpt.org/

Example of how to add secondary index when storing object in Riak with Java Client? -

i storing hash-map in riak bucket this: bucket.store(key, dochashmap).execute(); i store object secondary index. how accomplish this? aware iriakobject has addindex method, how access iriakobject before stored? i think trying expected use-case, yet not able find documentation or examples on this. if can point me 1 appreciated. thanks! update: @brian roach answered on riak mailing list , below. here custom class wrote extends hashmap: class docmap extends hashmap<string, object> { /** * generated id */ private static final long serialversionuid = 5807773481499313384l; @riakindex(name="status") private string status; public string getstatus() { return status; } public void setstatus(string status) { this.status = status; } } i can still use object ordinary hashmap , store keys , values, write "status" secondary index (and end being called "status_bin" since it's stri

java - Bundle and putExtra -

i new learner when copy practicing code book bought, tells me putextra not defined bundle can use putlong instead? or what? public class remindereditactivity extends fragmentactivity { @override public void oncreate (bundle savedinstancestate) { super.oncreate (savedinstancestate); setcontentview (r.layout.reminder_edit_activity); fragment fragment = getsupportfragmentmanager().findfragmentbytag(remindereditfragment.default_edit_fragment_tag); if (fragment == null) { fragment = new remindereditfragment(); bundle args = new bundle(); args.putextra(reminderprovider.column_rowid, getintent().getlongextra(reminderprovider.column_rowid, 0l)); fragment.setarguments(args); fragmenttransaction transaction = getsupportfragmentmanager ().begintransaction(); transaction.add (r.id.edit_container, fragment, remindereditfragment.default_edit_fragment_tag); transaction.commit(); } } } yes, can try putlong method, bundle don't

javascript - OpenTextFile gives error Automation server can't create Object -

i created method create text file log page has different buttons call functions parameters different textfields: function writetofile(data) { var currentdate = new date(); var datetime = "time: " + currentdate.getdate() + "/" + (currentdate.getmonth()+1) + "/" + currentdate.getfullyear() + " @ " + currentdate.gethours() + ":" + currentdate.getminutes() + ":" + currentdate.getseconds(); var fso = new activexobject("scripting.filesystemobject"); var = fso.opentextfile("c:\\logs\\log.txt", 8); a.writeline(datetime); a.writeline(data + "\n"); a.close(); } and works fine when i'm using c: drive. unfonrtunately, used in production in z: drive other people can use page well. when copy z: drive , change line: var = fso.opentextfile("c:\\logs\\log.txt", 8); to following: var = fso.opentextfile("z:\\logs\\log.txt", 8); it gives me error

javascript - Crossfilter filtering and displaying on array properties -

i have array of data objects this: { index: "m1", first: "first", last: "last", distance: 5, specialties: ["pediatrics", "internal"], languages: ["english", "french"] } in addition filtering distance: var cf = crossfilter(physicians); var bydistance = cf.dimension(function (d) { return d.distance; }); i'd filter specialty. i've looked @ this question , gives me structure count of each specialty entire dataset. ideally i'd display matching specialties based on distance filter, , use specialties further filter results. is possible given structure of objects? there easier way represent data lend better filtering? thanks. fiddle here: http://jsfiddle.net/colin_young/xrqjx/35/ support custom filter functions has been added in crossfilter-1.2.0. should able do: var specialties = cf.dimension(function(d) { return d.specialties; }); specialties.filterfunction(fun

jquery - Hide/Show content with many variables -

i'm using jquery reveal/hide content on click event follows: $('#staffer1').click(function() { $("#staff1").show(); $("#staff2").hide(); $("#staff3").hide(); }); $('#staffer2').click(function() { $("#staff2").show(); $("#staff1").hide(); $("#staff3").hide(); }); $('#staffer3').click(function() { $("#staff3").show(); $("#staff1").hide(); $("#staff2").hide(); }); this issue lies in volume. if have 60 staffers, there way circumvent listing out 60 lines each click event? html so: <div> <p><a id="staffer1">staff name 1</a></p> <p><a id="staffer2">staff name 2</a></p> <p><a id="staffer3">staff name 3</a></p> </div> <div id="staff1"> <div class="slider"> <img src="i

c# - can there be two different columns of type link in datagridview? -

if how handle cellcontentclick event of each separately? adding columns dynamically. heres code:- datagridviewshow.columns.add(new datagridviewtextboxcolumn { headertext = "date", datapropertyname = "date", celltemplate = new datagridviewtextboxcell() }); datagridviewlinkcolumn tocomputer = new datagridviewlinkcolumn(); tocomputer.headertext = "status"; tocomputer.name = "link1"; tocomputer.usecolumntextforlinkvalue = true; tocomputer.text = "save file"; tocomputer.activelinkcolor = color.white; tocomputer.linkcolor = color.blue; tocomputer.trackvisitedstate = true; tocomputer.visitedlinkcolor = color.green; datagridviewshow.columns.add(tocomputer); datagridviewshow.cellcontentclick += (savefiletype_click); datagridviewlinkcolumn tonet = new datagridviewlinkcolumn(); tolinx.headertext = " "; tolinx.name = "link2&qu

jquery - Alert on value change in select -

i'm trying alert user when value of select changes specific one, have multiple select in page (one each user). here tried: http://jsfiddle.net/mefqq/ $(document).ready(function() { $("select").change(function(){ if($(this).text() == "chef") { alert(); } }); }); my wish have alert when select changes value "chef". how do this? something perhaps: http://jsfiddle.net/mefqq/1/ you need use .val() function, not .text() function when working selects. also need compare value attribute (1 in case) not actual text value. the code looks this: $(document).ready(function() { $("select").change(function(){ if($(this).val() == "1") { alert('value 1 (wich refers chef) got selected'); } }); });

php - how to make the calender pop out when entering data -

i'm trying make web interface admin enters customer information , stores in database want calendar pop out when click on date field this how insert code is <?php function valid( $start_date, $end_date, $error) { ?> <!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd"> <html> <head> <title>insert records</title> </head> <body> <?php if ($error != '') { echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>'; } ?> <form action="" method="post"> <table border="1"> <tr> <td colspan="2"><b><font color='red'>insert records </font></b></td> </tr> <tr> <td width="179"><b><font color='#663300'>start date<

windows xp - Is there a limit on number of handles to system registry in XP? -

very rarely, 1 of application instances fail find registered class/dll in registry. suspect due failure read registry. windows xp impose limit on number of active file handles registry? besides absolute handles limit. yes, there upper limit handles. beyond bounds of imagination should hitting it. there enough headroom multiple running applications have several registry handles open simultaneously. the way ever reach such limit if not closing handles when finished them, resulting in leak. make sure calling regclosekey function each handle open.

java - How can I make a group optional which capturing a pattern and also capture the same group number? -

pattern pattern = pattern.compile("\\d{4}\\s+[a-z|a-z]{2}\\s+plain\\stext\\s+(.*?)\\(ns\\)"); matcher matcher = pattern.matcher("2007 al plain text ap2345 (ns)"); while (matcher.find()) { system.out.println(matcher.group(1)); } i want work input1 = 2007 al plain text ap2345 (ns) (the above regex work this) fails input2 = "ap2345" . want capture both these strings in same group number means need make previous captures optional. how can that? edit::: want same group number work both when strings value 2007 al plain text ap2345 (ns) or ap2345 i not sure if understood problem correctly before explain check regex (\\d{4}\\s+[a-za-z]{2}\\s+plain\\stext\\s+)?(\\w+)(\\s+\\(ns\\))? like pattern pattern = pattern .compile("(\\d{4}\\s+[a-za-z]{2}\\s+plain\\stext\\s+)?(\\w+)(\\s+\\(ns\\))?"); matcher matcher = pattern.matcher("2007 al plain text ap2345 (ns)"); while (matcher.find()) { system.out.println(mat

c - How can I design a signal-safe shell interpreter -

the code have right sends prompt out stdout, reads line stdin. receiving sigint @ point interrupts execution , exits program. unsure should trap sigint , , know cannot start new prompt when signal received current code. there proper way accomplish (ultimate goal act shells (sigint cancels current prompt , starts new one))? this code run on linux, less platform independent, better. get_line reads line stdin buffer , generates char[], assigned line. split_args takes line , transforms array of char[], splitting on whitespace. is_command_valid determines if user typed known internal command. external programs cannot executed. static int run_interactive(char *user) { int done = 0; { char *line, **args; int (*fn)(char *, char **); fprintf(stderr, "gitorium (%s)> ", user); get_line(&line); if (line[0] == '\0') { free(line); break; } split_args(&a

primary key - Why can't I trust a client-generated GUID? Does treating the PK as a composite of client-GUID and a server-GUID solve anything? -

i'm building off of a previous discussion had jon skeet . the gist of scenario follows: client application has ability create new 'playlistitem' objects need persisted in database. use case requires playlistitem created in such way client not have wait on response server before displaying playlistitem. client generates uuid playlistitem, shows playlistitem in client , issue save command server. at point, understand bad practice use uuid generated client object's pk in database. reason malicious user modify generated uuid , force pk collisions on db. to mitigate damages incurred forcing pk collision on playlistitem, chose define pk composite of 2 ids - client-generated uuid , server-generated guid. server-generated guid playlistitem's playlist's id. now, have been using solution while, don't understand why/believe solution better trusting client id. if user able force pk collison user's playlistitem objects think should assume provide us

objective c - My NSViewController doesn't respect view order (OS X) -

i'm working on mac os x app . i have mainviewcontroller xib subviews , class mainviewcontroller (a nsviewcontroller ). i add in there empty nsviewcontroller above other views. set background color in layer. but, views created in xib stay above second view controller. views added programmatically in mainviewcontroller seem work expected. any idea ? edit : in fact, problem seems come second view controller, not xib. edit 2 : found 1 part of problem. second view controller load same xib mainviewcontroller shouldn't. initialize without xib : [[secondviewcontroller alloc] init] edit 3 : removed xib file , created new 1 debugging. second view controller still load xib. if remove class file's owner, still tries load it, writes error console : [nsviewcontroller loadview] loaded "(null)" nib no view set. you notice doesn't know xib's name. pretty weird.

html - Is it wrong to use "if IE" conditional comment to control what content is displayed? -

i have simple html login form in want display users internet explorer (as per existing design, not choice) , display error message when accessed other browser. my question is, how wrong use <!--[if ie]> tag in body determine content show, if @ all? there drawbacks using this? login.html <html> <head> ... </head> <body> <!--[if ie]> <form> ... </form> <![endif]--> <![if !ie]> site can accessed via internet explorer <![endif]--> </body> </html> i aware can use javascript, css or server-side things perform this, want change code , design minimally possible , quite curious drawbacks of above method. according msdn, conditional comments not supported in standards mode of ie 10. http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx that said, if supporting browsers need using them go it. don't surprised if phased out going forward. also, synt

get data from jquery client form into python server -

i wanna web-browser xml generator. input jquery dynamic form , server side (generating xml) use python. how can send jquery form data python? framework should use? tried web.py, not make done. wanna keep things small , simple. please ;) you can use python cgi . question might - how run python cgi web server in windows .

c - How to manually cause an interrupt? -

i'm writing device driver virtual device in linux kernel. because virtual, may ask there command or technique manually cause interrupt test interrupt handler? currently interrupt handler simple this: static irqreturn_t interrupt_handler(int irq, void *dev_id){ printk(kern_alert "interrupt handler executed!\n"); return irq_handled; } and called probe function: static int probe (struct platform_device *pdev) { printk("-----------------------------------------probe called \n"); ret = misc_register(&mydevice); printk("-----------------------------------------got minor:%i\n",mydevice.minor); struct resource *r = platform_get_resource(pdev, ioresource_mem, 0); if(r == null) { printk("platform_get_resource failed\n"); return -enodev; } irq = platform_get_irq(pdev,0); if (irq < 0) { printk("platform_get_irq failed\n"); return -enodev; } printk

node.js - How do I install a previous version of an npm package? -

i used nvm download node v0.4.10 , installed npm work version of node. i trying install express using npm install express -g and error express requires node version >= 0.5.0. well, odd, since following directions node+express+mongodb tutorial here used node v0.4.10, assuming express is/was available node v0.4.10. if assumption correct, how tell npm fetch version work setup? if have install older version of package, specify it npm install <package>@<version> for example: npm install express@3.0.0 you can add --save flag command add package.json dependencies, or --save --save-exact flags if want exact version specified in package.json dependencies. the install command documented here: https://docs.npmjs.com/cli/install if you're not sure versions of package available, can use: npm view <package> versions and npm view can used viewing other things package too. https://docs.npmjs.com/cli/view

scanner troubles in java -

i writing obj viewer of sorts lightweight java game library (lwjgl) , having troubles reading external obj file. when run code not print stack trace, less print nextline. here whole code (in case error in syntax outside of block of code, or put in wrong place. import java.io.filenotfoundexception; import java.io.filereader; import java.io.ioexception; import java.util.scanner; import org.lwjgl.lwjglexception; import org.lwjgl.opengl.display; import org.lwjgl.opengl.displaymode; import org.lwjgl.opengl.gl11; public class maindisplay { public void start() { try { display.setdisplaymode(new displaymode(800,600)); display.create(); } catch (lwjglexception e) { e.printstacktrace(); system.exit(0); } gl11.glmatrixmode(gl11.gl_projection); gl11.glloadidentity(); gl11.glortho(0, 800, 0, 600, 1, -1); gl11.glmatrixmode(gl11.gl_modelview); while (!display.iscloserequested()) { gl11.glclear(gl11.gl_color_buffer_bit | gl11.gl_depth_buffer_bit); gl11.glcolor3f(0.5

php - Laravel3: Giving failsafe image paths with built-in functions of Laravel -

background-image: url('home_assets/images/origami/parallax/01.png'); <img alt="" src="home_assets/images/origami/logo.png"> i worry 404 issues if: i move laravel folder subfolder, rename home_assets in future i'm looking solution like: url::to_home_assets_image('origami/logo.png'); url take care of paths. if move laravel a/b/c/ folder, should understand public folder should in a/b/c/public/ . ::to_home_assets_image should work constant. home_assets_image constant/function/object (whatever want call as) should refer 'home_assets/image/' . something this: url::to_home_assets_image('origami/logo.png'); should work. what think? worry or has done avoid folder issues? ps: can't use html::image() . break first example cause add tag. you can achieve you're after <img src="{{url::to_asset('images/original/logo.jpg')}}"> . more work urls in css styles, technicall

PHP not displaying errors when using PHPUnit -

when using phpunit terminal php not reporting errors if php error exists within php file. here example file using: <?php class assertionstest extends phpunit_framework_testcase { public function testexception() { new nonexistantclass; } } clearly nonexistantclass no exist. when running phpunit, getting this: jamesjeffery$ phpunit assertionstest.php phpunit 3.7.19 sebastian bergmann. no php errors. i using php 5.4.10. have error reporting set e_all , display_errors set on. any idea's happening?

mysql - Error in my first php code using GET -

this question has answer here: mysqli_fetch_array()/mysqli_fetch_assoc()/mysqli_fetch_row() expects parameter 1 resource or mysqli_result, boolean given 33 answers i writing first server side api, , code giving me errors... here php code (i using method) <?php //check if there function if(function_exists($_get['function'])) { //if equals loadall if ($_get['function']=='loadall'){ //then call function , pass parameter needs $_get['function']($_get['entity']); } //if found, call function value parameter $_get['function']($_get['value']); } /** * method loads of object db */ function loadall($entity){ //variables connecting database. //these variable values come hosting account. $hostname = "------"; $username = "-----"; $dbn

ios - Custom Segue class perform method called, action doesn't do anything -

i'm trying create custom segue between viewcontroller (first view) , browsercontroller (second view). currently have... customsegue.h: #import <uikit/uikit.h> @interface customsegue : uistoryboardsegue @end customsegue.m: #import "customsegue.h" @implementation customsegue - (void)perform { nslog(@"perform method running"); uiviewcontroller *viewcontroller = (uiviewcontroller *) self.sourceviewcontroller; uiviewcontroller *browsercontroller = (uiviewcontroller *) self.destinationviewcontroller; nslog(@"starting duration..."); [uiview transitionwithview:viewcontroller.navigationcontroller.view duration:0.2 options:uiviewanimationoptiontransitionflipfromleft animations:^{ nslog(@"animation section"); [viewcontroller.navigationcontroller pushviewcontroller:browsercontroller animated:no]; } completion:null]; ns

googletest - How to test a vitual pure function in C++ and Google Test? -

edited requested, e.1 : i stuck on : i need test virtual pure function in google test , cannot work. keep getting error in fixture "referencetest a:" : type 'referencetest' must implement inherited pure virtual method 'bibli::reference::clone'. error may trivial don't see it. thank help. #include <gtest/gtest.h> #include <date.h> #include <reference.h> #include <iostream> #include <sstream> #include <fstream> using namespace bibli; //********************implantation d'une classe concrete*********************** class referencetest: public reference { public: referencetest(const std::string& p_cote, const std::string& p_theme, const std::string& p_titre, const std::string& p_auteurs, int p_anneeedition, const util::date& p_dateacquisition) : reference(p_cote, p_theme, p_titre, p_auteurs, p_anneeedition, p_dateacquisition) {}; //instancier un o

ruby - Empty item at end of .each loop because of rails cycle method -

i have list should show activities inside category, , sort of works last element displayed strange. there 4 activities in db particular category , @ end of list i'm getting item /categories/1/activities %table.catlist - @category.activities.each |activity| %tr{:class => cycle('one','two')} %td= link_to activity.name, [@category, activity] %td &nbsp; i tried: link_to activity.name, category_activity_path(:category_id => @category.id, :id => activity.id) but that's not working @ all, , giving me error: no route matches {:category_id=>1, :action=>"show", :controller=>"activities", :id=>nil} the routes nested this: resources :categories resources :activities resources :records end end it's showing right, closes list strange element activity path, without id. edit i think happening because of cycle method supposed switch between css classes. ideas how empty r

Error when creating any vector with package::prob in R -

i need create simple vector x<-c(2, 4, 9, 12) , after running library(prob) , error in c(2, 4, 9, 12) : unused argument(s) (9,12) . r seems take first 2 arguments, , if try create vector 2 entries assigns value null opposed actual vector. can replicate issue on 1 computer, however. something pathological occurring. when install package:prob_0.9-2 in r 2.15.2 no error , "x" variable appears constructed. should restart , see if persists , if should reinstall r.

ios - JamVM classes outside core java on iPhone -

so have old iphone (first generation) laying around, , thought use fun stuff. jailbroke it, , installed java package off cydia. however, whenever try use classes outside of core java (anything has imported), no class def found error. printlns , simple arithmetic work, nothing else. same error doing same thing on first gen ipad. has else played around jamvm , gotten outside of core java work work?

How to change\set background image of a button in C# WPF code? -

Image
i'm trying change background image of button other image , encountered errors. code have on xaml: <button x:name="button1" width="200" height="200" content="button1" margin="0,0,0,400"> <button.background> <imagebrush **imagesource ="images/aero.png"** ></imagebrush> </button.background> </button> and cs: private void button1_click_1(object sender, routedeventargs e) { var brush = new imagebrush(); brush.imagesource = new bitmapimage(new uri("images/aero.png")); button1.background = brush; } the error have on xaml " file 'images\logo.png' not part of project or 'build action' property not set 'resource'. can me explain, thanks in build action, can mark image file content or resource. syntax use image in imagebrush different depending on 1 choose. here

caching - How to use Cache.getOrElse(java.lang.String key, java.util.concurrent.Callable<T> block, int expiration) -

how use cache.getorelse(java.lang.string key, java.util.concurrent.callable block, int expiration) give me example? point how use “expiration",i know means expire time. by way: want save object cache,and set expire time. when expire time,i can reset object cache. thanks. expiration number of seconds object hold in cache. if pass 0 expiration cache doesn't expire , have control hand. what getorelse check cache, if object not there call callable block passing , adds result cache number of seconds passing expiration time. i based comment in play framework cache javadoc .

javascript - load Js file in HTML -

my first phonegap application includes 2 html files. the first 1 named index.html uses index.js . file display list item. when click item in list, brings me detail.html file this: $.mobile.changepage("detail.html", { transition: "slideup"}); or location.href = "detail.html"; on detail.html page, load detal.js . did not work. not use functions in detail.js . please give me advise , there example ? capture photo <link rel="stylesheet" href="css/jquery.mobile.structure-1.3.0.min.css" /> <link rel="stylesheet" href="css/jquery.mobile-1.3.0.min.css" /> <link rel="stylesheet" href="css/getabstract.min.css" /> <script src="js/jquery-1.9.0.min.js"></script> <script src="js/jquery.mobile-1.3.0.min.js"></script> <script src="js/jquery.ba-dotimeout.js"><

Determine if and which partial postback occurred in pageLoad() with JavaScript in .NET -

as understand it, partial page updates asp.net ajax cause javascript pageload() event handler invoked. my question: there generic way of determining in javascript within pageload() function... i) if postback partial page update or not. ii) if so, panel updated. my application uses combination of .net updatepanels & telerik radajaxpanels. i'm looking generic (preferably javascript) solution doesn't require me specify unique client-side callback function each panel, nor set flag within each postback event handler identify client-side. to determine if postback partial update or not, can use scriptmanager.getcurrent(this.page).isinasyncpostback . here's example: protected void page_load(object sender, eventargs e) { if (page.ispostback) { // reference scriptmanager , check if have partial postback if (scriptmanager.getcurrent(this.page).isinasyncpostback) { // partial (asynchronous) postback occured

java - Listview : How to remain highlighted/selected after press back button? -

how keep listview remain highlighted when pressed button? possible? i've went through link no replies. i managed set background, image, , text in order change when user press list. one of xml: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@color/light_grey" /> <item android:state_selected="true" android:drawable="@color/light_grey"/> <item android:state_activated="true" android:drawable="@color/light_grey"/> <item android:state_focused="false" android:drawable="@color/white" /> notification_row.xml <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffffff" android:orientation="vertica

process - How to migrate a running Java program from one machine to another? -

this question has answer here: dumping java program file , restarting it 10 answers say have 1 java program running on machine a, want interrupt it, save context , resume execution on machine b. possible that? how? no, there's no way "freeze" process , "revive" on separate machine, process might holding sorts of state (open files/sockets etc) cant move it. if application youre writing better make clusterable , start node on target machine, wait 2 nodes sync , shut fown original node. if not application youre writing or above much, run application inside vm , use vm's capabilities migrate entire vm running app in (so, use vmotion).

parsing - Python argparse key=value parameters -

i've tried answer on stack overflow, can't find exact answer particular case. this first link has same question in first section, unanswered ( python argparse: parameter=value ). , second question similar, can't seem working particular case ( using argparse parse arguments of form "arg= val" ). so situation -- re-writing python wrapper used many other scripts (i prefer not modify these other scripts). currently, python wrapper called command line arguments of form --key=value number of different arguments, parsed manually. parse them argparse. n.b. argument names unwieldy, renaming using dest option in add_argument. parser = argparse.argumentparser(description='wrappin ronnie reagan') parser.add_argument("--verylongargname1", nargs=1, dest="arg1", required=true) parser.add_argument("--verylongargname2", nargs=1, dest="arg2") parser.add_argument("--verylongargname3", nargs=1, dest="arg

sharepoint - How can I upload what I've designed in visual studio back to office 365 server? -

Image
i adquired office 365 developers server publish web pages sharepoint, installed napa , gave me option of working in visual studio, after doing work don't know how upload files sharepoint server, didn't upload automatically , don't know whats wrong. can me? thanks! using "napa" office 365 development tools add "napa" office 365 development tools sharepoint store developer site. click on napa on site contents page add new project various apps available choosing. select app sharepoint. give app name , click "create" within napa window, develop new app click run project deploy app office 365 preview your project being packaged , installed on sharepoint server you can read more here

function - Return Every THIRD odd number using javascript? -

all trying return every third odd number within specified range. this 1 bit weird me, tried few different things nothing worth posting attempts yielded no results close looking for, have feeling out of scope of current capabilities, appreciated. in advance. try <script> var range = 100; var j = -1; (i = 0; <= range; i++) { if (i % 2 == 1) { j++; if (j % 3 == 0) { alert(i); } } } </script>

oauth 2.0 - how to post in user's Streams using google plus api in java -

i want share information in google plus wall application.and trying moment.insert, getting 400 error . can me @override public jsonobject getgoogleplusadduseractivities(object token) { token accesstoken = (token) token; oauthservice service = createoauthserviceforgoogleplus(); oauthrequest request = new oauthrequest(method.post,"https://www.googleapis.com/plus/v1/people/me/moments/vault"); request.addquerystringparameter("alt", "json"); service.signrequest(accesstoken, request); jsonobject object=new jsonobject(); try { object.put("kind","plus#moment"); object.put("type","http://schemas.google.com/addactivity"); jsonobject obj1=new jsonobject(); obj1.put("kind", "plus#itemscope"); obj1.put("url","https://plus.google.com/me"); obj1.put("description","sign claim , redeem credits while shopping

c# - Custom enum as optional parameter -

public enum employee { ft, pt, } this doesn't work public actionresult index(employee s = employee.pt) { viewdata["message"] = s.tostring(); return view("myview"); } exception details: system.argumentexception: parameters dictionary contains invalid entry parameter 's' method 'system.web.mvc.actionresult index(samplecontrollerex.controllers.employee)' in 'samplecontrollerex.controllers.homecontroller'. dictionary contains value of type 'system.int32', parameter requires value of type 'samplecontrollerex.controllers.employee'. parameter name: parameters but below 1 works, public actionresult index([defaultvalue(employee.pt)] employee s) { viewdata["message"] = s.tostring(); return view("myview"); } may know why 'defaultvalue' supports custom enum, optiona

oop - Why we declare some variables in PHP as like "$_variablename"...? -

this question has answer here: what's deal leading underscore in php class methods? 13 answers why declare variables in php $_variablename ? does _ define something? please me clear up, thanks. it's naming convention. from pear manual on naming conventions: private class members preceded single underscore. example: $_status

backbone.js - Grouped collection and views with Backbone.Marionette -

i have backbone collection of documents want group month, documents created within same month, grouped together. know can achieve with: var bymonth = documents.groupby(function(doc){ return this.get('date').getmonth() }); now have bymonth array, best way set backbone view automatically updates when items added collection, date on 1 of documents changes, etc - document automatically move to correct group , views updated accordingly? ps. want show aggregate data each month (for example, number of documents, etc). marionette's compositeview ideal such things, i'm not sure if , how can make work grouped collections? i've thought lot, , don't have perfect answer, here notes (brain-dump) in case / spark new ideas you: best way display (and auto-update) collection broken 3 sections/groups e.g. this-week, next-week , upcoming filter collection outside view: create filtered sub-collections in controller, , pass 1 each collectionview. there

linux - Invocation command using SSH getting failed? -

as per project requirement, need check content of zip file generated been generated on remote machine.this entire activity done using automation framework suites. has been written in shell scripts. performing above activity using ssh command abd execute unzip command -l , -q switches. command getting failed. , shows below error messages. [someuser@machine ip function]$ ./tests.sh ssh someuser@machine ip unzip -l -q some_path/20130409060734*.zip | grep -i xml |wc -l unzip: cannot find or open some_path/20130409060734*.zip, some_path/20130409060734*.zip.zip or some_path/20130409060734*.zip.zip. no zipfiles found. 0 the same command had written manually works properly. have no idea.why getting failed whenever executed via shell scripts. [someuser@machine ip function]$ ssh someuser@machine ip unzip -l -q some_path/20130409060734*.zip | grep -i xml |wc -l 2 kindly me resolve issue. thanks in advance, priyank shah when run command local

c# - Integration of BI(Business intelligence) with Portal -

one portal hosted on server , in server there business intelligence(tibco spotfire web) hosted. want integrate bi portal .how can integrate? note- portal in asp.net , business intelligence(bi) developed in java , both hosted on iis. both server have full write communicate each other. my main concern can hit on portal open business intelligence(bi)on client side. i think make api on bl web site. (using soap or restapi) if use bl javascript on client side, please check jsonp.

c++ - Logic to recognize the name of the COM port to which a USB to RS422 connector is connected (for Windows application)) -

i have application writing data serial port via usb rs422 convertor. convertor cable connected pc through usb hub. problem facing each time change pc in running application, name of com port changes. have change in code , recompile code run application. @ present following code using initialize serial port: if ((comport = createfile("\\\\.\\com7", generic_write, 0, null,open_existing,file_attribute_normal,null)) == invalid_handle_value) { return false; } here exclusively mentioning name of com port. know if there api know status of com ports , on fly recognize com port convertor connected ? what proper way detect available serial ports on windows? question might out, @ least bit. it's not possible api, second answer implies. serial ports aren't plug & play. so it's possible list ports. possible way think of, polling each device in list. , wait till response expecting. it's not nice. edit: might possible frien

java - I'm in the process of writing a Merge Sort program, I'm getting the following errors: -

please consider following code: public class mergesort { public static void main(string[] args) { int[] = new int[10]; // printing initial arrays system.out.println("array elements before sorting follows:"); for(int = 0;i < a.length;i++){ system.out.println(a[i] + " "); } // call mergesort method here // printing sorted array here system.out.println("sorted array follows:"); //for(int j = 0;j < result.length;i++){ //system.out.println(result[i] + " "); //} public static int[] merge_sort(int[] b){ if(b.length <=1){ return b; } int midpoint = b.length/2; int[] left = new int[midpoint];

android - processing human voice -

i trying make android app checks whether recorded voice of person of high frequency or not.i have completed till recording part don't know how proceed further. after searching found fft algorithm must used problem how array values must passed input algorithm. can please? assuming have defined meant "contains high frequency", , merely need measure of (no need visualize frequency content in graph), there no need calculate fft. i calculate rms values of signal (a measure of total energy), apply low-pass filter on data (in time domain) , calculate rms values again on filtered signal. comparing loss of energy measure of how high frequency content responsible initial energy value. reply comment: you need data in order process it! perhaps dont understand question? of wish "get exact values of" have stated "completed recording part" assume have signal stored in memory, need calculate total energy of signal in order either a) calculate change

algorithm - Looking for an one-way function with small input and long output -

i'm looking algorithm, one-way function, hash function. , algorithm accept small input(serveral bits, less 512 bits), , map long output(1k byte or more). know algorithm or function this? from shannon theorem don't gain security having cyphertext of size bigger plain text, unless key (or procedure create cyphertext) different input. in case, need assign 1 key (or mechanism) each input x otherwise violate definition of function. if apply encryption mechanism f: x (set of inputs) -> y (set of outputs), |y| <= |x| . all if input less 512 bits, gain nothing producing 1kb output. now, recommend use 1 of functions listed on one-way function wiki page

javascript - Backbone App Crash on Navigate -

i have single-page-app built backbone.js has multiple views in it, , app crashes when transitioning between views. when app crashes, browser not crash, app, browser displays message chrome's "oops" screen. crash forces user 'reload' refresh page, whatever working on lost if hadn't saved. crash intermittent , hard reproduce. code: to accomplish these transitions without navigation tab, create event-aggregator (or simple 'state-machine') in router so: eventaggregator: _.extend({}, backbone.events), i set-up router listen multiple events, example: this.eventaggregator.on("movetopage1", function () { this.navigate("page1", {trigger: true}); }); this.eventaggregator.on("movetopage1", function () { this.navigate("page2", {trigger: true}); }); so routes this: routes: { "page1": "viewpage1", "page

regex - Regular expression grouping with lookaheads (in Python) -

i'm modifying regular expression extract group of group matches, 'supergroup' not return composite matched string expected. the string match of form: /dir/somestring-w0.12+345.raw.gz and regex i'm using: /dir/ (?p<super> (?p<name>.*?) (?=(?p<modifier>-w\d\.\d{2}[+-]\d{3})?\.(?p<extension>raw\.gz|root)$) ) i'm getting following results named groups: modifier: '-w0.12+345' super: 'somestring' name: 'somestring' extension: 'raw.gz' while expecting super: 'somestring-w0.12+345.raw.gz' the grouping of subgroups has worked me, not time, , cannot understand why. hope give me hint. note: explanation of regex can found in ( matching specific substring regular expressions using awk ) the group super matches same text group name matches, because lookahead assertion doesn't contribute actual characters match (that's why they're called "zero-width asserti

api - Beginner in Python programming -

i working on project in task design command prompt application using python technology collect data such appointments, events, user contact etc. server, in firm work uses thunderbird or other calendar applications store appointments, events, etc. these data stored in 1 main central server. my task develop command line interface connect server , data such user contacts, appointments, events etc. , display them in cmd according user selections since beginner development , python confused how start stuck @ starting point , confused without idea. have been given test system test application stuck without clues. i suggest start breaking problem down. sound you're struggling decide on start because you're thinking of whole project 1 problem solve, can tackle breaking down. beginner, playing around components crucial part of learning, simplify essence , play that. i suggest start connecting server, , retrieving list of tables in database (or data stored - know?) if

python - Shifting 3D numpy array -

i able shift 3d numpy array in either direction along height axis. if positive shift of 3 given, values in array shift , 3 new slices of zeros appear @ bottom of array. opposite occur if negative shift given, slices shift down along height axis , new slices of zeros appear @ top. i have attempted reshaping array 1d , shifting left , right, , returning 3d. however, shifts array along wrong direction. tried implementing numpy.rollaxis before reshaping, shifting along correct axis. system i'm working on not recognize numpy functions , not perform rollaxis. thanks! your question little ill defined. first, 'height' axis not clear definition of 1 after in 3d array. better locate them position in shape tuple. going take meaning 'along first axis', should obvious how different one. second, while clear want zeros fill in shifted data, don't specify want data on other side: should disappear beyond array's boundary , lost? or should array extended ke