Posts

Showing posts from July, 2012

function - Run Dial & Say at the same time on Twilio? -

when user calls number, wish have twilio <say> them while <dial> ing number, issue is, can seem 1 or other (i.e. say, dial (delaying dial), or, dial, (not saying until call over)). want either of following (first 1 preferable, although answers both best (in case need opposite 1 in future/someone googling)):- initiate call new number and start saying "lorem ipsum...", if finishes first silence until call picked up, if phone number picks first, let finish transfer them/combine calls. initiate call new number and start saying "lorem ipsum...", if finishes first silence until call picked up, if phone number picks first, cut command off , instantly transfer/combine calls. thanks! twilio evangelist here. there no way using twiml twilio processes twiml sequentially going finish <say> before moving on <dial> . you combine twiml rest api however. in same http request generating twiml in it, make call out rest api have tw

amazon web services - Cannot Launch EMR Jobflow using Temporary Credentials from EC2 IAM Roles -

i have instance has been assigned ec2 iam role. cannot create emr jobflow instance using temporary credentials having role assigned instance provides, following response api: <error> <type>sender</type> <code>validationerror</code> <message>service role , instanceprofile required calls made temporary credentials provided sts</message> </error> googling error message has revealed absolutely nothing. same response api whether use aws cli or boto directly. in attempt follow advice of error message, have tried passing {instanceprofile: <instance_profile_name>} api_params argument run_jobflow method in boto, still same error. tried using service_role argument run_jobflow , failed. passing both failed. according page amazon docs, emr should support sts , ec2 iam roles, wondering if has gotten work before. i got working in java. sam, specified service role , jobflow role. surprise me error instance

ruby on rails 3 - Error pushing Heroku created App to Github -

i have created empty rails project using railsinstaller, able generate ssh pair , set project on git/github. went set on heroku, gem install , create commands went well. attempted git push , received error below, attempted ssh heroku putty i'm not sure right step. have been following exact instructions this book set project. c:\rails_projects\first_app>heroku keys:add found existing public key: c:/users/jeff/.ssh/id_rsa.pub uploading ssh public key c:/users/jeff/.ssh/id_rsa.pub... done c:\rails_projects\first_app>heroku create --stack cedar creating protected-spire-2324... done, stack cedar http://protected-spire-2324.herokuapp.com/ | git@heroku.com:protected-spire-2324 .git git remote heroku added c:\rails_projects\first_app>git push heroku master server refused public-key signature despite accepting key! fatal error: disconnected: no supported authentication methods available (server sent: publickey) fatal: not read remote repository. please make sure have corr

matlab: minimization/optimization algorithm -

i use function multiple outputs farina4 computes coefficients a , b , e , f , vector out_p5tads_final (1 x n array) through minimization of system of equations using data input set p5tads (1 x n array): function [a b e f fval out_p5tads_final] = farina4(p5tads) f = @(coeff)calculs_farina4(coeff,p5tads); [ans,fval] = fminsearchcon(f,coeff0,[0 0 0 0],[1 1 1 1]);% fminsearch constrains = ans(1); b = ans(2); e = ans(3); f = ans(4); out_p5tads_final = p5tads_farina4(a,b,e,f); function out_coeff = calculs_farina4(coeff0,p5tads) %bla-bla-bla end function out_p5tads = p5tads_farina4(a,b,e,f) %bla-bla-bla end end after calculating a , b , e , f , out_p5tads_final need calculate/minimize rms function respect out_p5tads_f4 . rms = sqrt(mean((p5tads(:) - out_p5tads_f4(:)).^2))*100 and repeat function farina4 in order find optimal set of parameters a , b , e , f , out_p5tads_final . i trying build algorithm of such optimization , not see way far. instance, seems

mongodb - Imports to Mongo limited to 16MB if using jsonArray -

i using mongo 2.6.1. want import data json file > 16 mb. json array of documents. according documentation if use --jsonarray option, file can 16mb, see http://docs.mongodb.org/manual/reference/program/mongoimport/ strangely, have managed import data > 16 mb (24mb) no problem using mongoimport, doing: mongoimport -db mydb --collection product --file products.json --jsonarray so 16mb limit then? 16 mb mongodb bson document size limit . means no document inside mongodb exceed 16 mb. note json representation of mongodb document exceed limit, since bson more compact. the problem --jsonarray flag mongoimport reads whole .json file single document first, , performs import on each of elements, suffering bson document size limit. solution new mongodb versions ( 2.5.x , later) i tested mongoimport latest mongodb 2.6.4 using large json array (~200 mb) , worked perfectly. i'm pretty sure such operation impossible mongodb 2.2.x . so, looks mongodb.org

database - How to get recordset into bidimensional array in vbscript? -

i want table bidimensional array in vbscript (i'm using asp access mdb), anyway, trying make this: 'levels' dim 1 : 1 = array() dim 2 : 2 = array() dim 3 : 3 = array() dim 4 : 4 = array() dim 5 : 5 = array() dim level recordset.open sql, connection if recordset.recordcount <> 0 each record in recordset level = record("level") select case level case 1 case 2 case 3 case 4 case 5 end select next end if but seems doesn't work, i'm not sure if bidimensional variable declaration right way of doing it. can 1 enlighten me? in advance. why not use built-in getrows() method instead. takes recordset , puts 2 dimensional array. here's sample code w3schools.com illustrates method well: &

java - Android Iterate Over List -MapView -

i'm attempting iterate on array list running errors when try create dynamic map marker on mapview. casting values not seem work @ bottom of method when try loop iterate on both latitude , longitude values in allpostmarkers json array. please let me know if need more information me , happy provide more code. i'm still iterating on array list problem. private jsonarray allpostsmarkers = null; private arraylist<hashmap<string, string>> mpostsmarkerlist; public void updatejsondata() { // instantiate arraylist contain json data. // going use bunch of key-value pairs, referring // json element name, , content, example, // message tag, , "i'm awesome" content.. mpostsmarkerlist = new arraylist<hashmap<string, string>>(); // bro, it's time power j parser jsonparser jparser = new jsonparser(); // feed beast our comments url, , spits // json object. boo-yeah jerome. jsonobject json = jparser.ge

swift - Why can't I append a String to a NSURL? -

appending .txt file component url path doesn't work: var error:nserror? let manager = nsfilemanager.defaultmanager() let docurl = manager.urlfordirectory(.documentdirectory, indomain:.userdomainmask, appropriateforurl:nil, create:true, error:&error) docurl.urlbyappendingpathcomponent("/ricfile.txt") <-- doesn't work via debugger: file:///users/ric/library/developer/coresimulator/devices/ <device id>/data/containers/data/application/<app id>/documents/ writing string using docurl file doesn't work because of missing file name. reason (via error): "the operation couldn’t completed. directory" so question: why doesn't following work? docurl.urlbyappendingpathcomponent("/ricfile.txt") urlbyappendingpathcomponent: doesn't mutate existing nsurl , creates new one. documentation : urlbyappendingpathcomponent: returns new url made appending path component original url. you'll

c++ - Why does this line of code cause a computer to crash? -

why line of code cause computer crash? happens on memory-specific level? for(int *p=0; ;*(p++)=0) ; i have found "answer" on everything2, want specific technical answer. this code formally sets integer pointer null, writes integer pointed 0 , increments pointer, looping forever. the null pointer not pointing anything, writing 0 undefined behavior (i.e. standard doesn't should happen). you're not allowed use pointer arithmetic outside arrays , increment undefined behavior. undefined behavior means compiler , library authors don't need care @ these cases , still system valid c/c++ implementation. if programmer classified undefined behavior whatever happens happens , s/he cannot blame compiler , library authors. programmer entering undefined behavior realm cannot expect error message or crash, cannot complain if getting 1 (even 1 million executed instructions later). on systems null pointer represented zeros , there no support memory protec

c# - How to make a "Real-Time Responsive"? -

i have textbox , datagridview. when user presses types words inside textbox, datagridview should show result db (bound datagridview) question: how make textbox "on real response"? i mean if type "hello", , during processing of inputting each letter textbox, each time have new search, ui form must dead because there many requests db. know can use threads, want there's mechanism can allow me cancel or accept "search db , bind datagridview". in detail, is: each time when change textbox's value, there comes request value textbox , search db, , previous textbox's value can cancelled instead of doing previous search in background-thread, etc. does .net framework have such mechanism now? or someone can suggest ideas cancelling previous query string searched or during searching process? can show me demo persudo codes if want cancel previous query call cancel on dbcommand object executed query. why don't know already, given

android listview - setOnCheckedChangeListener -

i want expand group item when check on it, reasons can't collapse group item after expands. can please tell me doing wrong? public view getgroupview(final int groupposition, boolean isexpanded, view convertview, viewgroup parent) { final groupholder holder; final viewgroup viewgroup = parent; if (convertview == null) { convertview = layoutinflater.inflate(r.layout.group_list, null); holder = new groupholder(); holder.checkbox = (checkbox) convertview.findviewbyid(r.id.cb); holder.imageview = (imageview) convertview.findviewbyid(r.id.label_indicator); holder.title = (textview) convertview.findviewbyid(r.id.group_title); convertview.settag(holder); } else { holder = (groupholder) convertview.gettag(); } holder.imageview.setimageresource(groupstatus[groupposition] == 0 ? r.drawable.group_down: r.drawable.group_up); final item groupitem = getgroup(groupposition); holder.title.settext

Using URL to connect to webservice through Java -

i using jira rest api pull issues created in jira . when enter url [ http://example.com/rest/api/2/search?jql=project=demo , issuetype=bug&fields=summary,priority ] in browser , getting issues , bugs , along fields summary , priority . when try use in java application , not getting same output , getting issues created .my doubt how encode url in java application . used urlencoder.encode(string s,string enc), not helpful in encoding url . idea on how encode url , cause not getting response , got in browser ?? before constructing url have segregate individual querystring values , encode following way... import java.io.unsupportedencodingexception; import java.net.urlencoder; public class urlencodetest { public static void main(string[] args) throws unsupportedencodingexception { string baseurl="http://example.com"; string finalurl=baseurl + "?a=" + encode("this is") + "&b=" + encode(":url

r - How to add multiple columns to a data.frame simultaneously? -

i have following dataframe , vector: ddf = data.frame(a=rep(1,10), b=rep(2,10)) xx = c("c", "d", "e", "f") how can new empty columns named items in xx ? i tried following not work: ddf = cbind(ddf, data.frame(xx)) error in data.frame(..., check.names = false) : arguments imply differing number of rows: 10, 4 following not work: for(i in 1:length(xx)){ ddf$(xx[i]) = "" } error: unexpected '(' in: "for(i in 1:length(xx)){ ddf$(" } error: unexpected '}' in "}" this there: ddf[xx] <- na # b c d e f #1 1 2 na na na na #2 1 2 na na na na #3 1 2 na na na na #... you can't directly use ddf$xx because try assign column called xx rather interpreting xx . need use [ , [<- functions, using square brackets when dealing character string - ddf["columnname"] . the reason why selects columns because data.frames lists essentially: is.list(ddf)

c# - Jabber server doesn't reply to Client Final Message -

i'm working on own jabber client (mostly learn both xmpp , c#) , i'm trying connect server using scaram-sha-1 on tls. tls negotiation goes fine first client/server messages exchange, server challenge , generating client final message following code: //following block generates client final message //---step 1. creating salted password--- byte[] saltbytes = encoding.utf8.getbytes(salt); byte[] saltedpasswordbytes = getsaltedpassword(userpassword, convert.frombase64string(salt), iterations); //---step 2. creating client key--- byte[] clientkeybytes = gethash("client key", saltedpasswordbytes); string clientkey = bitconverter.tostring(clientkeybytes); //---step 3. creating stored key--- sha1 storedkeysha = sha1.create(); byte[] storedkeybytes = storedkeysha.computehash(clientkeybytes); string storedkey = bitconverter.tostring(storedkeybytes); //---step 4. creating auth message--- string authmessage = "n=test_guy,r=" + clientnonce + "," + serve

javascript - pass variable from options page to content script chrome extension -

lets have in options.html , want take user-defined value of , define @ variable called keyword: var keyword = document.getelementbyid("keyword").value in options.js. want pass on variable keyword contentscript.js. i've looked @ both google chrome's message passing guide , storage guide on dev site. still can't execute way intend though. appreciated. thank you!

.htaccess - htaccess redirect including string -

i know how redirect normal links without strings, including string email addresses has me stuck. can please assist 301 redirecting url domain including url string? need redirect following: www.domain.com/page.php?e=tom-jones@mail.com to www.domain1.com/?e=tom-jones@mail.com i need keep email address in string when it's redirected new url thanks in advance. in htaccess file in www.domain.com document root, can add: redirectmatch 301 ^/page\.php$ http://www.domaon1.com/ the query string automatically appended. or can use mod_rewrite: rewriteengine on rewritecond %{http_host} ^(www\.)?domain\.com$ [nc] rewriterule ^page\.php$ http://www.domaon1.com/ [l,r=301]

design patterns - A Django admin interface for my Django admin interface -

my django project has models shoptype , shopitem . each shoptype object create, want associate — not single shopitem object — subclass of shopitem . basically, want model type in django not textfield or imagefield or like, model field. example: using django admin interface, create new instance of shoptype called cheeseshop . in turn creates new model called cheese inherits of behavior shopitem . if go main page of django admin site, there's new link called "cheeses", , can create bunch of cheese s please. of course, suspect that's not possible: if create — — petshop , wouldn't have add new record database, i'd have augment database schema include pet s (along registering new pet model admin interface , other complicated things haven't thought of yet). but maybe there's existing django solution pattern? or maybe there's different, better-suited approach problem might achieve same effect? any thoughts?

plugins - Milliseconds format in maven.build.timestamp -

this scenario, it's pretty simple afraid took me 2 days already. in pom.xml, have set of properties. <properties> <timestamp>${maven.build.timestamp}</timestamp> <maven.build.timestamp.format>yyyymmdd-hhmmsssss</maven.build.timestamp.format> </properties> the format fine because i've got milliseconds in it, however, wanted have milliseconds, 1 returned in, date.gettime(); can in maven plugins? thanks. you can have @ plugin: http://www.mojohaus.org/buildnumber-maven-plugin/create-timestamp-mojo.html . default, returns time in milliseconds.

Inno - how to address the setup window title? -

Image
how can address text code? r.png you can access caption property of wizardform , e.g.: [code] procedure initializewizard; begin wizardform.caption := 'hi, i''m installer!'; end;

c# - How to show a form infront of all windows interfaces (start screen) -

i want make winforms make in front of many thing (in windows 8, in front of start screen, make can leave desktop while desktop snapping). for example, magnifier (magnify.exe) dialog in windows 8 top start screen. it possible make happen (in vb or c#)? this image example ask for, far didn't find sdk this, , image edited (none of many application except magnifier (magnify.exe)) http://i.stack.imgur.com/1uxcx.png alternative : https://docs.google.com/uc?authuser=0&id=0b0xi21kq3jxrlww4cll6x3njsta&export=download you can make form modal calling form.showdialog() don't forget set form.dialogresult accordingly on modal form. an easy example following: form f = new form(); f.showdialog(this); the other option set form's topmost property true. finally, have modal property block other no modal forms click or keyboard events. but given winforms desktop app, able show in desktop of windows 8, not new metro interface.

ios - Block isn't recognized unless it is defined in the same class -

i trying define instance variable block i have 2 classes follows @interface classa:nsobject typedef void (^ablock)(void); @end #import "classa.h" @interface classb :nsobject -(void)somemethodwithablock:(ablock)block; @end in class b " ablock " type not recognized unless written right above " somemethodwithablock " how can fix it? you want this? typedef void (^blocka)(void); #import <foundation/foundation.h> @interface classa : nsobject { blocka classablocka; } @end @interface classb : nsobject { blocka classbblocka; } @end

primefaces - avoid nodes of p:treeTable to collapse after update -

i have p:treetable in form , p:dialog in form p:dialog add data p:treetable on submit of h:commandbutton of dialog add update of p:treetable in orded see added node the issue expanded nodes user has opened collapse i found question avoiding collapsing of p:treetable after update in question wrote solved no answer or solution question to avoid collapsing or expanding have mark node on java side collapsed or expanded. that add ajax calls , listener methods. jsf/faces: <p:tree ...> <p:ajax event="expand" listener="#{backing.nodeexpand}" /> <p:ajax event="collapse" listener="#{backing.nodecollapse}" /> ... </p:tree> java/backing: public void nodeexpand(nodeexpandevent event) { event.gettreenode().setexpanded(true); } public void nodecollapse(nodecollapseevent event) { event.gettreenode().setexpanded(false); }

c# - HTTP Error 500.19 - Internal Server Error -- IIS when accessing shared by specified user -

i created virtual directory (on server 1) access shared location ( share on server ). give url http://server1.com/alias shared location contains few folders. through application ( located on server1), need access url http://server1.com/alias/folders instead of using pass through application, used specific user credentials connect shared location. verified user has full access shared location. but when accessing url http://server1.com/alias/ below error. http error 500.19 - internal server error requested page cannot accessed because related configuration data page invalid. module iis web core notification beginrequest handler not yet determined error code 0x8007052e config error cannot read configuration file config file \\?\unc\server1.com\alias\upload\web.config requested url http://server1.com/alias/ physical path \\server2\\share logon method not yet determined logon user not yet determined config source -1: 0: instead of using specified user credent

How do I insert Images on an Acumatica Email Template -

how insert images on acumatica email template. create custom header , signature of email. tried following options, , both of them did not work: tried access branch logo option objects not found because screen selection seems different. tried insert tag on template did not work. first should copy image clipboard, paste email template. work me!

c# - Debugging multiple projects in a single solution -

is there way around issue of debugger being raised each project in solution when debugging postsharp? have 14 projects in solution , trying debug 1 of them postsharp seems difficult because debugger attach window pops each project in solution. if choose attach wrong debugger process breakpoint have set not hit , then, when starts building next project pops window not have active vs instance in it. there flag on msbuild can use "use same debugger process requirements of debugger process" or effect? as understand, you're debugging compile-time logic of aspect following steps postsharp documentation . when set "attach debugger" property on command-line, shown below, property set projects involved in build. , attaching debugger invoked each of projects. msbuild myaspects.test.csproj /t:rebuild /p:postsharpattachdebugger=true what can instead, set property 1 project need it, temporarily editing *.csproj file: <propertygroup condition="

php - Migrate fails Laravel -

so decided try out laravel since heard it's great framework similar rails etc. got stuck in basic first parts of creating testapplikation. when try create migration file errors. php artisan migrate:make create_users_table parse error: parse error in /myfolders/myproject/vendor/laravel/framework/src/illuminate/support/helpers.php on line 411 anyone have ideas? should mention don't have composer installed cause want focus on creating basic laravel project. you need upgrade php version, laravel 4 requires php >= 5.4 .

android - How to change divider color option menu item? -

Image
i want change default divider color of option menu, can give me suggestion or technical? you can setting theme popup menu use below code in style.xml file in res folder <style name="mythemepopup" parent="@android:style/theme.holo.light.darkactionbar"> <item name="android:textcolor">@color/white</item> <item name="android:dividerheight">2px</item> <item name="android:divider">#f00</item> <item name="android:popupmenustyle">@style/popupmenu</item> </style> <style name="popupmenu" parent="@android:style/widget.popupmenu"> <item name="android:popupbackground">@color/opaque_black_color_dark</item> </style> above code creating theme <item name="android:divider">#f00</item> use setting color divider after can set created th

C# - Winforms Drawing on Bitmap -

Image
i having such kind of problem. making small photo editor, can select image, change brightness contrast of image, draw text on image. form. . have methods. private void drawtext(string text, int x, int y) { rectanglef rectf = new rectanglef(x, y, 90, 50); graphics g = graphics.fromimage(this.picturebox1.image); g.smoothingmode = smoothingmode.antialias; g.interpolationmode = interpolationmode.highqualitybicubic; g.pixeloffsetmode = pixeloffsetmode.highquality; g.drawstring(text.tostring(), new font("tahoma", convert.toint32(this.textboxsize.text.tostring())), brushes.black, rectf); g.flush(); } private void setbrightness(int brightness) { if (!object.referenceequals(this.picturebox1.image, null)) { bitmap temp = (bitmap)this.picturebox1.image; bitmap bmap = (bitmap)temp.clone(); if (brightness < -255) brightness = -255; if (brightness

polling - Angularjs how to access scope data outside the angular-poller function -

i'm pooling data using ng-poller function , splice data/json file. problem if navigate between tabs/menu data being spliced each time. need able poll data , access them outside function not being spliced every-time navigate through site. here's controller: 'use strict'; angular .module('myapp') .controller('analyticshistoryctrl', ['$scope', 'poller', 'analyticshistory', function ($scope, poller, analyticshistory) { var datatosplice; var polleranalyticshistory; polleranalyticshistory = poller.get (analyticshistory, {delay: 10000}); polleranalyticshistory.promise.then (null, null, function (data) { //this works fine splices //data every 10000ms not $scope.mydata = data.analytics.splice(0,5); //i'm trying access outside $scope.mydata = data.analytics; dat

collaborative filtering - Is this an approach to user-item recommendations that could work -

i designing application incorporates recommendation system base on user interactions (collaborative filtering). user on homepage presented set of 6 items interact with. there between 50 , 300 items. following actions possible: click on item (strong interest) refresh item (some interest) open read-more dialog (some interest) don't move on (no interest) this data collected , stored. system should recommend items of interest user. i'am thinking turning data rating system. option a) if user clicks on item, translated implicit lifetime rating of 5. refreshing item 4 , on. user->item matrix this: item 1 | item 2 | item 3 john 5 4 jane 4 in example john has clicked on item 1 , refreshed item 3. rating can go really, i.e. if user has refreshed item write 4 , update 5 if item clicked later. option b) each time user 1 of above actions, i'll increment scalar value item, means can grow unbounded. item 1 | item 2 | item 3 john

jsf - Override css for a single column in richdatatable -

i using jsf 1.2. css columns of rich:datatable follows:- .cssallcolumns { border-right: 1px solid #a0b681; border-top: 1px solid #a0b728; border-left: 1px solid #a0b681; border-bottom: 1px solid #a0b728; padding: 1px; } .... <rich:datatable value="#{employeebean.employeelist}" ... columnclasses="cssallcolumns" .../> i want single column align left follows <rich:column id="employeename" sortable="true" style="text-align:left;cellspacing=5;"> its aligning single column left , other center (as per requirement) tightly left_aligned. want leave 2 3 char-spaces left border. how achieved? i have never used rich tables if follow same principles, inline css incorrect. change <rich:column id="employeename" sortable="true" style="text-align:left;cellspacing=5;"> to <rich:column id="employeename" sortable="true" cellspac

class - How to make link between LocalApp project to RemoteApp project in standalone maven? -

i created 1 localapp project , 1 remoteapp project. used classes of remoteapp project in localapp project. i added dependencies group id, artifact, version , scope of remoteapp pom.xml of localapp while executing localapp command prompt, got noclassdeffoundexception means inherited classes of remoteapp not visible in localapp. how can localapp find classes remoteapp?

javascript - How can i get external HTML with JS or jQuery -

this question has answer here: ways circumvent same-origin policy 11 answers i trying html of external url jquery cannot code below work. can 1 tell me how make work? <script language="javascript" type="text/javascript"> $.ajax({ url: 'http://news.bbc.co.uk', type: 'get', success: function(res) { var headline = $(res.responsetext).find('a.tsh').text(); alert(headline); } }); </script> crossbrowser access not allowed in ajax you use jsonp has limitation another solution create iframe , change url website want. when iframe loads innnerhtml of iframe , should provide result <iframe id="urldetails" onload = "htmlcontent()" src=""></iframe> $("#urldetails").attr("src","http://news.bbc.co.uk");

c++ - VertexShader compile fails on windows, same code works on linux -

i following opengl tutorial here . works on arch linux system, not on windows. my vertex , fragment shader code in example: fragment shader code: #version 330 core in vec2 uv; out vec3 color; uniform sampler2d mytexturesampler; void main(){ color = texture2d( mytexturesampler, uv ).rgb; } vertex shader code: #version 330 core layout(location = 0) in vec3 vertexposition_modelspace; layout(location = 1) in vec2 vertexuv; out vec2 uv; uniform mat4 mvp; void main(){ gl_position = mvp * vec4(vertexposition_modelspace,1); uv = vertexuv; } i following errors on windows: error: 0:16: 'texture2d' : no matching overloaded function found (using implicit conversion) error: 0:16: 'rgb' : field selection requires structure, vector, or matrix on left hand side error: 0:16: 'assign' : cannot convert 'const float' 'fraguserdata 3-component vector of float' do have ideas problem might be? this listed in v330 spec @mrvoid

java - IntStream strange error -

java 8 has new interface, named intstream . used of() static method , encountered strange error: this static method of interface intstream can accessed intstream.of but can see in following code, i, exactly, used intstream.of import java.util.stream.intstream; public class test { public static void main(string[] args) { int[] listofnumbers = {5,4,13,7,7,8,9,10,5,92,11,3,4,2,1}; system.out.println(intstream.of(listofnumbers).sum()); } } moreover, if check api , see method has been declared in similar way used. although intstream.of(int...) seems work more expected use arrays.stream(int[]) . public void test() { int[] listofnumbers = {5, 4, 13, 7, 7, 8, 9, 10, 5, 92, 11, 3, 4, 2, 1}; // works fine designed ints instead of int[]s. system.out.println(intstream.of(listofnumbers).sum()); // expected use. system.out.println(intstream.of(5, 4, 13, 7, 7, 8, 9, 10, 5, 92, 11, 3, 4, 2, 1).sum()); // better approach i

java - TestNG is not running in parallel in eclipse -

my colleague , working on project using testng. using data provider , @ factory. code runs in parallel in system , not in system! same code! only difference uses netbeans , using eclipse. have installed testng plugin. able run test, not in parallel in eclipse. same code runs in parallel in netbeans. any ideas how can make code run in parallel in eclipse ?

php - preg_replace match and replace exact count of characters -

how can add count or whatever else preg_replace replaces when encounters 2 or 3 > , not more or less that? original $str = '>>this code>> text >>>this link>>>. >>>>this need not replaced>>>>'; $patterns = array('#>>((?!>[^>]).+?)>>#','#>>>((?!>[^>]).+?)>>>#'); $actions = array('[code]$1[/code]','[a]$1[/a]'); echo preg_replace($patterns, $actions, $str ); //output [code]this code[/code] text >[code]this link[/code]>. [code]>>this need not replaced[/code]>> expected [code]this code[/code] text [a]this link[/a]. >>>>this need not replaced>>>> what i'm trying here is, match >> , >>> , not else, third 1 in string. current end doing matching in there. i tried adding {2} , {3} $patterns : $patterns = array('#>>{2}((?!>[^>]).+?)>>{2}#','#&g

.htaccess - removing second language on site, how to redirect without having to do all pages? -

for client updating website. 1 of things having remove english part of site (just keeping dutch part) since there on 70 pages not want redirect every single page. want redirect every page has ?lang=en in title homepage. is idea, , if so, tips should write in .htaccess? thanks!!

c# - Freezable exception after logging in remotely and logging back locally -

i getting error reports users logging in remotely application. app works fine until when come office , log directly desktops - app crashes , error report standard 'freezable cannot frozen' none of known workarounds fixing one. every single brush resource in app decorated ice:freeze: <solidcolorbrush ice:freeze="true" also exception thrown domain unhandled exception there way swallow it. over last couple of months spent hours analyzing reported issues freezables bot cannot find solution. .net code problem happens: /// <summary> /// unbinds freezable context. /// </summary> /// <param name="resource">the resource freeze.</param> private static void freeze(object resource) { freezable freezable = resource freezable; if (freezable != null && !freezable.isfrozen) { freezable.freeze(); } } /// <summary> /// searches res

javascript - ng-include : How can I maintain data in $scope after changing views? -

please check jsfiddle: http://jsfiddle.net/mystikacid/b7hqcdfk/4/ template: <div ng-app="myapp"> <div ng-controller="datactrl"> <div>data : {{data}} (value outside views)</div> <div ng-include src="view"></div> <script type="text/ng-template" id="view1"> <p> view 1 </p> <p>value inside view 1 : {{data}}</p> <input type = "text" ng-model = "data" /> <button ng-click = 'changeview("view2")' > go view 2 </button> </script> <script type="text/ng-template" id="view2"> <p> view 2 </p> <p>value inside view 2 : {{data}}</p > <input type = "text" ng-model = "data" /> <button ng-click = 'changeview("view1")' > go view 1 <

How to preserve variable type when posting to php from javascript -

when use ajax post data javascript php, php $_post variables strings. there way preserve variable type when posting. eg when posting boolean true want boolean true , not string 'true'. you can use json format , php json parser you. you can find example here: http://php.net/manual/en/function.json-decode.php#90790

asp.net mvc - Sending form with Select List -

i using code post value of selected item view controller @using (html.beginform()) { @html.dropdownlistfor(model => model.myvar, (selectlist)viewdata["list"]) <button name="button" value="valider">valider</button> } is there way send value when selection change in select list (without need click on button) ? yes can via jquery , on dropdown selection change post form via jquery: add id drop down: @html.dropdownlistfor(model => model.myvar, (selectlist)viewdata["list"], new { id="someid"}) and write jquery event: $(function(){ $("#someid").change(function(){ $(this).closest("form").submit(); // post form }); });

php - Group conversation by ID and join the most recent message -

i have 2 tables. conversations id | user_from | user_to | subject messages id | user_id | conversation_id | message now want pull conversations particular user . however, can't figure how this. current solution gives me oldest message each conversation. db::table('conversations') ->where('user_from', '=', $this->id) ->orwhere('user_to', '=', $this->id) ->join('messages', 'conversations.id', '=', 'messages.conversation_id') ->groupby('conversations.id') ->get(); how can newest message each conversation? in plain mysql can use additional self join messages ,according question guess id messages table set auto_increment have used max(id) recent message id per conversation select c.* conversations c join messages m on(m.conversation_id = c.id) join (select conversation_id,max(id) ic messages group conversation_id) mm on(m.conversation_id = mm.conversa

java - No ONE Here to help me !... Frustated about Different Size but same result when rendered -

update : sorry, earned tumbleweed badge before, , thread has been quiet whole day... i editing whole question might not clear others help. take @ game image i modifying super jumper game (mario zechner's beginning android game) , i've come stuck in issue: if @ image link above, see character image rendered in same size spring image. i'm using texture atlas 1024x1024 px, spring = new textureregion(items, 980, 90, 32, 40); charjump = new animation(0.2f, new textureregion(items,charx+32, chary, 64,160), new textureregion(items, charx+150, chary, 64, 160)); //char anim. i using photoshop , put texture region required in atlas. each character image frame has size of 64x150 while spring image has size of 30x40 the world class camera width , height = 11f x 14f world renderer class camera width , height = 11f x 14f please give me clue, important knowledge missing here ? thank you. i found culprit !!.. batcher.dra

ios7 - how to disable a navigation bar button item in iOS -

i have created navigation controller. in second view (which pushed), have webservice call , placing overlay view , setting self.view.userinteractionenabled = no ; once web service call complete, reverting self.view.userinteractionenabled = yes ; when this, every other buttons except buttons on navigation bar disabled. how disable 2 navigation bar button items ? (a button similar button, pops first view controller , button gives info help). i have tried using self.navigationitem.backbarbuttonitem.enabled = no . still able tap on button , can navigate first screen. how can disable these 2 buttons ? try this recommended self.navigationitem.leftbarbuttonitem.enabled = no; self.navigationitem.rightbarbuttonitem.enabled = no; or disable on edge case self.view.window.userinteractionenabled = no; update: apple doesn't allow button enable / disable. instead of can hide it. self.navigationitem.hidesbackbutton = yes;

ruby - Use Devise in rails application with engines -

i creating rails application , separated application 2 engines. application uses devise gem user registration , authorization. devise gem connected in root app , admin side lying inside 1 of engines. admin side layout still inside root application. if use code <%= link_to edit_user_registration_path %> in admin layout showing me following exception: undefined local variable or method `edit_user_registration_path' at /app/views/layouts/admin.html.erb can please me solve problem. can reason outcome? i think have messed routes.rb ..let me give u hint... for /admin/posts , admin/posts#index , <%= link_to admin_posts_path %> work,your routes must have namespace :admin resources :posts, :comments end but like( only url , helper/controller without admin ) work `/admin/posts` , `posts#index` , `<%= link_to posts_path %>` then ...your routes must have resources :posts, path: /admin/posts so must have in routes(using devise)

camera - Unity 2D Background Implementation -

i'm trying use fixed background. added image child of camera , sized fill view of camera. seems in unity player when run on android devices, background seems short. see blank space in left , right sides of screen. orthographic size 6. this position plane or quad , scale fill screen. works both in orthographic , perspective. orthegrphic size doesnt matter. step 1 - create plane object in scene. step 2 - add script object created. step 3 - script auto resize , position @ near clip using unityengine; public class fillscreenplane:monobehaviour { public float lunityplanesize = 10.0f; // 10 unity3d plane void update() { camera lcamera = camera.main; if(lcamera.isorthographic) { float lsizey = lcamera.orthographicsize * 2.0f; float lsizex = lsizey *lcamera.aspect; transform.localscale = new vector3(lsizex/lunityplanesize, 1,lsizey/lunityplanesize); } else { fl

apache pig - Pig: Absolute value of an integer -

i give absolute value of integer field not work. how can correctly? y = foreach x generate abs(quantity); thanks intabs solution works integer not expressions

python - Newly created records in domain not shown in field OpenERP -

i have been working on search module in openerp-7. returning records in domain can show them on field. problem field not showing newly created records in domain. while on printing value of domain on console, desired records. don't seem why it's not allowing me view them in field. neither getting error. my domain part of function follows: res = cr.fetchall() p_id,p_name in res: domain.append((p_id)) print domain return {'domain':{'my_products':[('id','in',domain)]}} to see records in one2many, don't have use 'domain', must use 'value' template save one2many records (see in server/bin/openerp/osv/fields.py around line 420) : # --------------------------------------------------------- # relationals fields # --------------------------------------------------------- #

Laravel pivot: Get model from withPivot() -

i'm building application using laravel 4 have stumbled across problem pivot tables. i've got user model, establishment model, & studylevel model. for moment find establishment user has been @ use following code in user model: public function establishments() { return $this->belongstomany('establishment')->withpivot('start', 'stop', 'study_level_id')->withtimestamps(); } the establishment_user (pivot) table has following columns: id | establishment_id | user_id | start | stop | study_level_id to list of establishments user use following in controller: $establishments = $user_repo->find($user_id) ->with(['establishments', 'establishments.usersubjects' => function ($query) use ($user) { $query->where('user_id', $user->id); }]) ->get(); my problem response gives me id of studylevel have inf

c# - Math.Round returning a rounded up for odd values but rounds down for even -

i trying found float using math round found following 0.5 --> 0 1.5 --> 2 2.5 --> 2 3.5 --> 4 and on. believe due floating point error, not quite sure how. how can around numbers round properly? from documentation ; the integer nearest a. if fractional component of halfway between 2 integers, 1 of , other odd, number returned. note method returns double instead of integral type. math.round method has overloads takes midpointrounding parameter can specify rounding value if midway between 2 numbers. awayfromzero when number halfway between 2 others, rounded toward nearest number away zero. toeven when number halfway between 2 others, rounded toward nearest number.

android - NullPointerException while changing textView text in an AlertDialog -

background: i want create customdialog specific layout , add content. its dialogfragment code: textview text; @override public void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); text = (textview)getview().findviewbyid(r.id.lorem); text.settext("test"); } @override public dialog oncreatedialog(bundle savedinstancestate){ alertdialog.builder builder = new alertdialog.builder(getactivity()); layoutinflater inflater = getactivity().getlayoutinflater(); builder.setview(inflater.inflate(r.layout.custom_dialog, null)); return builder.create(); } problem: the dialog worked, after started add the lines in "oncreate" got nullpointerexception error. hope can me. thanks @raghunandan answer + explanation , here working code: @override public dialog oncreatedialog(bundle savedinstancestate){ alertdialog.builder builder = new alertdialog.builder(getactivity()); layoutinflater inflater = getactivity(

phpexcel - PHP not detecting XLS file as zip -

i using library read xls files internally uses php's zip_open() function. when creating files locally , uploading test server works fine. however, when use xls files downloaded website (normal download via browser), not work, instead returning error 19 meaning file not seen zip file, incorrect. excel opens file without problems. if re-save file locally xlsx file , upload it, same error (in instance file opened php's ziparchive class). ideas reason be? checked files not read only, possibly unix permissions set not displayed in windows? (doubt this, error code indicates file accessed, not identified xls) using: apache under windows (wamp) php 5.4.12 it seems had misread line of code, zip check done determine if xls file incorrectly named xlsx file. problem xls file returns no sheets when parsing, need still. not know why saving xls file xlsx file (using excel) results in incorrect zip archive though, guessing related.

php - Laravel - Multiple language files at custom locations -

is there way have multiple language files same language? know work if have different packages, have own plugin system. there way load additional language files on runtime? if (inside app/start/global.php or prefer) lang::addnamespace('namespace', '/your/custom/location'); then should able to lang::get('namespace::filename.localekey');

android - Crash when trying to use DirectionalViewPager (by Jake Wharton) -

i looked through questions on stack overflow similar problem, haven't managed find solution, suites case. i need implement following structure: fragment being replaced fragment b. fragment b contains viewpager, switches fragments c1 , c2. works great if use viewpager support library, problem is, need viewpager use vertical swipe. purpose i'm using library jake wharton here https://stackoverflow.com/a/14268702/1220743 . some code: a being replaced b fragment fragment = new fragmentb(); string tag = this.getclass().getname(); fragmentmanager fm = getfragmentmanager(); fm.begintransaction().replace(r.id.container, fragment).addtobackstack(tag).commit(); b initializes directionalviewpager directionalviewpager viewpager = (directionalviewpager)v.findviewbyid(r.id.view_pager); fragmentmanager fm = getfragmentmanager(); viewpager.setadapter(new myviewpageradapter(fm)); this gives me crash when switches b, following crash stack: 08-18 16:47:02.320: e/androidruntime(