Posts

Showing posts from August, 2015

r - Using a 'complex' function within the apply family -

i attempting use aov() function within tapply() line, , not sure if not possible, or if i'm coding incorrectly. factors<-c("factor 1", "factor 2") years<-c("year 1", "year 2", "year 3","year 4", "year 5") width<-rnorm(100) height<-rnorm(100) mydata<-data.frame(years,factors,width,height) i see if there difference between factor levels each year. note real data has several factor levels, why i'm using anova , not t-test. i can tapply() 'simple' functions, sum : with(mydata,tapply(width,factors,fun="sum")) from simple examples, think way tapply() works subsets data 2nd entry, factors , takes first entry, width , , put's whatever function declared. reasoning, tried: with(mydata,tapply(width~factors,years,fun="aov")) this returns error arguments must have same length . if possible use tapply function requires complex input, how go doing this...

PowerShell - Get-GhildItem - Ignore specific directory -

i working script clear old files off our file server. using line in script find files older date: $oldfiles = get-childitem $oldpath -recurse | where-object { $_.lastwritetime -le $olddate } my question is, how ignore directory in $oldpath? instance, if had following: root dir1 dir 2 subdir 1 subdir 2 dir 3 subdir 1 dir 4 and want ignore dir 2 , subdirectories when building list final working script: $oldpath = "\\server\share" $newdrive = "i:" $olddate = get-date -date 1/1/2012 $oldfiles = get-childitem $oldpath -recurse -file | where-object {($_.psparentpath -notmatch '\\ignore directory') -and $_.lastwritetime -le $olddate } $olddirs = get-childitem $oldpath -recurse | where-object {$_.psiscontainer -and ($_.psparentpath -notmatch '\\ignore directory')} | select-object fullname $olddirs = $olddirs | select -unique foreach ($olddir in $olddirs) { $strdir = $newdrive + "\" + ($olddir | split-path -noqual...

Lua integer won't increment -

i have simple lua function designed solve problem of consecutive prime sum. prime 41, can written sum of 6 consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 this longest sum of consecutive primes adds prime below one-hundred. function: function numofconsecprimes(limit) = allprimes(limit/2) length = table.getn(a) sumsofar = 0 innersum = 0 finalsum = 0 pos = 1 items = 0 inneritems = 0 finalitems = 0 resetpos = pos while resetpos < length pos = resetpos resetpos = resetpos + 1 items = 0 sumsofar = 0 while sumsofar < limit , pos < length if isprime(sumsofar) == true innersum = sumsofar inneritems = items end print(sumsofar) sumsofar = sumsofar + a[pos] print(a[pos] .."->"..sumsofar) pos = pos + 1 items = items + 1 end if inneritems > finalitems finalitems = inneritems finalsum = innersum end end...

Scheduling tasks after polling the database php -

i building web app in php used schedule tasks in future. in background supposed poll database every 2 min see if there upcoming task. how implement polling. javascript solution not helpful user can on of pages on webapp, system should keep pooling db. cron 1 way still have poll database create cron job. best way implement it? thanks create cron job executed once every x minutes , make job check db. if there new upcoming task, make job launch it.

html - Restart entire SVG animateTransform sequence? -

i have svg graphic animating via animatetransform . animates in, stays on screen until click it, scales down 0 , cannot brought back. want restart entire animation sequence on 2 seconds after last animation has ended (scaled 0), animate in. how can this? thanks! <!-- keep scaled @ 0 on load --> <animatetransform attributename="transform" attributetype="xml" type="scale" from="0" to="0" dur="0.5s"/> <!-- scale after 0.5 seconds --> <animatetransform attributename="transform" attributetype="xml" type="scale" from="0" to="1" begin="0.5s" dur="0.3s" fill="freeze" additive="sum"/> <!-- scale down on click --> <animatetransform id="animatfinished" attributename="transform" attributetype="xml" ...

PHP and C#.NET MVC ( repository pattern in PHP, how might i go about it ) -

i love unity , ninject framework dependency injection c#.net controllers repository interfaces etc, trying think alternative in php , struggling. i have: class user { //.. } interface iuserrepository { public function repository(); // can't work variable, should abstract? } class userrepository implements iuserrepository { public function repository() { $users = // dao gets users , returns them.. // how iuserrepository me @ all? if had ninject or // unity creating new link between userrepo , iuserrepo? return $users; } public function getallusers() { // errr.. i'm confused } } // has if admincontroller called, // inject construct, new iuserrepository class admincontroller extends controller { private $repository; public function __construct( $repository ) { $this->repository = $repository; } public function actionresult_listusers() { $users = $repos...

asp.net - Passing Error from HttpModule to MVC Application -

i have custom httpmodule authentication. in authenticaterequest event handler of module check if custom sso ticket available , in case perform authentication logic. if sso ticket available, incorrect, show friendly error message user. prefer able somehow set http status 401 (unauthorized, used when authentication fails) , pass on meaningful error message http module. i mvc application somehow information , use render custom 401 error page includes meaningful error message module. what's best way raise error in http module , what's best way have display error using mvc application (to error message in mvc application's layout)? you create custom controllerfactory, , in your: protected override icontroller getcontrollerinstance(requestcontext context, type controllertype) you have access httpcontext , routedata through context object. if user not authenticated can manipulate routedata targed desired controller/action desired routeconstraints/parameters ...

ios - Adding a text and progress icon to navigation bar -

Image
i add status navigation bar. example, in whatsapp, when user changes alert settings, display "updating" text , progress icon on navigation bar, shown in below image. how do that? simple add separate view in xib, image below and create iboutlet of components, , can below self.navigationitem.titleview=self.progressview; //progressview iboutlet of container view progressview in viewdidload then can create function like -(void)showprogress{ self.lblupdate.text=@"updating..."; [self.indicator startanimating]; } -(void)hideprogress{ self.lblupdate.text=@"updated"; [self.indicator stopanimating]; } make sure make view background color clearcolor , , make indicator hidewhenstopped . hope helps.

c# - How to send xml through an HTTP request, and receive it using ASP.NET MVC? -

i trying send xml string through http request, , receive on other end. on receiving end, getting xml null. can tell me why is? send: var url = "http://website.com"; var postdata = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><xml>...</xml>"; byte[] bytes = system.text.encoding.ascii.getbytes(postdata); var req = (httpwebrequest)webrequest.create(url); req.contenttype = "text/xml"; req.method = "post"; req.contentlength = bytes.length; using (stream os = req.getrequeststream()) { os.write(bytes, 0, bytes.length); } string response = ""; using (system.net.webresponse resp = req.getresponse()) { using (streamreader sr = new streamreader(resp.getresponsestream())) { response = sr.readtoend().trim(); } } receive: [httppost] [validateinput(false)] public actionresult index(string xml) {...

ios - Accessing obj as property vs method param (style preferences) -

when comes accessing objects different methods in same class, understand, these 2 ways it. given do want hold property pointer object, better way go this? i've been thinking while, , wondered if there preference consensus. #1: nsarray *array = ... // array somewhere self.myarray = array; [self dosomethingtomyarray]; this method takes no parameter , accesses array via own property via self - (void)dosomethingtomyarray { // stuff with/to array via self.myarray [self.myarray ...]; } vs #2: nsarray *array = ... // array somewhere self.myarray = array; [self dosomething:array]; this method takes array , accesses array via own method parameter - (void)dosomething:(nsarray *)array { // stuff with/to array via method parameter "array" [array ...]; } i think it's going depend on dosomethingtomyarray , calls it. fairly obvious comments: if want more 1 array, need take argument; if you're doing logically more array class (e.g. you'...

linux - Java Using High Virt Memory -

Image
according i'm using 14gb+ on java process in apache. in running minecraft control panel , when run memory check via minecraft tells me have using 7.6gb of 8gb. when should looking @ around 1-2gb max of used space. i'm new linux , little confusing me. believe inaccuracy if explain going on here appreciated? checkout linuxatemyram.com also if virtual machine java useage may not accurate. you can limit memory size launching these params -xms1024m -xmx1024m to limit 1gb example

java - How can i show details "on click" of a polyline Google Maps API V2 -

i using google directions api request direction route between 2 points.i parsed "overview polyline" tag , decoded list of latlng objects.i have drawn polyline adding googlemap object. polyline shown ok till now. now want able click on polyline , show details distance , time every point of polyline clicked. how this?? suppose ill need click listener couldnt find working. can u me please?? (i need java solution not javascript , need maps v2) thx

php date change to 12 hour format and add gmt +3 -

i using date as: $date = date('m-d-y h:i:s'); this inserts 24 hour , want 12 hour format , add gmt +3, how can that? if want gmt +3 timezone, apply this: date_default_timezone_set('etc/gmt+3'); although don't recommend because php will not longer support timezone . might use one of supported ones . , date being in 12-hour format use way: $date = date('m-d-y h:i:s'); lowercase h format character for 12-hour format of hour leading zeros

android - Listener for RadioButton for change Fragments -

i need switch fragments @ application tabs (radiobutton). event listener should use? onclick or oncheckedchanged? if possible example for single radiobutton can use onclicklistener follows: onclicklistener listener = new onclicklistener() { @override public void onclick(view v) { radiobutton rb = (radiobutton) v; toast.maketext(your_activity.this, rb.gettext(), toast.length_short).show(); } }; radiobutton rb1 = (radiobutton) findviewbyid(r.id.radiobutton1); rb1.setonclicklistener(listener); in case of radiogroup need use oncheckedchangelistener follows : radiogroup radiogroup = (radiogroup) findviewbyid(r.id.yourradiogroup); radiogroup.setoncheckedchangelistener(new oncheckedchangelistener() { public void oncheckedchanged(radiogroup group, int checkedid) { // checkedid radiobutton s...

javascript - .find doesn't work in jquery 1.4.2 and I can't figure out how to support it -

i can't figure out how write code backwards support jquery 1.4.2. perplexed trying support older library files. var n = this; e(document).ready(function () { var r = e("body").find(n); r.attr("placeholder", t); r.val(t); n.focus(function () { e(this).val("") }).blur(function () { var r = e(n); if (r.val() == "") r.val(t) }) }) you're overcomplicating code. first, don't need use $(document).ready() inside of plugin, can let developer using plugin take care of that. next, inside of plugin, this jquery object containing selected elements. should iterate on them act on each 1 individually. (function ($) { $.fn.labelfixer = function (t) { return this.each(function(){ var $this = $(this); $this.attr("placeholder",t); this.value = t; $this.focus(function(){ ...

url routing - How can I get AngularJS working with the ServiceStack FallbackRoute attribute to support HTML5 pushstate Urls? -

i building client/server solution, using angularjs single page app client component , self-host servicestack restful api server component. single visual studio console application project holds html , javascript files angularjs component, along c# classes bootstrapping servicestack apphost (i have devolved interface , service responsibilities separate visual studio projects). i have set html , javascript files have 'build action' of 'none' , 'copy output directory' of 'copy if newer'. everything working long prepared put having '#' in site urls. eliminate using html5 pushstate urls. effectively means need persuade servicestack serve default single page app html shell page whenever non-existent route requested. there fallbackroute attribute available in servicestack appears have been added purpose. however, unsure how use it. have found people asking similar questions here , here , here . answers given before new fallbackroute attr...

html - Page won't scroll; using CSS fixed position tables -

it's been years since have done heavy duty html/css work, , started overhaul of company's website. i'm pretty happy way design turning out , seems work, content filling page have realized page won't scroll, despite there being content below 'the fold'. i'm guessing because i'm using css tables fixed positions. tried changing position attribute 'relative', , although fixed scrolling issue, messed layout , i'm not sure how make work. here fiddle code: http://jsfiddle.net/jbooth63/sknsc/ and here link live preview of code: http://www.financecapital.us/test/test.html any appreciated! here example of code using: <head> <style type="text/css"> body,td,th { font-family: gotham, "helvetica neue", helvetica, arial, sans-serif; font-style: normal; font-weight: normal; font-size: 10px; color: #333;} body { background-color: #fff;} .socialcell { position: fixed; margin-top: 105px; margin-left: 5px; backgrou...

python - Migrating to gmail oauth2 -

we python/django shop , have connection gmail using depracated oauth approach returns token/secret every user. have move oauth2 before 2015 because of google deprecation policy there no documentation how migrate, , making our users reconnect account want avoid. it's there way migration programmatically?

android - Gradle: error: package does not exist -

Image
i know there different solutions different libraries posted. but, me this one? i've busting head past couple of days, , don't know do. tried importing modules in suggested ways different posts. ( project structure --> dependencies --> add dependencies ), etc. project not show errors, when run it, throws me compilation error complains classes missing. library depends on viewpagerindicator 's library imported. here picture. thanks!!! note :i have tried eclipse , problem different there. app crashes when run it. when uncheck islibrary properties -> android , erase libraries, app works. inspired this answer , these steps did: put jar file (in case, 'xxx.jar') libs folder of project right click , select add library type in dependencies part of build.gradle file: compile files('libs/xxx.jar') clean build. can done inside android studio, ran gradlew.bat included inside project folder now, project should built , run fine.

eclipse - "remove type arguments" in code-cleanup -

i switched project java 1.6 1.7. i'm getting these "redundant specification of type arguments xxx"-warnings eclipse. since i'm lazy remove these warnings hand wanted done code cleanup. eclipse offers me quickfix "remove type arguments". couldn't find in code-cleanup menu. any hints how achive this? it's open bug (and quite valid requirement needlessly (and manually) correcting 1000s of warnings not option). you can vote here .

php - how to create the sql_query -

i have created filters in php.3 of them aimming 1 table. 4th aimming table. first table : id_of_orders : id_order(int) time(now) username(varchar) price(decimal) the second 1 : order : order_id(int) product(varchar) price (decimal) order.order_id refered id_of_orders.id_order table id_of_orders mapper orders table ( id_of_orders.id_order has unique numbers). table orders contains many orders of them have same order_id i want return id_of_orders.id_order contain order.product=='proion' the query use this: $query = "select * id_of_orders 1=1"; if(!empty($_session['employees'])) $query .= " , id_of_orders.username='$_session[employees]'"; if(!empty($_session['timis'])) $query .= " , id_of_orders.price='$_session[timis]'"; if(!empty($_session['dates'])) $query .= " , date(time)='$_session[dates]'"; //if(!empty($_session['proions'])) // $query .= " , (...

java - How can I associate a value with each checkbox in a ListView? -

i have created custom listview using custom adapter. have xml file defines each row, , each row has checkbox defined in xml file. app judging app each item on listview "task" counts number of points. idea if task completed, judge clicks checkbox, , score of task added overall score. unfortunately, see no way value associated checkbox. there way this? i'll post code, , hope it's enough general idea of issue. the xml file row: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/score_list_layout" android:layout_width="match_parent" android:layout_height="match_parent" > <checkbox android:id="@+id/score_box" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignparentright="true" android:paddingtop="30dp" android:scal...

c# - Adding a string to a List<string> inside of a List<List<string>> -

im trying add string object list inside of list> in & while loop, trying use var list object wish use. here code of class, on im doing wrong appreciated :) public class genclass { private static int _gencount; private static bool _filesloadedtolists; private static list<string> _nounsetone = new list<string>(); private static list<string> _nounsettwo = new list<string>(); private static list<list<string>> _toload = new list<list<string>>(); private string _emotionmidtrim = ""; public const string fileone = "nounsetone.txt"; public const string filetwo = "nounsettwo.txt"; public genclass() { while (_filesloadedtolists == false) { texttolist(fileone,filetwo); _filesloadedtolists = true; } _gencount++; } the problem withing part of class public void texttolist(string fileone, string fil...

c# - Ninject interception attribute with parameters passed to interceptor? -

i have interception working (very simplistically) following code: (see question @ bottom) my interceptor: public interface iauthorizationinterceptor : iinterceptor { } public class authorizationinterceptor : iauthorizationinterceptor { public iparameter[] attributeparameters { get; private set; } // doesnt work currently... paramters has no values public authorizationinterceptor(iparameter[] parameters) { attributeparameters = parameters; } public void intercept(iinvocation invocation) { // have tried attributes // returns nothing. var attr = invocation.request.method.getcustomattributes(true); try { beforeinvoke(invocation); } catch (accessviolationexception ex) { } catch (exception ex) { throw; } // continue method and/or processing additional attributes invocation.proceed(); afterinvoke(invocation); } protected void beforeinv...

git - Pull request on github - showing commits rebased from master -

i'm working team , we're doing feature branches , pull requests. i created branch, worked on bit while doing little work on master. then, rebased branch against master. want pull request. however, in github, pull request shows commits happened between when first made branch , - commits did on feature branch, , commits on master happened in between. this noisy clutter - doing wrong? i'd pull request show commits i've made, since other commits on both master , on branch, no difference. the suggestion see making branch based on latest upstream master , cherry picking commits branch onto it. i used have same problem: if have foo branch, branched master , pushed origin , , on both branches changes made, after merging/rebasing getting changes master in pull request's diff. i solved executing git fetch first, updating local master branch, changing local branch foo , executing commands: git rebase master git push -f origin foo:foo this ...

How to create custom style mapping in cytoscape.js? -

is there way add custom mapper new cytoscape.js? i know there data(nodekey), uses nodekey's value de novo. can set mapping of own? thanks! custom mappers expensive in general, not supported in cytoscape.js. performance 1 of our top requirements library. if describe sort of mapping you're looking for, may possible api today, or work out meets needs. thanks!

css - Remove the white space below image -

Image
in chrome image on right hand side of banner has small white space under it. odd thing - when using developer tools make change css property, image seems realign , white space disappears. i have added properties image such as: display:block; outline: 0; padding: 0; margin: 0; vertical-align: text-bottom; this page. how looks in chrome: how looks in other browsers: how can rid of space? this common issue, noticed myself in own html web development when using chrome , developer tools. theres seems glitch in html render when have developer tools open. happens every often, know weird bug. never notice in other browser. my suggestion you, ignore :) (if doesn't break html of course) seems minor ui space. good luck -kiru

Why does the order of static members in java matter? -

why order of static members in java matter? e.g. public class { static int i= 1; static int c = i; int = c; <<------ ok } vs. public class b { int = c; <<--- compile error static int c = 1; static int = c; } why java designed such ordering makes difference? (i have edited question based on answer of ykaganovich) edit: thank ! have tested examples non-static variables. has same behaviour, static doesn't play role here. question misleading (at least me). try summarize answers. edit 2 : i try sum answers up. more info please read answers below :) a) direct forward references in java as: static int = c; static int c = 1; are confusing. it's not allowed in java. main reason initialisation order. b) indirect forward references allowed in java public class test { int = c(); int c() { return c; } int c = 1; } c) must define order of execution of variable declaration (or initialisation), it's definition matter how this ...

c# - How to securely handle AES “Key” and “IV” values -

if use aes (system.security.cryptography) encrypt , decrypt blob or memo fields in sql server, store “key” , “iv” values on server? (file, regkey, dbase,...) and protection of aes “key” , “iv” values? the background question more : if “they” hack server , dbase... can program encryption stuff (it's on same server, can't it)... , if "they" good, notice “key” , “iv” values stored...(.net 4.5 ilspy) , can decrypted again. please advice? how handle aes “key” , “iv” value’s? ps: not pwd fields... so, it's not hashing... pure data cryptography. the iv has been thoroughly covered other answers, i'll focus on storing key. first... i can't except not done on single server @ software level. anything done in software can undone in software. can encrypt, hide, , lock in many safes want, application still needs able access key. if application has access, same level of access application able well. developers have been dealing problem lo...

c++ - How to implement a hash table with 2 keys? -

i have following problem: single value, can associated 2 different keys. example: uint64 key1 -> value uint32 key2 -> value so query can twofold: table.find(uint64 key1) or table.find(uint32 key2) key1 , key2 independent. there possibility implement 1 table having access through 2 keys without duplicating items? one possible solution (psedocode): class twokeyhashtable { value find(uint64); value find(uint32); insert(key1, key2, value) { insert_into_table(key1, value); insert_into_table(key2, value); } struct item { uint64 key1; uint32 key2; value value; } *table; }; however solutions doubles number of items in table. have hundreds of millions of items , want keep entire table in memory, asking if more memory efficient exists? wow, surprised there no ideas around... :-/ implemented table, duplicating of items, follows: class twokeyshashtable { public: struct item { uint64 key1; uint32 key2; int32 va...

What version of FFMPEG should I use on DEBIAN to transcode RTSP to RTMP? -

i using command: ffmpeg -i rtsp://login:password@90.70.42.54:554/axis-media/media.amp -f flv rtmp://localhost:1935/live/yarek which worked fine on 1 windows , this command gives errors on linux1 (ffmpeg version 0.8.6-4:0.8.6 writen, rtmp send error 10053 (129 bytes) writen, rtmp send error 10053 (45 bytes) writen, rtmp send error 10038 (42 bytes) av_interleaved_write_frame(): operation not permitted and gives errors on linux2: (ffmpeg version 0.7.15) [h264 @ 0x98e2f80] rtp: pt=60: bad cseq c54f expected=b90c [h264 @ 0x98e2f80] rtp: pt=60: bad cseq b90c expected=c551 [h264 @ 0x98e2f80] rtp: pt=60: bad cseq c552 expected=b90f [rtsp @ 0x98de5e0] estimating duration bitrate, may inaccurate seems stream 0 codec frame rate differs container frame rate: 180000.00 (180000/1) -> 90000.00 (180000/2) input #0, rtsp, 'rtsp://login:password@90.70.42.54:554/axis-media/media.amp': metadata: title : media presentation duration: n/a, start: -4756.58266...

css - white space between divs, simple HTML -

i have searched , searched on site solution , tried apply results simple html none have appeared work. i'm sure there easy way because @ moment there isn't code explain. i want simple layout, 3 div s. 1 main page div containing 2 horizontal div s, want 2 inside div s contain picture used div backgrounds enclosed in main page div , can backgrounds on cannot rid page of white line, i'm sure guys sick of reading about. i line appearing between " header " , " site " div s. i'm sure easy solution. i have want keep html simple possible , plan have 3 three links put in once space has gone, i'm sure can apply solution further div s. i'm struggling upload code, please advise html: <html> <head> <link rel="stylesheet" type="text/css" href="css.css"> </head> <body> <div id="mainwrap"> <div id="header"> ...

database - Difference between NVARCHAR in Oracle and SQL Server? -

we migrating data sql server oracle. columns defined nvarchar in sql server started creating nvarchar columns in oracle thinking them similar..but looks not. i have read couple of posts on stackoverflow , want confirm findings. oracle varchar2 supports unicode if database character set al32utf8 (which true our case). sqlserver varchar does not support unicode. sqlserver explicitly requires columns in nchar/nvarchar type store data in unicode (specifically in 2 byte ucs-2 format).. hence correct sql server nvarchar columns can/should migrated oracle varchar2 columns ? yes, if oracle database created using unicode character set, nvarchar in sql server should migrated varchar2 in oracle. in oracle, nvarchar data type exists allow applications store data using unicode character set when database character set not support unicode. one thing aware of in migrating, however, character length semantics. in sql server, nvarchar(20) allocates space 20 characters ...

c# - use of <!-- # in HTML or ASP.net programming -

the title says all, can enlighten me number sign in assume html comment block? <!-- # these mod_include in apache http server. for eg. <!--#element attribute=value attribute=value ... --> for more read this , this

c# - Implementing a 2D Map -

i posted q. earlier arrays , replies lead me change game design. i'm building 2d game map tiles (cells). need add pen line cells, representing wall cannot pass through. pen line represented cell.topwall, cell.bottomwall etc etc of type boolean shown in code. whole app far. draws grid without pen lines walls. take note of commented out code have tried different things stating walls go array of 0's (no wall) , 1's (walls). question is, can hint on how implement walls like? hope have shared enough information app. thanks cell.cs using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; namespace map { public class cell : picturebox { bool leftwall; bool topwall; bool rightwall; bool bottomwall; } } form1.cs using system; using system.collections.generic; using s...

wordpress - Change current user role with form selection on update (not entry creation) -

i'm using formidable forms in wordpress , have form registers users. can use radio button in registration form determine role be. have hook that. need, however, hook change user role based on radio selection on form entry update. current code works on entry creation. here code assigns roles on registration: add_filter('frmreg_new_role', 'frmreg_new_role', 10, 2); function frmreg_new_role($role, $atts){ extract($atts); if($form->id == 8){ if($_post['item_meta'][280] == 'job applicant') $role = 'applicant'; } return $role; } "8" id of form itself. "280" id of radio button field "job applicant" 1 of values. , "applicant" 1 of our site's user roles. i need adaptation of change role after entry has been created, on update. closest thing can find hook changes user role after successful paypal payment. tried combine 2 couldn't work. here paypal generated user role change...

javascript - Why changing image link invokes controller asynchronously in asp.net mvc -

i'm changing link of image on client side , invokes controller asynchronously. i don't understand behavior, explain me happening? why url adding invokes controller default, happens asynchronously. <script> $("#refreshlnk").click(function () { $("#cap").attr('src', '@url.action("captchaimage")?' + new date().gettime()); }); </script> <img id="cap" alt="captcha" src="@url.action("captchaimage")" style="" /> <a id="refreshlnk" href="#">refresh</a> public actionresult captchaimage() { } this normal , expected behavior. when click button, script changes src attribute of image "/captchaimage?1376967614675". browser tries render image, invokes url. triggers captchaimage method in controller. there many posts related question, can start one: how url.action wo...

java - Sorting the values in the treemap -

i read text file , stored in tree map each key having multiple values.like, key: a1bg values: g5730 a4527 e3732 b0166 key: bca3 values: c1478 a4172 d8974 b1432 e2147 key: db8c values: n0124 k7414 x9851 since tree map got keys sorted.now,i want sort values corresponding key.and o/p as, key: a1bg values: a4527 b0166 e3732 g5730 key: bca3 values: a4172 b1432 c1478 d8974 e2147 key: db8c values: k7414 n0124 x9851 iam new java.can on this. here code bufferedreader reader = new bufferedreader(new filereader("e:\\book\\datasone.txt")); map<string, string> map = new treemap<string,string>(); string currentline; while ((currentline = reader.readline()) != null) { string[] pair = currentline.split("\\s+"); key = pair[0]; value = pair[1]; if(map.containskey(key)) { value += map.get(key); } else { map.put(key,value); } } (string name: map.keyset()) { string key =name.tostring()...

excel - Using month qualification in SUMIFS statment -

here's i'm looking for.... trying sum count of worksheet 'results 2013' column g items if cell matches "canada" if cell e (date) july having trouble date portion of sumifs statement below. sumifs('results 2013'!$g$2:$g$510,'results 2013'!$a2:$a$510 ,"=canada",'results 2013'!$e2:$e510,month('results 2013'!$e2:$e510)=7) example value of "results 2013"$e$480 i try formula, , provides "january" incorrect. =text(month('results 2013'!$e$480),"mmmm") however, formula, results in true or 1 =if(month('results 2013'!$e$480)=7,1,0) the simplest solution add column month using month function compute values, , refer new column in sumifs .

php - NFS hang from Vagrant guest to OSX -

i have vagrant guest i'm using run symfony 2 application locally development. in general working fine, however, regularly finding processes lock in 'd+' state (waiting i/o). eg. try run unit tests: ./bin/phpunit -c app the task launches, never exits. in process list see: vagrant 3279 0.5 4.9 378440 101132 pts/0 d+ 02:43 0:03 php ./bin/phpunit -c app the task unkillable. need power cycle vagrant guest again. seems happen php command line apps (but it's main command line tasks do, might not relevant). the syslog reports hung task: aug 20 03:04:40 precise64 kernel: [ 6240.210396] info: task php:3279 blocked more 120 seconds. aug 20 03:04:40 precise64 kernel: [ 6240.211920] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables message. aug 20 03:04:40 precise64 kernel: [ 6240.212843] php d 0000000000000000 0 3279 3091 0x00000004 aug 20 03:04:40 precise64 kernel: [ 6240.212846] ffff88007aa13c98 000000...

python - Finding intersection between ellipse and a line -

i trying find intersection points between elipse , line, seem unable so. have tried 2 approaches, 1 shapely trying find intersection between linestring , linearring in code bellow, did not usable values out of it. 1 of problems, elipse off center , @ small or high angle # -*- coding: utf-8 -*- """ created on mon aug 19 17:38:55 2013 @author: adudchenko """ pylab import * import numpy np shapely.geometry.polygon import linearring shapely.geometry import linestring def ellipse_polyline(ellipses, n=100): t = np.linspace(0, 2*np.pi, n, endpoint=false) st = np.sin(t) ct = np.cos(t) result = [] x0, y0, a, b, angle in ellipses: angle = np.deg2rad(angle) sa = np.sin(angle) ca = np.cos(angle) p = np.empty((n, 2)) p[:, 0] = x0 + * ca * ct - b * sa * st p[:, 1] = y0 + * sa * ct + b * ca * st result.append(p) return result def intersections(a, line): ea = linearring(a) eb...

c - for-loop optimization using pointer -

i trying optimize code run in under 7 seconds. had down 8, , trying use pointers speed code. gcc gives error when try compile: .c:29: warning: assignment incompatible pointer type .c:29: warning: comparison of distinct pointer types lacks cast here had before trying use pointers: #include <stdio.h> #include <stdlib.h> #define n_times 600000 #define array_size 10000 int main (void) { double *array = calloc(array_size, sizeof(double)); double sum = 0; int i; double sum1 = 0; (i = 0; < n_times; i++) { int j; (j = 0; j < array_size; j += 20) { sum += array[j] + array[j+1] + array[j+2] + array[j+3] + array[j+4] + array[j+5] + array[j+6] + array[j+7] + array[j+8] + array[j+9]; sum1 += array[j+10] + array[j+11] + array[j+12] + array[j+13] + array[j+14] + array[j+15] + array[j+16] + array[j+17] + array[j+18] + array[j+19]; } } sum += sum1; return 0;...

c++ - OpenGL and Game Entities -

i have been looping through game entity list , calling virtual render fn uses: glbegin/glend. i've learned vertex-buffer-arrays way go (especially ios/android). when create new entity world, merely have bind entity's vao vbo, set vao id. if have n entities, have n vao/vbo's? on render function don't need re-bind anything, call "gldrawarray/element"? can use both glbegin/glend-style opengl vao/vbo's in render fn? it seems opengl hates oop, need oop game programming... how solve paradox? thus if have n entities, have n vao/vbo's? in decent game engine, if have thousands of objects same geometry (say, discarded bullet cases or something), there's 1 instance (vao/vbo/whatever) of geometry/mesh loaded game engine. object , mesh used object 2 different things. multiple objects can use same mesh instance. can use both glbegin/glend-style opengl vao/vbo's in render fn? yes, although people insist because opengl 3/4 ava...

I want to dynamically populate the tabs from an array using jquery -

i want dynamically populate tabs array. please me out. tried following code fails work. how hardcode values generated in array?? <!doctype html> <html> <head> <meta charset="iso-8859-1"> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <title>dynamic population</title> <script> $(document).ready(function() { $("div#tabs").tabs(); $("button#add-tab").click(function() { var num_tabs = $("div#tabs ul li").length + 1; $("div#tabs ul").append( "<li><a href='#tab" + num_tabs + "'>#" + num_tabs + "</a></li>" ); $("div#tabs").append( "<div id='tab" + num_tabs + "'>#" + num_tabs + "</div...

ubuntu 12.04 - editing the bash file -

i using ubuntu 12.04.i have added following line both bashrc file , bash_profile. bash-profile file created me in order add lines export cuda_install_path="/opt/cuda" export path="${cuda_install_path}/bin:${path}" export ld_library_path=$ld_library_path:/opt/cuda/lib:/opt/cuda/lib64 now when open terminal showing bash: export: `/opt/cuda': not valid identifier what problem. should changed you have space after = . rid of it, want no spaces on either side of it.

java - Javascript won't post into DIV? -

so console shows data being sent , received reason (probably conditional) nothing posted in specified div tag var var_iddatacheck = <?php echo $javaid; ?>; var var_idcheck = parseint(var_iddatacheck); //datacheck var var_numdatacheck = <?php echo $datacheck; ?>; var var_numcheck = parseint(var_numdatacheck); function activitycheck() { $.ajax({ type: 'post', url: 'feedupdate.php', data: {function: '3test', datacheck: var_numcheck, javaid: var_idcheck}, success: function (check) { console.log(check); var verify = json.parse(check); if (var_idcheck < verify.id) { var_idcheck = verify.id; (var i=0;i<var_idcheck;i++){ $('#datacheck').html(verify[i]); } } settimeout(activitycheck(),5000); }, error: function(check) { console.log(check); settimeout(activitycheck(...

android - how to upgrade a phonegap plugin from 1.6.x to 2.7? -

the code aim grap content using jsoup, , i'm try upgrade code here code far: package com.phonegap.g7.plugin; import java.io.bufferedreader; import java.io.inputstream; import java.io.inputstreamreader; import java.net.httpurlconnection; import java.net.url; import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject; import org.jsoup.jsoup; import org.jsoup.nodes.document; import org.jsoup.nodes.element; import org.apache.cordova.api.cordovaplugin; import org.apache.cordova.api.pluginresult; import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject; public class urlfeedjava extends cordovaplugin { //@override public pluginresult execute(string action, jsonarray data, string callbackid) { pluginresult.status status = pluginresult.status.ok; pluginresult r=null; try { string target = data.getstring(0); string selector = data.getstring(1); document...