Posts

Showing posts from August, 2012

python - Collision not working for pygame Sprites -

i'm trying make spaceship game python programming class, , want use sprite.spritecollideany check if player sprite spaceship colliding of asteroid sprites in spritegroup group, no matter do, doesn't seem work. here's code: import pygame import random pygame.init() screen = pygame.display.set_mode((600, 600)) pygame.display.set_caption("asteroids , spaceships") background = pygame.image.load("background.png") background = background.convert() white = 255,255,255 #first make asteroids class. class asteroids(pygame.sprite.sprite): def __init__(self, x, y): pygame.sprite.sprite.__init__(self) self.x = x self.y = y self.width = 30 self.height = 30 self.i1 = pygame.image.load("smallasteroid.png") self.i1 = self.i1.convert() self.i1.set_colorkey(white) self.rect = self.i1.get_rect() self.rect.left = x self.rect.top = y self.i2 = pygame.i

c++ - c++11 get string length in compile time by constexpr -

#include <stdio.h> constexpr size_t constlength(const char* str) { return (*str == 0) ? 0 : constlength(str + 1) + 1; } int _tmain(int argc, _tchar* argv[]) { const char* p = "1234567"; size_t = constlength(p); printf(p); printf("%d", i); return 0; } hi,all want length of string in compile-time.so wrote code above.but in disassembly code found 'constlength' function named sub_401000 below lead run-time overhead computting length of string.is there wrong?(visual studio 2015 preview,release maximize speed (/o2) optimization) int __cdecl sub_401010() { int v0; // esi@1 v0 = sub_401000("234567") + 1; sub_401040(&unk_402130); sub_401040("%d"); return 0; } int __thiscall sub_401000(void *this) { int result; // eax@2 if ( *(_byte *)this ) result = sub_401000((char *)this + 1) + 1; else result = 0; return result; } a constexpr function can evaluat

ruby - How do I set up my rubygems environment correctly? -

i have following error when try run shotgun (this more gem environment specific gem): /system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': not find 'shotgun' (>= 0) among 12 total gem(s) (gem::loaderror) /system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec' /system/library/frameworks/ruby.framework/versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem' /usr/local/bin/shotgun:22:in `<main>' in other words, think looking in wrong area (i don't try run on mac osx's ruby.framework. i had tried remove thought symlink rm -rf ~ , deleted bunch of things. i have following rubygems environment, , want have own, separate ruby gem installation directory, not dependent on framework or library. how do that? however, when @ both ruby executable , installation directory, both in library. rubygems

Integrating Fortran code in Julia -

i using gnu gfortran compiler (on cygwin) own module. example start compilation stage, address mangled names , call subroutine julia via ccall . examples i've seen skip first 2 stages. so imagine have following module in fortran 90 file named 'f90tojl.f90': module m contains integer function five() 5 = 5 end function 5 end module m this example here . compile gfortran follows create shared library: gfortran -shared -o2 f90tojl.f90 -o -fpic f90tojl.so and my, admittedly shaky, understanding reading julia docs suggest should able call function 5 so: ccall( (:__m_mod_five, "f90tojl"), int, () ) it didn't work me. 'error compiling anonymous: not load module f90tojl... . cares enlighten me? got sneaky sense i'm doing silly.... in official doc , emphasis on c. i'm aware of this c++. in r , python, momentum -- have cython , rcpp in mind -- seems c/c++. similar question , want sense of how easy interface julia fortran vs

ios - UITableViewCell in nib or storyboard -

hi what's difference of using nib or storyboard on custom uitableviewcell? i'm planning create facebook news feed using custom uitableviewcell dynamic height.what's more flexible use? edit: why did down-vote question? don't see problem on post. with nib can design custom cell once use in number of classes, have attach outlets nib; while storyboard, each screen have make custom cell , attach outlets. if cell required 1 screen , may go storyboard else use nib. both ways can have custom height

android - How to access gmail attachment from my application? -

i have seen questions related question, not getting getcontentresolver().query(); method ; how related gmail?,how file gmail application without download file it's not possible directly we have use external api gmail api in java , integrate gmail api our android application here link gmail api https://developers.google.com/gmail/api/

login - Requests s.get(url,verify = False) error [Python] -

i'm attempting write program grabs data password protected gradebook , analyzes me because university's gradebook doesn't automatically calculate averages. i'm running issues @ beginning of program , it's growing more , more frustrating. i'm running on python 2.7.9. this code. import logging import requests import re url = "https://learn.ou.edu/d2l/m/login" s = requests.session() r = s.get(url,verify = false) this error occurring. traceback (most recent call last): file "/users/jackson/desktop/untitled folder/grade calculator.py", line 7, in <module> r = s.get(url,verify = false) file "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 473, in return self.request('get', url, **kwargs) file "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 461, in request resp = self.send(prep, **send_kwargs) file "/usr/local/lib/python2.7/site-packages/re

c# - Run notepad.exe from a html-button using Awesomium -

i've been looking example on how open process notepad.exe html-element using wpf , awesomium 1.7.5. idea clicking html element triggers c# method using javascript far understand awesomium api. however, examples can find refer earlier version uses obsolete functions... can please provide me example on how execute c#-code when opennotepad() triggered? html: <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title></title> </head> <body> <button onclick="app.opennotepad()">this button open notepad</button> </body> </html> c#: public partial class mainwindow : window { public mainwindow() { initializecomponent(); webcontrol.source = new uri("index.html"); } private void webcontrol_documentready(object sender, documentreadyeventargs e) { bindmethods(webcontrol)

java - DOM with mulitple namespaces -

how go create xml in java dom looks this: <soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> <soapenv:header> <ns2:auditheader xmlns:ns2="http://schemas.rnab.nl/giraal/auditheader/1.0"> <messageid>2014101314101012294900000</messageid> <relatesto>pway://rnab/distributie/createcredittransferreply/01</relatesto> <to>mq://rnab/giraal/om</to> <action>mq://rnab/giraal/om/createcredittransfer/01</action> <from>pway://rnab/distributie</from> </ns2:auditheader> </soapenv:header> </soapenv:envelope>

java - Any Alternative to get class Loader from of calling class {Reflection.getCallerClass(2).getClassLoader()} -

i need class loader calling class of current method in java8 . since reflection.getcallerclass() has been removed , can suggest other way classloader of calling class? thanks yes correct, reflection.getcallerclass() has been removed java 8 version. refer this more info.

showModalDialog arguments does not pass in WPF WebBrowser control -

where url called via showmodaldialog , in ie work in webbowser-control page appears, apparently not receive arguments. here demonstration of problem, first page is: parent.html: , second page newform.html . in ie, second page works well: mydiv contains input. while in webbowser-control mydiv contains "type undefined". parent.html: , <!doctype html> <html> <head> <title>parentpage</title> </head> <body> <p >type text:</p> <input id="myinput"/> <button onclick="callprintnewform()">showmodaldialog</button> </body> <script language="javascript" type="text/javascript"> function callprintnewform() { var x = document.getelementbyid("myinput").value; alert(x); var wnd; wnd = window.showmodaldialog('newform.html', window, "dialogwidth:800px;dialogheight:600px;help:no;resizabl

javascript - BXSlider Pause Youtube Video When Switching Slides -

i have following example of bxslider, have 4 slides each having youtube video. problem when play video , go next slide, keeps on playing: http://jsfiddle.net/isherwood/xwl9y/ $(document).ready(function () { $('.bxslider').bxslider(); }); can out make youtube video pause when going next slide? var slider = $("#gallery").bxslider({ adaptiveheight:true, auto:true, autostart:true, autocontrols:true, video:true, onslideafter: function(slide){ if (slide.find("iframe:first").length) { slider.stopauto(); } } }); you might able use slide.find("div.fluid-width-video-wrapper:first") if use iframes other things in in slider. source ----update---- var slider = $('.bxslider').bxslider({ onslideafter: function(slide, oldindex, currentslide){ oldslide = $( '.bxslider > li:nth

how can image be downloaded to storage from server? -

how can image can downloaded server mobile's storage in code name one? imagedownloadservice.createimagetostorage(imageurl, null, "image.png") creates image on storage blank , not opening. if want download use util.downloadtostorage() otherwise recommend urlimage rather imagedownloadservice .

matlab - Plotting Vector field of a point charge -

Image
i have been trying model electric field of point charge using quiver command. x=-5:0.5:5; y=-5:0.5:5; [xx,yy]=meshgrid(x,y); r=(xx.^2+yy.^2).^0.5; quiver(x,y,xx./r^3, yy./r^3,1); the resultant electric field follows, as can see length of vector increases move away charge (center). learned length of vector plotted quiver depends on magnitude of vector @ point. since electric field reduces move away, 1 expect length of vector should reduce away charge. tried understand or remedy not find anything. can explain why happening or how can fixed. thanks time. appreciated. quite simple fix actually. forgot 2 dots. x=-5:0.5:5; y=-5:0.5:5; [xx,yy]=meshgrid(x,y); r=(xx.^2+yy.^2).^0.5; quiver(x,y,xx./r.^3, yy./r.^3,1); %% <--- note additional . in front of ^

check in the collection,what id has no records in mongodb -

i have few ids in array var editions= ["aaa","bbb","ccc","ddd",......,"zzz"] i have collection called participants it has record called edition edition:"aaa" now want ids in editions array has no records in participants collection if want of happen on server can use aggregation framework , set features available, notably $setdifference operator mongodb 2.6 , greater: db.collection.aggregate([ { "$group": { "_id": null, "editionsfound": { "$addtoset": "$edition" } }}, { "$project": { "notfound": { "$setdifference": [ editions, "$editionsfound" ] } }} ]) or can on client performing difference between result , original via .distinct() method: array.prototype.diff = function(a) { return this.filter(funct

cocoa - Why I cannot get the right path with NSURL (swift) -

Image
it situation when use nsopenpanel and nsurl to open file path string coding swift. path should "/users/yy/downloads/chs16.fon" but got "p\xab\xe2w\xff\x7f" , , don't know why. p.s. top left hollow circle small bug too, have connected action button. nsopenpanel return nsurl, filehandleforreadingatpath need string, i've solve this function , works me : func nsurltostring (nsurlinit:nsurl) -> string { var nsurlproperty:nsurl = nsurlinit var urlstring:string = nsurlproperty.absolutestring! urlstring.removerange(urlstring.startindex..<advance(urlstring.startindex, +7)) return urlstring }

jsp - Can we give mouse listener to html table cell -

i developing 1 web based application using jsp,servlet in have reports when user clicks on row record should open. question can call listener on html table? or need follow way? you can use onclick on <td> , you'll : <td onclick="go()">test</td> maybe idea if add of code have, makes lot easier help

php - http/1.1 406 not acceptable on android app sendind data via json -

i have android app need update, send data via json , php mysql database. works ok old server, boss want data saved in our new server, , when in app try save in new server error: http/1.1 406 not acceptable think, seeing code, app can´t connect server, i´m new con android , don´t know how solve this... thanks!!! the resource identified request capable of generating response entities have content characteristics not acceptable according accept headers sent in request. unless head request, response should include entity containing list of available entity characteristics , location(s) user or user agent can choose 1 appropriate. entity format specified media type given in content-type header field. depending upon format , capabilities of user agent, selection of appropriate choice may performed automatically. however, specification not define standard such automatic selection. via http://www.w3.org/protocols/rfc2616/rfc2616-sec10.html

SVN, The timeout specified has expired while trying to commit large filles -

we facing strange issue our svn. commit works smaller files, when colleague try commit 3 mb pdf, or bit larger zip file sees timeout. "connecting" via eclipse our svn. here logs time got timeout. [mon dec 08 15:13:32.345525 2014] [dav:error] [pid 29316:tid 1136040256] (70007)the timeout specified has expired: [client 10.213.64.91:58474] timeout reading body (uri: /svn/com.company.dwh/!svn/txr/774-oq/databases/trunk/doc/hp/samreporting/configuration/company_sam_shr_configuration_and_operation_guide_006.pdf) [408, #0] [mon dec 08 15:14:38.013723 2014] [dav:error] [pid 29316:tid 1324857664] (70007)the timeout specified has expired: [client 10.213.64.91:58479] timeout reading body (uri: /svn/com.company.dwh/!svn/txr/774-or/databases/trunk/doc/hp/samreporting/configuration/company_sam_shr_configuration_and_operation_guide_006.pdf) [408, #0] [mon dec 08 15:16:53.640390 2014] [dav:error] [pid 29316:tid 1314367808] (70007)the timeout specified has expired: [client 10.2

c++ - Initializing fixed number of variables with an initializer list -

i want initialize object initializer list. problem is, initializer list able contain unpredictable number of elements, need initialize variables. user may send number of list elements, , need 4 of them. i wrote following code, looks long , inefficient me. there better way of doing this? pixel::pixel(std::initializer_list<uint8_t> channels) { switch (channels.size()) { case 0: r = 0; g = 0; b = 0; = 0; break; case 1: r = *(channels.begin() + 0); g = 0; b = 0; = 0; break; case 2: r = *(channels.begin() + 0); g = *(channels.begin() + 1); b = 0; = 0; break; case 3: r = *(channels.begin() + 0); g = *(channels.begin() + 1); b = *(channels.begin() + 2); = 0; break; default: r = *(chan

jquery - How to target dynamic generated id {{element}} inside angular Directive -

i have requirement have created directive below: app.directive('popover', function ($compile) { return { restrict: "a", link: function (scope, element, attrs) { // template var templateid = element.data('popover-template'); var templatehtml = $('#' + templateid).html(); // compile content , class var popover_content = $compile(templatehtml)(scope); var popover_class = element.data('popover-class'); and in html page have passed id angular expression below data-popover-template="{{field.popoverid}}" after running code getting error error: syntax error, unrecognized expression: {{field.popoverid}} . could me issue? the error self-explanatory: data-popover-template expects expression. try this: data-popover-template="field.popoverid" expression interpolation result {{}} not expression anymore, dir

url - Trouble with "Python Requests" username/password login -

i'm attempting write program grabs data password protected gradebook , analyzes me because university's gradebook doesn't automatically calculate averages. using "requests" in order log in website current code, nothing seems happening. i've tried different methods i've found here on stackoverflow have yet find working code. @ me? thanks. p.s. when manually log website, looks take me sort of "authorization" url short second, forwards me post login home page. from requests.adapters import httpadapter requests.packages.urllib3.poolmanager import poolmanager import ssl class myadapter(httpadapter): def init_poolmanager(self, connections, maxsize, block=false): self.poolmanager = poolmanager(num_pools=connections, maxsize=maxsize, block=block, ssl_version=ssl.protocol_tlsv1) import requests url = 'http://lea

javascript - jquery expand table not starting as hidden -

i trying make expandable table, many rows have button can press toggle child row each row. seems functioning want begin child row closed. how can this? $(document).ready(function() { $('.rowtoclick').click(function() { $(this).nextall('tr').each(function() { if ($(this).is('.rowtoclick')) { return false; } $(this).toggle(); }); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <table border=0> <tr class="rowtoclick"> <td><button>+</button></td> <td>hello</td> </tr> <tr><td class="additionalrow">data row 1 goes here...</td></tr> <tr><td class="additionalrow">data row 1 goes here...</td></tr> <tr><td class="additionalrow">data row 1 goes here...</td>

c# - DataGridView backcolor of the first row is white although the selection backcolor is transparent -

Image
i hide selection option of datagridview seems nothing has been selected. i have set selectionbackcolor property of datagridview transparent . when loads, first row's color white although turns transparent select other rows. @ beginning white. this how looks after loading: and how looks click on row: how can make looks second picture? just deselect first row after you've filled grid. default first row selected when fill it, possible have no rows @ selected. datatable dtb = new datatable("d"); dtb.columns.add("c1"); dtb.rows.add("a"); dtb.rows.add("b"); dtb.rows.add("c"); dtb.rows.add("d"); dtb.rows.add("e"); datagridview1.datasource = dtb; datagridview1.selectionmode = datagridviewselectionmode.fullrowselect; if (datagridview1.selectedrows.count > 0) { datagridview1.rows[0].selected = false; }

sql server 2008 - How do I join tables on multiple conditions -

Image
i have select data 2 tables using join both working individual not working together, when execute complete query not work when execute both joins individually example: select dbo.mail_messages.subject, dbo.mail_messages.body, dbo.mail_messages.date, dbo.mail_messages.messageid --dbo.mail_messages.parrentid dbo.mail_messages join dbo.mail_reply mr1 on mr1.messageid = dbo.mail_messages.messageid ==================================================== select dbo.mail_messages.subject, dbo.mail_messages.body, dbo.mail_messages.date, dbo.mail_messages.messageid dbo.mail_messages join dbo.mail_reply mr2 on mr2.parrentid = dbo.mail_messages.messageid above queries work fine. but when execute below query (combination of above queries) returns nothing. select dbo.mail_messages.subject, dbo.mail_messages.body, dbo.mail_messages.date, dbo.mail_messages.messageid --dbo.mail_messages.parrentid dbo.mail_messages join dbo.mail_reply mr1 on mr1.messageid = dbo.mail_messages.messageid j

c# - How to save dynamic image in WatIn -

this question has answer here: how bitmap of watin image element? 5 answers i trying save image changes dynamically each request. i tried watin , httpwebrequest (getting new image) httpwebrequest request = (httpwebrequest)webrequest.create("www.test.com"); request.allowautoredirect = false; webresponse response = request.getresponse(); using (stream stream = response.getresponsestream()) using (filestream fs = file.openwrite(imagecodepath)) { byte[] bytes = new byte[1024]; int count; while ((count = stream.read(bytes, 0, bytes.length)) != 0) { fs.write(bytes, 0, count); } } and (user32.dll) urldownloadtofile (getting new image) [dllimport("urlmon.dll", charset = charset.auto, setlasterror = true)] static extern int32 urldownloadtofile(int32 pcaller, string szurl, string szfilename, int32 dwreserved, int32 lp

ios Mantle - Overriding default initWithDictionary properly -

i facing following problem.. i have class menu.h , item.h. menu menu of restaurant , has multiple categories (like appetizers, salads, etc) , each menu has multiple items associated. menu.h has nsarray property called itemlist. trying automatically load these objects using mantle. menu.h @interface menu : mtlmodel <mtljsonserializing> @property (nonatomic) nsarray *itemlist; @end and menu.m @implementation menu + (nsdictionary *)jsonkeypathsbypropertykey { // model_property_name : json_field_name return @{ }; } + (nsvaluetransformer *)itemlistjsontransformer { return [nsvaluetransformer mtl_jsonarraytransformerwithmodelclass: item.class]; } - (instancetype)initwithdictionary:(nsdictionary *)dictionaryvalue error:(nserror **)error { self = [super initwithdictionary:dictionaryvalue error:error]; if (self == nil) return nil; return self; } and item.m - (instancetype)initwithdictionary:(nsdictionary *)dictionaryvalue error:(ns

windows phone 8 - Tree View or Heirarchical List in WP8 -

i want tree structured list in app wp8. there control item or toolkit item provided same, or require creation of new style? i want display list, in list items can have further list structures items. it's not recommended use treeview on wp8, default style of hierarchical navigation on wp8 clicking items , using button browse . if still want use treeview , there treeview control here .

PHP/MySQL - How to save results to another array? -

im stuck in code. don't know how save result stored in array array. can me ? thank much. php: $sql_curr = mysql_query("select * tr_prices tr_code = '$acode'"); while($row = mysql_fetch_assoc($sql_cur)){ if($row['price'] != ''){ // there should array results if not empty column } } $arr_curr = array( //there should results previous array 'example' => 'example' ); $sql_curr = mysql_query("select * tr_prices tr_code = '$acode'"); $newarr=array(); while($row = mysql_fetch_assoc($sql_cur)){ if($row['price'] != ''){ $new_arr[]=$row; } } );

prolog - Create predicates given the last n elements of a list -

example: ?-lastn([1,2,3,4],3,t). t = [2,3,4] this whay i'm write: lastn(l,n,r):- length(l,x), x1 x-n, lastt(l, n,r). lastt(l,0,l). lastt(x,[h|t],l):- x2 x-1, lastt(t,x2,l). i assume question 'predicate last n elements in list' , meant do. it's simple discarding of first element after counting how many elements have discarded, right? not deal improper input @ lastn(l,n,r):- length(l,x), x1 x-n, lastt(l,x1,r). lastt(l,0,l). lastt([h|t],x,l):- x2 x-1, lastt(t,x2,l).

Having to Change the Drive constantly in Batch script -

i have come across odd behaviour batch script haven't seen before. below have had script work. below piece of overall script shows issue. in short having switch drives in code. becomes issue when using blat.exe attachment on different drive. set datafile=test%date:~-7,2%%date:~-10,2%.csv :: echos correct name echo %datafile% :: wouldn't expect need 2 lines below d: cd %datapath% :: if file not present exit if not exist %datafile% ( echo no file exists exit ) what want able simplify things (what on other environments) set datafile=test%date:~-7,2%%date:~-10,2%.csv :: echos correct name echo %datafile% :: if file not present exit if not exist %datafile% ( echo no file exists exit ) hopefully makes sense. seems environment issue or similar, cant find obvious. thank help. edit solution: as mentioned in comment below, underlying issue sent me on complete wild goose chase , hence example provided made little no sense. problem comment inside of

c# - Adding Join to Existing LINQ Query -

i kindly helped this stack overflow question . now i'm building query , need add joins other tables bring in names , descriptions etc. my query this: using (var ctx = new myentities()) { var pc = ctx.tblpostcodes.where(z => z.postcode == postcodeoutward) .select(x => new {postcodeid = x.postcodeid}).single(); int pcid = pc.postcodeid; var q = ctx.tblprices.orderbydescending(x => x.cost) .where(c => c.postcodeid == pcid) .where(s => s.itemid < 18) .groupby(x => x.itemid) .select(g => new { g, count = g.count() }) .tolist() .selectmany(t => t.g.select(b => b).zip(enumerable.range(1, t.count), (j, i) => new { j.itemid, j.cost, j.supplierid })); foreach (var in q) { sb.appendformat("itemid = {0}, cost = {1}

c - How to wait for frame and alarm signal -

i have problem webcam. can hardware 1 i'm convinced no. apps can see stream freezes. because of following output used app when problem occurs: v4l: timeout (got sigalrm), hardware/driver problems? i have checked out code , interesting part: /* how many seconds wait before deciding it's driver problem. */ #define sync_timeout 3 int alarms; void sigalarm(int signal) { alarms++; } ................................................................................. void wait_for_frame_v4l1( input_t *vidin, int frameid ) { alarms = 0; alarm(sync_timeout); if (ioctl(vidin->fd, vidiocsync, vidin->buf + frameid) < 0 ) fprintf(stderr, "input: can't wait frame %d: %s\n", frameid, strerror(errno)); if (alarms) fprintf(stderr, "v4l: timeout (got sigalrm), hardware/driver problems?"); alarm(0); } from conclude sync_timeout problem. value 3 secondes seems quite enough. my request me chage code don't

bash - How to use grep command to print value of a variable in a line? -

for example,consider below line <workflowlink condition ="" fromtask ="start" totask ="cmd_start_run"/> from above line, need print start fromtask ="start" using grep command or using command. try doing : $ xmllint --xpath 'string(//workflowlink/@fromtask)' file start $ xmlstarlet sel -t -v 'string(//workflowlink/@fromtask)' file start $ saxon-lint --xpath 'string(//workflowlink/@fromtask)' file start xmllint libxml2 xmlstarlet saxon-lint

linux - environmental variable duplicating in all shells when exporting from a single user -

we have application 1 shell script file maintains environmental variables, set export. these variables used run external commands in application. so, have many users running same application single server own home directories. when user run application, executable in user b path running. set environmental variables each user executable supposed run user a's own path. how can make executable run user's own path? sample.sh export ha_inc=/home/a/proj export ha_exe=/home/a/proj/bin these above file cloned users when application cloned git. whenever user executing command, in ha_exe directory, executable running other users' directory. users using own shells. i think can have system-wide shell script in /etc/profile. to represent current user's home directory, use "~". represent b's home directory, use "~b".

loops - Python: Partial sum of a set in a matrix by columns -

i have 2 large matrices (1800l;1800c), epeq , triax, have columns like: epeq= 0 1 1 2 1 0 3 3 1 1 0 2 1 1 1 triax= -1 1 3 1 -2 -3 -1 1 2 3 2 1 -1 -3 -1 1 as can see, triax columns have cycles of positive , negative elements. want cumulative sum in epeq in beginning of each cycle in triax , value stay constant during cycle, this: epeq_cr= 0 1 1 1 1 1 1 11 11 11 11 11 11 11 11 17 and apply procedure columns of epeq matrix. have code miss. epeq_cr = np.copy(epeq) g in range(1,len(epeq_cr)): h in range(len(epeq_cr[g])): if (triax[g-1][h]<0 , triax[g][h]>0): epeq_cr[g][h] = np.cumsum()... i've run out of time @ i'd start figuring out cycles start in triax: epeq = np.array([1, 1, 2, 1, 0, 3, 3, 1, 1, 0, 2, 1, 1, 1]) triax = np.array([-1, 1, 3, 1, -2, -3, -1, 1, 2, 3, 2, 1, -1, -3, -1, 1]) t_shift = np.roll(triax, 1) t_shift[0] = 0 cycle_starts = np.argwhere((triax > 0) &

xaml - How to change background color of a column in grid -

i have used following code how use color first grid column. how use grid lines in windows phone 8.1 grid. <grid grid.column="0" grid.row="7" name="mgrid" margin="0,10,0,0" background="white"> <grid.rowdefinitions> <rowdefinition /> <rowdefinition /> <rowdefinition /> <rowdefinition /> <rowdefinition /> <rowdefinition /> </grid.rowdefinitions> <grid.columndefinitions > <columndefinition width="190" /> <columndefinition width="10" /> <columndefinition width="*" /> </grid.columndefinitions> </grid> after column definitions, can create rectangle sit inside first column definition. then, using rowspan property, make appear full column. for example: <rectangle background="red" grid.rowspan="

select - php curl send multiple data under one key -

how send data via curl under select tag? can't find answer, please help, browser's procedure follows: content-type:multipart/form-data; boundary=----webkitformboundaryebhinmjju3pgp1tb ------webkitformboundaryebhinmjju3pgp1tb content-disposition: form-data; name="allvolumecountries" 6 ------webkitformboundaryebhinmjju3pgp1tb content-disposition: form-data; name="allvolumecountries" 13 p.s: don't have access source, don't advise me change allvolumecountries[]

swift - Use Self as generic type -

self can used return type of method: func dosomething() -> self {} is somehow possible use self generic type this? func dosomething() -> wrapper<self> {} example it nice if subclass christmaspresent , let have wrapped function returns wrappedpresent generic set whatever subclass was. class christmaspresent { func wrapped() -> wrappedpresent<self> { return wrappedpresent(present: self) } } class wrappedpresent<t: christmaspresent> { var present: t init(present: t) { self.present = present } } class toycar: christmaspresent {} let wrappedtoycar = toycar().wrapped() // inferred be: wrappedpresent<toycar> the vexing paradox in swift this: "swift prefers methods, swift's functions more powerful." swift team knows that, , someday have powerful methods. today not day. there many things you'd express in methods cannot. want can done functions, however. class christmaspresen

repeater - XPages Managed Bean and Repeat Control issue: how to reload value? -

for xpage developed managed beans keep data. page contains repeat control, it's @ moment: <xp:panel styleclass="form"> <xp:this.datacontexts> <xp:datacontext value="#{javascript:pagedata.getform(compositedata.formname, compositedata.datasource);}" var="myformdata"> </xp:datacontext> <xp:datacontext var="myfields"> <xp:this.value><![cdata[#{javascript:return myformdata.getfieldsasjson();}]]></xp:this.value> </xp:datacontext> </xp:this.datacontexts> <xp:table style="width:100%" cellspacing="1" cellpadding="0"> <xp:repeat var="thisfield" rows="#{javascript:compositedata.rows}" disabletheme="true" repeatcontrols="true" disableoutputtag="true" value="#{myfields}"> the pagedata object bean, cont

jvm - Accessing an uninitialised static field in Java -

i'm indebted this answer idea. the following code compiles, shouldn't. uses value of x before it's been initialised. if remove staticassign. qualifier no longer compiles. public class staticassign { public static final int x; static { system.out.println(staticassign.x); x = 5; } public static void main(string[] args) {} } on machine, consistently prints 0 . if change type of x string , consistently prints null . the question is: print 0 or null , or might access uninitialised memory , print out else? and if code gets through compiler, why isn't picked jvm? is there way nasty things based on this? it has been initialized. variables in global scope initialized automatically. variables of object type initialized null primitive int initialized 0. variable declared not in global scope must initialized ie. declared in method. problem declaring final telling compiler must explicitly initialized. adding x=5

postgresql - Rails schema.rb does not include new custom Postgres function -

i have created new custom postgres function via usual migration. class createbestbowlingfigurefunction < activerecord::migration def change execute "create or replace function ......" end end after migration, new function not available in schema.rb. as per official doc, use command db:schema:load create schema before running tests. so, best practice create custom functions before running tests? schema.rb does not handle (see section 6.2 of rails 3.2.x guides , section 7.2 of rails 4 guides) views or custom functions. have view in our application , schema not work it. we use structure.sql instead sets our view and, sense same apply here custom functions. use structure.sql instead of schema.rb: this set in config/application.rb config.active_record.schema_format setting, may either :sql or :ruby. you can use combination of schema.rb (for regular tables & index) , structure.sql (for custom functions). setup combo test environme

NFC, is it possible to exchange strings or bytes between Android and Windows phone? -

i need create android app comunicates (send string or bytes) windows phone app, nfc. possible? how can without bluetooth? how connect (android , windows phone) arduino uno nfc shield ( http://www.adafruit.com/product/789 )? i want create apps in c# , java. thank you! here wiki explains api of adafruit nfc shield. in section, demo 2: ptopinitiator.pde , ptoptarget.ino , example shown , seems peer-to-peer communication available use. i have never touched windows phone don't know available but, here explanation using nfc (as peer-to-peer) on windows phone 8. the way use peer-to-peer communication on android asked / answered here .

ruby - Rails: most Quiz attributes passing to params, apart from user_id. Why? -

for testing/learning purposes, have quiz model following attributes (snippet schema.rb): create_table "quizzes", force: true |t| t.integer "user_id" t.string "answer1" t.string "answer2" t.string "answer3" t.string "answer4" t.string "answer5" t.string "answer6" t.string "answer7" t.string "answer8" t.datetime "created_at" t.datetime "updated_at" end add_index "quizzes", ["user_id"], name: "index_quizzes_on_user_id" a quiz sent 'new' view, this: def new @quiz = quiz.new(user_id: current_user.id) end when user completes quiz, quizzescontroller#create action triggered: def create @results = quiz.create(post_params) #from private method render :show end (whether renders 'show' view or default 'create' view, works - while i

Java overriding parent equals method -

i have 2 classes person , teacher . in person class check if 2 objects passed in equal using compareto method. in teacher class, problem i'm working on states need override equals method in person. in equals method, way return true if it's equal in both equals method in person , teacher . question is, when check in teacher 's equals method, call super.equals(other) in order check if 2 objects equal parent class or there else need do? person: public class person implements comparable<person> { public boolean equals(object other) { try { return this.compareto(other) == 0; }catch(exception e) { return false; } } } teacher public class teacher extends person { private string facultyid; @override public boolean equals(object other) { boolean personequals = super.equals(other); try { teacher teach1 = (teacher)other; boolean idequals = this.facul

html - how to remove the scroll and adjust the adaptability? -

please remove scroll appears when window's width 992px < width < 1006px (for convenience, brought in header width). here settings bootstrap: http://getbootstrap.com/customize/?id=fbddbcf1a87480d1bf27#media-queries-breakpoints   important me distance between .bg_blue_innerpo continued 66px, , width .page-header 992px. your issue lies in breakpoint medium (992) , small (768): @media (min-width: 992px) .container { width: 1006px; } @media (min-width: 768px) .container { width: 786px; } your container is, in essence, larger breakpoint (width of screen) causing scrollbar. is there reason why have changed default breakpoint structure?

php - Is it possible to pipe PowerShell output to a URL? -

anyone know if it's possible pipe output of powershell command url request? i able pipe output web server can parse out meaningful data , store or email on. the output small, i'm not worried finer details post limitations , character escaping, etc. it depends on want pipe , type of http request want do. invoke-webrequest supports following http requests : delete, get, head, merge, options, patch, post, put, , trace. one caveat parameter of invoke-webrequest support pipeline input -body . you can check online of invoke-webrequest more details : http://technet.microsoft.com/library/hh849901.aspx

html5 - Is there a security reason for not being able to query localstorage size -

per mdn seems there's no built in way query available size of local storage . there security reason this? if not why not implemented? simply put - not implemented yet. ie example has .remainingstorage . there an issue in chromium bug tracker on that's still open , there pull request ready wasn't yet merged. i doubt in browser people hate localstorage because of performance implications (because it's sync). it's not in spec suggests aribtrary 5mb limit. you can calculate by pushing bigger , bigger strings , seeing fails that's not particularly idea either.

Moving sum in SQL server 2008 R2 -

edit: server i'm working on 2008 r2 client 2012... i'm trying create conditionnal sum based on month i'm in backing 1 year ago. here data have: month location quantity1 quantity2 200501 2072 46 42 200502 2072 53 51 200503 2072 141 132 200504 2072 134 129 200505 2072 75 72 200506 2072 75 74 200507 2072 77 72 200508 2072 56 52 200509 2072 58 54 200510 2072 59 52 200511 2072 71 69 200512 2072 48 46 200601 2072 62 55 200602 2072 209 197 200603 2072 143 138 200604 2072 78 67 200605 2072 95 86 200606 2072 78 73 200607 2072 80 73 200608 2072 68 62 200609 2072 54 46 200610 2072 52 49 200611 2072

jquery - Retrieve java object from servlet with ajax and print it with JSTL -

when option box changed in jsp want ajax post-call testservlet. when servlet retrieved ajax servlet create new person object , send jsp page ajax call comes from. at moment can print object in div id uidrespon <div id="uidrespon"></div> , how can read object jstl out tag <c:out test="${object.name}"/> or <c:out test="${object.age}"/> ajax call jsp page servlet: <script> $(document).ready(function() { $("body").on('change', '#personbox', function() { //get selected value var selectedvalue = $(this).val(); $.ajax({ type : 'post', url : '${pagecontext.request.contextpath}/secure/testcontroller.do', data : { "ajaxcallback" : selectedvalue }, success : function(response) { $('#uidrespon').html(response); }, error : function(error) { alert(error); }

Interpreting git diff output -

this question has answer here: how read output git diff? 6 answers i been using git years never used diff command , started use today don't understand output... had file , removed line 3 , 4 , got following output can me understand lines of output means in dummy terms. thanks $ git diff diff --git a/readme.txt b/readme.txt index 15827f4..8115e72 100644 --- a/readme.txt +++ b/readme.txt @@ -1,4 +1,2 @@ file adding -line 3 - line 1: command used produce diff. line 2: git database information 2 files involved. line 3 , 4: --- means old file, +++ means new file. line 5: @@ means range of lines represented in next diff hunk . -1,4 means lines 1-4 old file, , +1,2 means lines 1-2 in new file. the remaining lines lines original files, prefixed either (a space), - or + . lines in both old , new, - in old , + in new. these meant mnemonic

sails.js - View Caching in SailsJS -

i've got highly trafficed website , i'm using sails specific conponent on page. information doesn't change often, maybe once per day. i'm wondering if there way view caching? ideally using key/store redis? you can run app behind proper webserver nginx or apache , set them cache.

asp.net mvc - Looping through model of RSS feeds in mvc razor -

i'm generating list of rss links in model want show on webpage. model works fine , display of links works fine on view. question this, i'd display links in 2 side side columns. first 5 links in first column , next 5 links in second column. right i'm showing 10 links in each column. i'm sure there easy way this, i'm not sure how. appreciated. here model: namespace oa.models { public class rss1 { public string link { get; set; } public string title { get; set; } public string description { get; set; } } public class rss1reader { private static string _blogurl = "http://www.test.com/blogs/news/feed/"; public static ienumerable<rss1> getrss1feed() { xdocument feedxml = xdocument.load(_blogurl); var feeds = feed in feedxml.descendants("item") select new rss1 { title = feed.element("title").value,

how to access body/exchange in camel route -

i trying log exchange or body in camel route as: <log message="body:${body}"/> this prints blank ie. "body : ". processors called in same route passing parameters as: <bean id="userbean" method="findsomeuser(${body.getuserid})"/> how log exchange/body camel route if 1 wants see contents of exchange ? the expression used correct body empty @ time. try removing setbody part route , same result. <route > <from uri="timer://foo?fixedrate=true&amp;period=5000"/> <setbody> <constant>message</constant> </setbody> <log message="body:${body}"/> </route>

sql server - limit all users to 1 session -

i have been required configure sql server allow 1 session per login. have found few references on creating login triggers in order prevent login establishing more 1 session, wondering if there way define @ lower level, session limit default, rather having define in login each user? i seeing lot of references topic in both "questions may have answer" , "similar questions" here on stackoverflow, far have either not found or not understood post describes trying do. have seen reference declarative management framework allows configure sql server policy think. i going keep on looking through articles here try learn this, in meantime... advice appreciated! the example logon trigger in books online pretty close think want, i've made few changes make work logins. -- trigger must created user 'view server state' permission in order trigger have unrestricted access sys.dm_exec_sessions. create trigger connection_limit_trigger on server execut