Posts

Showing posts from May, 2015

sql server 2008 - Execute mathematical expression and set the value to variable in SQL -

i have mathematical expression expression created 3 variable @val1,@val2 , @operator. should need execute query string , need set value of variable inside query string, how can set? i tried below declare @val1 varchar=100; declare @val2 varchar=300; declare @oper varchar(20)='>'; declare @query varchar(max); declare @flag int=0; set @query='if(convert(int,'+@val1+')'+@oper+'convert(int,'+@val2+') set @flag=1'; exec (@query); print @flag; note: using inside function. use parametrized query sp_executesql procedure: declare @val1 varchar(20)= '500'; declare @val2 varchar(20)= '300'; declare @oper varchar(20)= '>'; declare @query nvarchar(max); declare @flag int= 0; set @query = 'if ' + @val1 + @oper + @val2 + ' set @flag=1'; declare @paramdefs nvarchar(max) = n'@flag int output' exec sp_executesql @query, @paramdefs, @flag output print @flag; also corrected m...

java - Propagate user principal from REST to EJB layer -

i starting application uses rest api makes calls ejb layer on jboss wildfly (resteasy). the rest services inside war calls ejb layer. know how achieve basic or custom form of authenthication on rest resteasy interceptor checks headers etc. described here: http://howtodoinjava.com/2013/06/26/jax-rs-resteasy-basic-authentication-and-authorization-tutorial/ the problem - check on rest facade. inside ejb layer don't know user authenticated against rest service. to clear - when using rmi , remote ejb calls authentication, user name stored in session context: @stateless public class loginservice { @resource private sessioncontext sessioncontext; public string getcurrentuser() { principal principal = sessioncontext.getcallerprincipal(); return principal.getname(); //i need username rest auth //currently it's anonymous } } is there way propagate username in standard way? e.g. putting custom principal sessioncontext? you can use subject's doas...

php - Cookies is not setting -

i setting cookie not being set when var_dump() variable trying set in cookies shows string(4461) "[" string "]"; does mean size of string bigger capacity of cookie. my php code looks setookie('corredores',json_encode(array_unique($corredores))) ; so when print cookie return null. hash string , set coocies. or serialize array.

java - client cluster database synchronization with Hibernate -

Image
i have java multi client application uses database shared among clients through hibernate . know how can guarantee clients have up-to-date data database. even if didn't use sort of cache , clients loaded latest data database client store possibly out of date data in form of gui elements displayed or application status. and application without cache extremely unresponsive. what need cache kept date (through database change events trigger each client hit database) , gui being notified when changes happened in cache , update new data arrived database. i checked terracotta seemed needed managing cache coherence , clustering of clients far looks if terracotta manages distributed map, queue, multimap, executorservice doesn't in context of database instead makes possible share map distributed cache. has indication of how multi client application using hibernate database can guarantee data @ clients date database , each client notified when client changes database? ...

android - java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification - List with Universal Image Loader -

i trying update fragment list view once async call complete getting following error : java.lang.illegalstateexception: content of adapter has changed listview did not receive notification. i updating adapter onpostexecute , have checked function running on main thread still getting illegalstateexception. @override protected void onpostexecute(list<string> result) { if (null != mclient) mclient.close(); //todo //constants.images = result.toarray(new string[result.size()]); constants.images.addall(result); log.i("images", images.tostring()); if (mthelistener != null && firstcallflag ) { firstcallflag = false; mthelistener.gotonextscreen(); }else{ dataupdatelistener.dataupdated(result); } } @override protected list<string> doinbackground(void... params) { if(aftertag != null){ ...

sql - How to calculate the broadcast year and month out of the given date? -

is there way calculate the broadcast year , month given gregorian date? the advertising broadcast calendar differs regular calendar, in way every month needs start on monday , end on sunday , have 4 or 5 weeks. can read here: http://en.wikipedia.org/wiki/broadcast_calendar this pretty common thing in tv advertising, guess there standard mathematical formula it, uses combination of date functions (week(), month(), etc...). here example mapping between gregorian , broadcast dates: | gregorian_date | broadcast_month | broadcast_year | +----------------+-----------------+----------------+ | 2014-12-27 | 12 | 2014 | | 2014-12-28 | 12 | 2014 | | 2014-12-29 | 1 | 2015 | | 2014-12-30 | 1 | 2015 | | 2014-12-31 | 1 | 2015 | | 2015-01-01 | 1 | 2015 | | 2015-01-02 | 1 | 2015 | here example how...

convert str time to kml timeStamp in java -

i building kml file , there line of timestamp: <gx:timestamp> <when>2002-07-09t19:00:00-08:00</when> </gx:timestamp> i need convert time like: "1430477311" "2002-07-09t19:00:00-08:00" format how ? (java code) tnx lot you wanting convert timeformat xml date format (iso-8601) - long timestamp = 1430477311l; java.util.date yourdate = new java.util.date(timestamp*1000); //ms simpledateformat yyyymmddthhmmsssdf = new simpledateformat("yyyy-mm-dd't'hh:mm:ssx"); string date = yyyymmddthhmmsssdf.format(yourdate); simple date format reference .

c# - How to write an integration test in NUnit? -

we 2 students writing our bachelor thesis , have developed windows application, should able aid restaurant in various communication processes. fundamentally, should able present information order moment guest send it served. we have omitted test during development have decided write unit tests now. nevertheless, have found out suitable test can write our system integration tests because methods in our classes bound sql stored procedures via linq sql. aware of usage of stubs fake out dependency database, when our database implemented functions, figured give more value test several methods integration test. as seen in code below have tried follow guide lines unit test, right way write integration test? [test] public void sendtotalorder_sendallitemstoproducer_onesentorder() { //arrange order order = new order(); guest guest = new guest(1, order); producer producer = new producer("thomas", "guldborg", "beverage producer"); ...

ios - Unable to use images from document directory in JavaScript file -

i storing user specific images getting server in document directory . want display images on bing map @ pins(inside pin infobox). loading images dynamically using javascript. images not displaying on map. i setting images html content of infobox like, pininfobox.sethtmlcontent('<div class="arrow_box"><div class="content" id="content"><img id="localfile" src="file:///var/mobile/containers/data/application/395e5eed-2fb4-4505-861e-2da9ab96433b/documents/my_image.jpg/"/>'+pin.title+'</div></div>'); if use remote file , access via http protocol work, pininfobox.sethtmlcontent('<div class="arrow_box"><div class="content" id="content"><img id="localfile" src="http://a.abcd.com/static/images/zoom/magnifying-glass.png" />'+pin.title+'</div></div>'); i don't know why not taking image sav...

Javascript object persistency in Meteor js -

supposed created js object cart = function cart(){ this.contents = new array(); } cart.prototype = { add : function(obj){ this.contents.push(obj); } } and put in project lib folder object can used project-wide. is possible use object persistently in template backend (js file)? example, declared : template.pagea.rendered = function(){ var smallcart = new cart(); } can use in template event? example: template.pagea.events = { 'click button#add' : function(event){ smallcart.add('newitem'); //is object same 1 in rendered? } } i have been doing stuff using sessions when there lot of operations done, events cluttered business logics , calculations. want avoid this, thinking of putting logics javascript object functions. will approach work? object stay persistent? you can place code inside meteor.startup, object persist always. meteor.startup(function(){ cart = function cart(){ this.contents = new array(); ...

How to link a table from front end to back end in split database (MS Access 2010) -

Image
i have created split database in ms access 2010, in front end database have added table , want link end database. how can resolve issue? in end database, go external data > access (import , link group): in external data window, browse front end database file , open it: when come external data window, select "link data source..." , click ok: a link tables window appear, list tables available front end database linked to. select table(s) want link , click ok: the table(s) selected front end database should show in navigation left: ...note difference in icons in above screenshot (linked tables little blue arrow; local ones not).

angularjs - Character casing in angular js -

hello have following code section <select id="ddlsite" ng-model="area.siteid"><option >select</option> <option ng-repeat="item in sites" value="{{item.siteid}}">{{item.siteid}}-{{item.code}}</option> </select> here class sites have 2 property named : siteid , code when bind drop down code working fine , dropdown display value. but if change code below above code section: <select id="ddlsite" ng-model="area.siteid"> <option >select</option> <option ng-repeat="item in sites" value="{{item.siteid}}">{{item.siteid}}-{{item.code}}</option> </select> see here "i" in {{item.siteid}} small casing , drop down display blank value. what may issue {{item.code}} or {{item.code}} both working. please help....

java - Hazelcast ssl enterprise version -

am using trial version of hazelcast enterprise version testing, when documentation, shows properties props = new properties(); ... clientconfig config = new clientconfig(); config.getsocketoptions().setsocketfactory( new sslsocketfactory( props ) ); http://docs.hazelcast.org/docs/latest/manual/html/ssl.html where when try implement it, there no such method after getsocketoptions setsocketfactory, not sure how implement ssl in hazelcast 3.4.2 version, trial periods running out,,, not satisfied ssl feature of hazelcast. regards, harry harry, did have chance go through hazelcast ssl example https://github.com/hazelcast/hazelcast-code-samples/tree/master/network-configuration/ssl ? it uses basicsslcontextfactory implemented hazelcast.

Use Crate SQL module(plugin) in Elasticsearch -

i using elasticsearch on linux sever quering little bit difficult because form of query not sql structure. in crate, there sql plugin, put plugin own elasticsearch is possible? if not, how can adopt crate sql plugin elasticsearch? thanks jehyun: crate has evolved being elasticsearch plugin complete software stack. don't believe can add plugin elasticsearch gain sql-like queries. need transition cluster crate in order use sql queries. of course, should test process on non-production system first.

Marshall @Id to JSON while retaining Java 8 time formatting -

i'm trying map object json. works fine, want expose @id in json. i've found this answer on how that, in order use solution, have extend repositoryrestmvcconfiguration . when extend this, java 8 time formatting breaking. json follows: {"name":"erik",birthdate:"2015-01-01"} the birthdate field java 8 localdate. now, try expose @id , extending repositoryrestmvcconfiguration , setting configuration.exposeidsfor(myclass.class); . have id exposed, but, result of extending repositoryrestmvcconfiguration , localdate serialized as: "birthdate":{"year":2015,"month":"august","chronology":{"id":"iso","calendartype":"iso8601"},"dayofmonth":15,"dayofweek":"saturday","era":"ce","dayofyear":227,"leapyear":false,"monthvalue":8} so, question is: how can expose id of class while retai...

ios - exclude subview from UIPinchGestureRecognizer -

uiview *superview = [[uiview alloc] initwithframe:cgrectmake:(0, 0, 320, 480); uiview *subview = [[uiview alloc] initwithframe:cgrectmake:(0, 0, 320, 480); uipangesturerecognizer *recognizer = [[uipinchgesturerecognizer alloc] initwithtarget: self action: @selector(handlepinch); superview.userinteractionenabled = yes; subview.userinteractionenabled = yes; [superview addgesturerecognizer:recognizer]; i have subview overlapping on top of superview. subview has 4 buttons needs tappable. superview has pinch-zoom gesture zooms view. disable zoom on subview. recognizer fired inside subview well, there way exclude recognizer subview? i used simple way below: - (bool)gesturerecognizer:(uigesturerecognizer *)gesturerecognizer shouldreceivetouch:(uitouch *)touch { if (touch.view != subview) { // accept touchs on superview, not accept touchs on subviews return no; } return yes; }

powershell - Azure diagnostics extension ConflictError for empty Staging slot (Azure SDK 2.6) -

i deploying azure cloud service deployment empty staging slot new-azuredeployment in powershell along extension configuration diagnostics created via new-azureservicediagnosticsextensionconfig. when swap production , call: get-azureservicediagnosticsextension -servicename "my-service-name-here" -slot production the "id" property comes "myrole-paasdiagnostics-staging-ext-0". note still says "staging". now, if try new deployment staging error says: new-azuredeployment : conflicterror: extension id myrole-paasdiagnostics-staging-ext-0 in use deployment. this seems broken since there nothing deployed staging @ time. way can deploy new cloud service "staging" diagnostics extension if first delete diagnostics extension "production" remove-azureservicediagnosticsextension. is bug or thoughts on might doing wrong? didn't see option let me specify alternate id extension. update this feels bug me. if do: get-...

javascript - Connect two devices directly over wifi only with a web page -

is possible load web page on desktop/mobile device , load on device on same network, connect them directly ? i know webrtc can solution , i'm using it; since devices nearby, i'm looking more efficient. thinking because know in many wifi file transfer apps android (e.g. airdroid) 1 end needs load web page. any ideas? yes, connect them directly. need way identify want talk , exchange offer/answer pair; typically via external service, , traffic can on local lan (see https://sharedrop.io/ example). it's possible offer/answer exchange (with pain) via cut-and-paste between machines, etc well.

r - If Else Statements and Vector Length -

i'm trying perform correlations between vectors of unequal length, e.g., cor(x , y ) i want use largest possible number of observations each. moreover, i'd sample "randomly" each of vectors. in pseudocode: cor( sample(x, size = length(x or y, whichever smaller), replace = false ) , sample(y, size = length(x or y, whichever smaller), replace = false ) ) any ideas on how can this? pretty sure you're asking, question motivations of not using pairwise correlations: x <- 1:10 y <- 15:35 min.of.xy <- min(length(x), length(y)) cor(sample(x, min.of.xy, replace = false), sample(y, min.of.xy, replace = false))

How to send json object from controller to html template in node.js? -

hi new node.js please problem. this controller have search function called function server.js captured json object api. and want send object html page written code below. i.e, res.render('display',....) gives error.i.e undefined not function. please me how redirect html template json object controller in node.js? var storejsondata; exports.search = function(req,res){ var callback = function(error, data) { if (error) { // error handling here console.log(error); } else { // success handling here storejsondata = json.parse(data); res.render('display', { jsondata: storejsondata }); } i believe you're not setting express correctly template engine. assuming you're using express , jade passing values (or context) template follows; var express = require('express'); var app = express(); // assuming search controller in controllers/search var searchctrl = require('./contr...

android - Is it possible to feed MediaCodec Bytearray received by Server, and show them on SurfaceView -

everyone. how can if take frame frame stream video server, have pps , sps, , configure mediacodec parametrs, have width , height. i'll glad help.this example how id did it. mediacodec, decode byte packet server , render on surface

eclipse - How to fix error in android sdk - java.lang.StackOverflowError -

soon open eclipse, following error on popup: unknown exception in parsesdkcontent. java.lang.stackoverflowerror if close popup popup saying following: a stack overflow error has occurred. recommended exit workbench. subsequent errors may happen , may terminate workbench without warning. see .log file more details. so checked .log file , had following error: !entry com.android.ide.eclipse.adt 4 0 2015-05-13 22:56:25.701 !message unknown exception in parsesdkcontent. !stack 0 java.lang.stackoverflowerror @ com.android.ide.eclipse.adt.internal.sdk.projectstate.buildfulllibrarydependencies(projectstate.java:682) @ com.android.ide.eclipse.adt.internal.sdk.projectstate.buildfulllibrarydependencies(projectstate.java:691) @ com.android.ide.eclipse.adt.internal.sdk.projectstate.buildfulllibrarydependencies(projectstate.java:691) @ com.android.ide.eclipse.adt.internal.sdk.projectstate.buildfulllibrarydependencies(projectstate.java:691) @ com.android.ide.eclipse.adt.internal.sdk.pro...

mysql - SQL One to Many column association rows -

given table below want select rows same 'code' associated multiple 'sub_code'. +------+------------+-------------+ | div | code | sub_code | +------+------------+-------------+ | 11 | 1000 | 1212 | | 11 | 1000 | 1213 | | 11 | 1000 | 3434 | | 11 | 1000 | 1000 | | 11 | 1000 | 3000 | | 11 | 3000 | 1213 | | 11 | 2000 | 1212 | | 20 | 1500 | 5656 | | 20 | 1500 | 1213 | +------+------------+-------------+ for above table result should be +------+------------+-------------+ | div | code | sub_code | +------+------------+-------------+ | 11 | 1000 | 1212 | | 11 | 1000 | 1213 | | 11 | 1000 | 3434 | | 11 | 1000 | 1000 | | 11 | 1000 | 3000 | | 11 | 1500 | 5656 | | 11 | 1500 | 1213 | +------+------------+-------------...

python - pandas: concatenate dataframes, forward-fill and multiindex on column data -

i have 2 csv files same column names, different values. the first column index ( time ) , 1 of data columns unique identifier ( id ) the index ( time ) different each csv file. i have read data 2 dataframes using read_csv , giving me following: +-------+------+-------+ | id | size | price | +-------+-------+------+-------+ | time | | | | +-------+-------+------+-------+ | t0 | id1 | 10 | 110 | | t2 | id1 | 12 | 109 | | t6 | id1 | 20 | 108 | +-------+-------+------+-------+ +-------+------+-------+ | id | size | price | +-------+-------+------+-------+ | time | | | | +-------+-------+------+-------+ | t1 | id2 | 9 | 97 | | t3 | id2 | 15 | 94 | | t5 | id2 | 13 | 100 | +-------+-------+------+-------+ i create single large dataframe entries both, , use ffill forward fill values previous time-step. i able achieve using combination of concat , ...

ios - Custom Input view from Storyboard? - Swift -

a few months there question posted regarding custom input view , answered david berry the answer works i've been trying same work storyboard rather nib. what equivalent code load storyboard in place of nib? if let objects = nsbundle.mainbundle().loadnibnamed("inputview", owner: self, options: nil) { myinputview = objects[0] uiview }

jQuery UI Droppable with Bootstrap Navbar - How to drop a item inside Dropdown -

i using jquery ui droppable bootstrap menu navigation... i want drag element item "menu items" dropdown , drop inside "my apps" dropdown. dropped element should go inside " my apps > ul > li " hidden default untill click on apps link. ps: my apps <li> item everything working except dropping directly " my apps > li " element instead of " my apps > ul > li ". i have tried " $("#header-my-apps>li").appendto("#header-my-apps ul.h-droped-list"); " without luck :( pease me out. fiddle jquery /* menu items drag n drop create short cuts in favorites bar */ $(document).ready(function () { $('.rp-draggable li').not('li.pd-dropdown').each(function (i) { $(this).attr('uuid', +i); }); $("#header-my-apps>li").appendto("#header-my-apps ul.h-droped-list"); /* jquery droppable */ $(function (...

javascript - Is it possible to track subfolders using Google Analytics from one file? -

let's directory structure: root index.php -- folder 1 -> file.php -- folder 2 -> file.php |-- subfolder -> file.php -= folder 3 -> file.php and need put tracking code on index.php file, need single code track activity on every single folder child of folder index.php is. i need insert tracking code on index.php, or should else, using php require commend? edit: made it, here how i've put things work: insert google analytics in php (am doing right way?) ultimately, want analytics tracking code appear on every page of site wish track. once solution include tracking code in php file (say, analytics.php ), , require after opening <body> tag of pages.

javascript - Drag and copy with a swap function -

i have created user interface has working drag , copy in javascript. problem div getting copied has hidden div need swap once reach dropzone. upon dragging visible div gets new id hidden 1 doesn't , when swap them swaps hidden div in it's original position. here javascript code: these work drag , copy functions. function allowdrop(ev) { /* default handling not allow dropping elements. */ /* here allow preventing default behaviour. */ ev.preventdefault(); } function drag(ev) { /* here specified should dragged. */ /* data dropped @ place mouse button released */ /* here, want drag element itself, set it's id. */ ev.datatransfer.setdata("text/html", ev.target.id); } function drop(ev) { ev.preventdefault(); var data=ev.datatransfer.getdata("text/html"); /* if use dom manipulation functions, default behaviour not copy alter , move elements. appending ".clonen...

android - Get Non-Transparent Area of Drawable -

Image
i wonder there way know non-transparent area of drawable image? example, have image: what want detect when people touch transparent area nothing , when people touch non-transparent area (which start button) something. thanks help. just check pixel value of touch position, if transparent nothing. how color @ spot(or pixel) of image on touch event in android check if pixel transparent or not - android

PHP $_GET['string'+$var] - Is this possible? -

php code far. echo $sender = isset($_get['s']) ? $_get['s'] : "null"; echo $receiver = isset($_get['r']) ? $_get['r'] : "null"; echo $timestamp = isset($_get['t']) ? $_get['t'] : "0"; echo "<br/>"; echo $stotalitems = isset($_get['si']) ? intval($_get['si']) : 0; echo $rtotalitems = isset($_get['ri']) ? intval($_get['ri']) : 0; echo "<br/>"; ($i = 0; $i < $stotalitems; $i++) { echo $input = isset($_get['si'+$i]) ? urldecode($_get['si'+$i]) : "null"; if ($input == "null") continue; $input = explode(":", $input); var_dump($input); } what i'm trying dynamically grab variable. i'm sending multiple requests, , contain same data, small differences. - question simple though. doesn't work i'm thinkin should in mind. $_get['si'+$i]; in mind, sh...

r - Changing df and col in a Function -

i having trouble creating function allow me to, on fly, change data frame (df) , column (col). each column has 2 possible entries, e.g., left or right. conceptually @ least, i'm trying do: myfun = function(df, col){ mean( df$rt[ df$col == levels(df$col)[1] ] ) - mean( df$rt[ df$col == levels(df$col)[2] ] ) so enter like: myfun( df = m, col = turn_direction ) any appreciated.

android - ConnectSDK - Cannot add a configuration with name 'testCompile' as a configuration with that name already exists -

i'm trying download connnectsdk-lite android , when sync gradle come error: error:(18, 0) cannot add configuration name 'testcompile' configuration name exists. i've done digging , problem seems unit test framework roboelectric connectsdk uses. cannot add configuration name 'testcompile' configuration name exists i checked out post , tried messing around connectsdk's build.gradle see if fix anything, haven't had success. hoping guys might able point me in right direction.

javascript - Angular + Selenium: Cannot get value from input field -

i have written tests in protractor , i've used expect statement: loginpage.email.sendkeys( params.login.email ); expect(loginpage.email.gettext()).toequal( params.login.email ); however, test failing because signuppage.email.gettext() returning empty string. couldn't find function call in selenium's documentation input field return correct value? in protractor.conf file: params: { login: { email: 'user@email.com', password: 'blahblah123' } error in terminal: expected '' equal 'user@email.com'. so i'm trying match input of email field same email address i've sent through. suggestions how in selenium? if input field, need value of value attribute : expect(loginpage.email.getattribute("value")).toequal(params.login.email); similarly, apply saifur's idea here, if need wait element contain desired value, use texttobepresentinelementvalue expected condition : ...

insertion sort - Agda Programming- Proving Insertionsort makes 3 or less comparisons on a list of size 3 -

good evening fellows, i attempting prove insertionsort perform <= 3 comparisons in list of size 3 while sorting. last part of project , cannot make headway on it. after spending fair amount of time pursuing incorrect approach, instructor informed me may accomplished writing helper function assist. unfortunately have not come piece of code help. if can offer advice or assistance, , appreciated. code follows. thanks! insert : ℕ → 𝕃 ℕ → 𝕃 ℕ × ℕ insert x (h :: t) = if h < x (x :: h :: t , 1) else let r = insert x t in h :: (fst r) , 1 + snd r insert x [] = x :: [] , 0 insertionsort : 𝕃 ℕ → 𝕃 ℕ × ℕ insertionsort [] = [] , 0 insertionsort (h :: t) insertionsort t insertionsort (h :: t) | t' , c1 insert h t' insertionsort (h :: t) | t' , c1 | r , c2 = r , c1 + c2 examplethm : ∀(x y z c : ℕ)(r : 𝕃 ℕ) → insertionsort (x :: y :: z :: []) ≡ r , c → c ≤ 3 ≡ tt exa...

javascript - Trouble with changing the text of an element based off of a text form .val() -

my app dynamically creates , deleted new elements based on + / - buttons. inside dynamically created elements text forms. want whatever user types text form displayed in dynamically created element. $('.lname').keyup(function(event) { var crazy = {}; for (var x = 1; x < i; x++) { crazy[x] = function() { $('#sidechange'+ x).keyup(function(event) { var value = $(this).val(); $('.sloan'+ x).text(value); }) } } for (var p = 1; p < i; p++) { crazy[p](); } }); for example, accomplished changing text in previous element including function in html onkeyup attribute, don't know how accurately target other elements. var changetitle = function() { var loantitle = $(this).val(); var code = $("input[type='text'][name='loanname']").keycode || $("input[type='text'][name='loanname']").which; var length = loantitle.length; console.log(length); ...

c++ - Unable to generate makefile for basic PETSc program -

i have basic program using petsc #include "petsc/petsc.h" #include "petsc/petscsys.h" #include "petsc/petscmat.h" int main(int argc, char *argv[]) { petscmpiint rank,size; petscinitialize(&argc,&argv,0,0); mpi_comm_size(petsc_comm_world,&size); mpi_comm_rank(petsc_comm_world,&rank); petscprintf(petsc_comm_world,"number of processors = %d, rank = %d\n",size,rank); petscsynchronizedprintf(petsc_comm_world,"synchronized rank = %d\n",rank); mpi_barrier(petsc_comm_world); petscfinalize(); return 0; } however, got undefined reference errors petsc_comm_world , petscinitialize , other junk, when tried compile using mpic++ i trying use build , cmake. attempt @ cmakelists cmake_minimum_required(version 2.8) project(checkmpi) set(cmake_module_path "${cmake_source_dir}/cmake-modules") set(petsc_arch linux-gnu) set(petsc_dir l${project_source_dir}/thir...

html5 - How to set an HTML radio button using a JavaScript array variable -

i have <label for="gender" class="housedata">male</label> <input type="radio" id="housegender" name="gender" class="housedata" value="male"/> <label for="gender" class="housedata">female</label> <input type="radio" id="housegender" name="gender" class="housedata" value="female"/> and document.getelementbyid("housegender").value = house[houseid] [7]; where house[houseid] [7]; either male or female. when above assignment, radio button gender unchanged. any ideas how fix appreciated! :-) the id attribute of element must unique. have more 1 element id of housegender . you need provide unique ids 2 elements (say, housegendermale , housegenderfemale ). check value want assign, pick right element, , set checked property true . example: document.getelementbyid("housegende...

java - Strange assignment, TextView to Bundle, after decompiling, why? -

i created simple application, counter app, upon pressing button increments integer 1 , updates textview. code can seen below: public class mainactivity extends activity { public static int count = 0; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); final textview textview = (textview) findviewbyid(r.id.count); textview.settext(integer.tostring(count)); final button button = (button) findviewbyid(r.id.button); button.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { count++; textview.settext(integer.tostring(count)); } }); } ... } after decompiling same app dex2jar , jd-gui received following code back: public class mainactivity extends activity { public static int count = 0; protected void oncreate...

In Eclipse, how do I load php files from outside of WebContent folder to outside of context root? -

Image
i have following php files in include folder outside of webcontent folder of dynamic web project: but when deploying website project apache tomcat 8 server instance, server deploys files in webcontent folder context root "/". is there sort of server configuration automatically map , deploy files include folder oustide webcontent folder folder outside of context root (so there include folder in following picture)?

postgresql - pg_dump from remote server to localhost -

hi can me dump postgresql database on remote aws server postgresql database on local machine. i've been trying using answer in this stack post keeps failing. the command i'm using pg_dump -c -h ssh ubuntu@ec2-59-16-143-85.eu-west-1.compute.amazonaws.com -u dev_user paycloud_dev | psql -h localhost -u dev_user paycloud_dev but keep getting error pg_dump: many command-line arguments (first "paycloud_dev") can't figure out i'm doing wrong just add, dev_user role i've set in postgresql on both local machine , remote server. paycloud_dev name of database on both (owner dev_user ) edit 1 tried command below per post has since been deleted reason pg_dump -c -h ec2-59-16-143-85.eu-west-1.compute.amazonaws.com -u dev_user paycloud_dev | psql -h localhost -u dev_user paycloud_dev this giving me error pg_dump: [archiver (db)] connection database "paycloud_dev" failed: not connect server: connection refused server running ...

sql - How To get the Check Rule Constraint -

how can expression of check constraint ? with mssms can easly see table person has check constraint named ck_person validating expression ([dateofbirth]<[dateofdeath]) . with query can column_name , constraint_name , constraint_type : select ccu.column_name, ccu.constraint_name, tc.constraint_type information_schema.table_constraints tc inner join information_schema.constraint_column_usage ccu on tc.constraint_name = ccu.constraint_name tc.table_name = 'person' resulting +-------------+-----------------+-----------------+ | column_name | constraint_name | constraint_type | +-------------+-----------------+-----------------+ | personid | pk_person | primary key | | dateofbirth | ck_person | check | | dateofdeath | ck_person | check | +-------------+-----------------+-----------------+ but how can actual expression itself? try this... select definition check_expression ,name co...

waterline - Sails.js populate with where -

i need select users dogs (pets type equal 'dog') var user = waterline.collection.extend({ identity: 'user', attributes: { firstname: 'string', lastname: 'string', pets: { collection: 'pet', via: 'owner' } } }); var pet = waterline.collection.extend({ identity: 'pet', attributes: { type: 'string', name: 'string', owner: { model: 'user' } } }); i didn't find examples, tried this user.find().populate('pets', {type: 'dog'}).exec(err, users) ... and this user.find().where({'pets.type': 'dog'}).populate('pets').exec(err, users) ... but not work would greate if result users array has no pets records did try this? user.find().populate('pets', { where: { type: 'dog' } }).exec(err, users)...

sql - Trying to rank by group on a query -

i have query in trying group position , rank final value. select qryprospects.[prospect name] , qryprospects.position , qryprospects.height , qryprospects.weight , qryprospects.college , qryprospects.roundid , round([avgofaggregate],2) [true value] , round([avgofaggregate]*[multiplier]*[needmultiplier],2) [final value] , qryprospects.prospectid qryprospects inner join qrycalculations on qryprospects.prospectid = qrycalculations.prospectid; so results rank qb's 1 being highest, rbs same, of wr's, etc.... any appreciation! use derived table. try this select [prospect name] , position , height , weight , college , roundid , [true value] , [final value] , prospectid (select qryprospects.[prospect name] , qryprospects.position , qryprospects.height , qryprospects.weight , qrypro...

ios - How to get pending view controller from method? -

how can pending view controller value method? -(void)pageviewcontroller:(uipageviewcontroller *)pageviewcontroller willtransitiontoviewcontrollers:(nsarray *)pendingviewcontrollers { } what code can use pending view controller value array? appreciated? i have tried using code: nextindex = (int)[pendingviewcontrollers objectatindex:0]; but keeps returning -1 instead of next or previous value! the method passes in array of pending view controllers, not index, can't cast int. if want first view controller, can this, uiviewcontroller *vc = pendingviewcontroller.firstobject;

c# - Task.Run with Parameter(s)? -

i'm working on multi-tasking network project , i'm new on threading.tasks . implemented simple task.factory.startnew() , wonder how can task.run() ? here basic code: task.factory.startnew(new action<object>( (x) => { // 'x' }), rawdata); i looked system.threading.tasks.task in object browser , couldn't find action<t> parameter. there action takes void parameter , no type . there 2 things similiar: static task run(action action) , static task run(func<task> function) can't post parameter(s) both. yes, know can create simple extension method my main question can write on single line task.run() ? private void runasync() { string param = "hi"; task.run(() => methodwithparameter(param)); } private void methodwithparameter(string param) { //do stuff } edit due popular demand must note task launched run in parallel calling thread. assuming default taskscheduler use .net threadpool...

bash - What is the python 'requests' api equivalent to my shell scripts curl command? -

i have curl command use shell script: curl -x post -h 'content-type: application/json' \ --cert /etc/puppetlabs/puppet/ssl/certs/${pefqdn}.pem \ --key /etc/puppetlabs/puppet/ssl/private_keys/${pefqdn}.pem \ --cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem \ --data "{ \"name\": \"$group\", \"parent\": \"00000000-0000-4000-8000-000000000000\", \"environment\": \"production\", \"classes\": { \"$class\": {}} }" \ https://${pefqdn}:4433/classifier-api/v1/groups | python -m json.tool i want away shell script need able process complex json comes rest api. figure i'd use python , requests package. looking @ documentation: http://docs.python-requests.org/en/latest/user/quickstart/ but not see can specify certificate info. in shell script can pass curl these options: --cert , --key , --cacert . not know how accomplish same python's requests api. out know how can accomplish ...

vscode - Visual Studio Code Plugins (Format / Spell Check) -

Image
using new "visual studio code" code editor vs 1. not full visual studio ide atom.io based code editor. install plugins spell check , formatting code. how can ? ive followed instructions here : is there command formatting html in atom.io editor? realized not have install plugin command. it's been few months since question asked (and answered), thankfully, things have changed! vscode support extensions! here's relevant excerpt above blog post: extension marketplace/gallery to complement extensibility mechanism, have launched in product gallery , web based extension marketplace. these allow discover , install extensions. open in vscode, hit f1 , select extensions: install extensions . alternatively, can browse extension marketplace @ https://marketplace.visualstudio.com/#vscode . i gave marketplace quick search , found multiple extensions spelling , source formatting, i'll forego making specific recommendations since ever...

google maps api 3 - Formula to match Street Address based on slightly different Lat/Lng values -

Image
is there proven formula match different lat/lng values street address without submitting both of them geocoding service (since we've done , don't want make second api call). eg. following coordinates same street address (55 church street zip code 07505), 1 set points building , other street. lat : 40.9170109 long: -74.1702248 lat: 40.9171216 long: -74.1704997 so there commonly used formula can use, perhaps effect of , match first 4 decimal places or subtract 2 lat values , 2 long values , if difference less x , same street address. these ideas based on definitions of lat/long, looking proven, perhaps industry standard formula if exists. for measuring distances in close proximity pythagoras or variation of adequate. may have heard of haversine formula overkill close proximities. for locations near equator pythagoras adequate move away equator becomes less accurate due convergence of meridians(longitude) approach poles. compensat...

html - Scrollable container with columns and overflow-y: auto -

i want make scrollable container content laid out in columns. finding cannot use property column-count overflow-y: auto , fixed size on same element. content overflows horizontally, making more columns have specified in column-count . html: <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> </ul> <ul class="with-columns"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> </ul> css: li { list-style-type: none; padding: 5px; background: coral; margin: 2px; width: 80%; display: inline-block; height: 60px; } li:nth-child(2n+3) { height: 90px; /* simulate variable height content items */ } ul { background: lightblue;...

javascript - Show thank you message after form is submitted after PHP validation -

i have looked @ few solutions on here trying different ways of doing none working me. here form: <form action="<?php echo htmlspecialchars($_server['php_self']); ?>" method="post" name="contact" role="form"> <?php //if error has occured echo error in red if(isset($errormsg) && $errormsg) { echo "<p style=\"color: red;\">*",htmlspecialchars($errormsg),"</p>\n\n"; } ?> <label for="name"><b>name:</b></label> <input type="text" name="name" id="name" placeholder="enter full name" value="<?php if(isset($_post['name'])) echo htmlspecialchars($_post['name']); ?>"> <label for="email"><b>email:</b></label> <input type="text" name="email" id="email" placeholder="enter valid email add...