Posts

Showing posts from July, 2011

linux - use variable from while do loop bash -

i have while loop below using variable pov. need each line set variable can called in connection string, cant figure out how create loop feed each line separately. wanting if [ ! -z $pov] .../shell execute using $pov... fi each line in seq_fy.txt what working with: cat seq_fy.txt | while read pov; echo "pov$((n++))=$pov" ###wanting "if [ ! -z $pov] <execute> fi" each line in seq_fy.txt done $ ./while_loop_only pov0= pov1=spt_seq_010,fy15 pov2=spt_seq_010,fy16 pov3=spt_seq_020,fy15 pov4=spt_seq_020,fy16 pov5=spt_seq_030,fy15 pov6=spt_seq_030,fy16 pov7=spt_seq_040,fy15 pov8=spt_seq_040,fy16 pov9=spt_seq_050,fy15 pov10=spt_seq_050,fy16 looks have been way over-analyzing this.... don't need pov or exporting variables @ all, put command inside while loop , fed in $line, , seems work expected cat fiename.txt | while read line; $owsdirectory"/hpm_ws_client.sh" processcalcscriptoptions "$appname" "$line" "

etl - Python Rename Filename With Substring Best Practices -

simplified, have data file: p.a2057.aco.qassgn.d150218.t1200333.xls i copy directory "mssp_data_archive" documentation here: dest_dir = "c:/users/office/desktop/test/mssp_data_archive/" file in glob.glob(r'c:/users/office/desktop/test/load/*.xls'): print file shutil.copy(file, dest_dir) i rename original version still sitting in "load" this: qassgn.xls i not know exact name of file monthly (appears @ least partially randomly generated elements). i hoping substring current filename extract desired name above. here have started: for file in glob.glob(r'c:/users/office/desktop/test/load/*.xls'): parts = file.split('.') parts = ['c:/users/office/desktop/test/load\\p', 'a2057', 'aco', 'qassgn', 'd150218', 't1200333','xls'] i know there must better way handle os.path.splitext , os.rename avoid getting "magic numbers"

javascript - JSON nested object to HTML Nested Table -

i'm having trouble getting nest correct way. needs nest object nested. td key, , new td / table objects or if values, shows table name / value. any direction help. the json string this: { "accounts": { "demo": { "name": "your medical clinic", "groupid": "demo", "callerid": "8664738160", "callerid_err": "ok", "transferphone": "1-931-555-1212", "transferphone_err": "invalid length", "timezone": "est", "emrsoftware": "greenway", "merlin": 1, "prm": 1, "calldaysout": 2, "emaildaysout": 5, "enablevoice": 1, "enabletext": 1, "enablemail": 1, "exclude": "12 months,12-17 years,18+ years,2 m

WMI connection error C# -

using system; using system.management; public class class1 { public static void main() { string strcomputer = string.format(@"machinename.domainname\root\cimv2"); connectionoptions options = new connectionoptions(); options.enableprivileges = true; options.impersonation = impersonationlevel.impersonate; options.authentication = authenticationlevel.packet; options.authority = "ntlmdomain:instil.com:instil.com"; options.username = "usr"; options.password = "pwd"; managementscope oms = new managementscope(strcomputer, options); selectquery query =new selectquery("select * win32_directory name ='"+string.format(@"c:\scripts")+"'"); managementobjectsearcher osearcher = new managementobjectsearcher(oms,query); managementobjectcollection oreturncollection = osearcher.get(); if (oreturncollection.c

bash - Alias Substitution in Fish Shell -

question: there fish equivalent of bash's alias substitution or what's recommended best practice keep code clean , dry? background: there's useful feature of aliases in bash called alias substitution. it's mentioned briefly in man page: alias [-p] [name[=value] ...] ... trailing space in value causes next word checked alias substitution when alias expanded. ... the power of functionality may conveyed example. consider many users define grep alias. here's mine: # extended regex, skip binaries, devices, sockets, & dirs, colored, & line # -buffered. use non- canonical alias instead of grep_options may wreck # poorly written scripts alias g='grep -eid skip -d skip --color=auto --line-buffered' similarly, many of same users define alias xargs. here's mine without alias substitution: alias x='xargs -rd\\n' # \n delimited, don't run on empty in and finally, here's how might want use doesn't work: $

update a table using a stored procedure in oracle -

i have table t_time have below attributes time_key, calendar_dt, cal_year, cal_quarter, cal_month, cal_week, week_in_month, cal_st_dt_of_wk, cal_end_dt_of_wk, rfrsh_dt, cal_yyyymm select * t_time time_key = (select max(time_key) t_time); 74937 31-12-2015 2015 4 12 5 5 27-12-2015 02-01-2016 17-07-2009 201512 i want write stored proc such when specify year,t_time should inserted keys , other attributes.. like for 2016 time_key calendar_dt cal_year cal_quarter cal_month cal_week week_in_month cal_st_dt_of_wk cal_end_dt_of_wk rfrsh_dt cal_yyyymm 74938 01-01-2016 2016 1 1 1 1 01-01-2016 02-01-2016 22-04-2015 201601 74939 02-01-2016 2016 1 1 1 1 01-01-2016 02-01-2016 22-04-2015 201601 74940 03-01-2016 2016 1 1 2 2 03-01-2016 09-01-2016 22-04-2015 201601 7494

ios - Laggy local html file .. common reasons? -

i have problem of local html file. noticed happens long html files. did 1 minute video show problem, please check out. https://youtu.be/wbezpverjum all html files running through same code. guys know common reason happen. you haven't stated since testing in ios simulator, i'm going assume using html5 create mobile app. when it's best practice have app pages in single html file, called single page application (spa). speeds things assets files loaded once, rather continuosly navigate other pages in app. more info: http://singlepageappbook.com/goal.html

excel - selecting data cells with data cells under them -

Image
is possible select cells in excel above cells data (the cell below 1 needs selected needs have data)? if every cell in column has data top cell should selected. if there no data cells above or below cell should not selected. thank you i found macro select data cells in range, possible add if "data below" this? tried, im green vba. thank you. sub selectnotblackrange() 'update20131220 dim rng range dim workrng range dim outrng range on error resume next xtitleid = "kutoolsforexcel" set workrng = application.selection set workrng = application.inputbox("range", xtitleid, workrng.address, type:=8) each rng in workrng if rng.value <> "" if outrng nothing set outrng = rng else set outrng = union(outrng, rng) end if end if next if not outrng nothing outrng.select end if end sub here example typical column, column c : sub cselect() dim kolumn string, n long d

asp.net mvc 4 - MVC 4 - 'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for -

yes i've searched rest of s.o. solution, none of solutions worked me. here's issue: 1) visual studio 2012 -> new web site... 2) create normal mvc 4 site (razor v2) , .net 4.5 3) add following code default.cshtml @using (html.beginform()) { } 4) launch , error: cs1061: 'system.web.webpages.html.htmlhelper' not contain definition 'beginform' , no extension method 'beginform' accepting first argument of type 'system.web.webpages.html.htmlhelper' found (are missing using directive or assembly reference?) what gives? edit, uploaded website here zip, 276k: http://budzap.com/mvc.zip this message says version of system.web.mvc not support beginform .it may have many causes.to find out cause problem,you can try 1 of this: it usaually caused deleting second web.confing resides in view folder.see this see version of system.web.mvc in references of project.it might old version doesnot support beginform . add system.web.

c# - How to solve this exception "Could not find a setter for property 'ProductCode' in class ... " -

i getting following exception: "could not find setter property 'productcode'in class ...orderitem.class " the property (productcode) 1 of table keys. see how property declaration in class. public class orderitem : entitybase { public virtual short company { get; set; } public virtual int order { get; set; } public virtual string seri { get; set; } public virtual string productcode { get; set; } public virtual string crop { get; set; } . . . } below mapping. public maporderitem() { table("iped"); compositeid() .keyproperty(c => c.company, "c_emp") .keyproperty(c => c.order, "p_ped") .keyproperty(c => c.seri, "s_ped") .keyproperty(c => c.productcode, "c_psv"); map(c => c.c_cfo).not.nullable(); map(c => c.anothercurrency).column("v_ipe"); . . . } checked

ios - AVPlayer and AWS Services Streaming -

i'm attempting stream videos aws s3 bucket. uploaded several fils "make everyone" permissions. i have created cloudfront distribution (i chose bucket , let others choices default). in web browser can download file / read adress http://distribution.cloudfront.net/movie1.mov in project have initiated avplayer takes path tableview (like itune movie). file each row same tested in web browser: http://distribution.cloudfront.net/movie1.mov row1 distribution.cloudfront.net/movie2.mov row2 ... the player takes path , start playing freeze @ same time. have pause or advance/back continue video. so seems buffer problem. i know if use aws cloud front , how can resolve buffer problem. i didn't find tutorials or answers this. thank help. regards did set geographic restrictions on cloudfront uses servers in area closest you? i meant between web , rmtp in first comment. want web correct. now restricted france, test videos again , see if performance

ffmpeg - formula to calculate video dimensions for target aspect ratio -

i building application converts videos specific dimension under consideration of target aspect ration. the target resolution must 1280x720, want fit uploaded video in size using black bars. can point out formula calculate target video dimensions without changing it's aspect ratio? if target smaller 1280x720 i'll add missing pixels black bars. i'm using ffmpeg "-vf scale=1280x720,pad=?:?:black" command (sorry if english not great) read this page, particularly section: sometimes there need scale input image in such way fits specified rectangle, i.e. if have placeholder (empty rectangle) in want scale given image. little bit tricky, since need check original aspect ratio, in order decide component specify , set other component -1 (to keep aspect ratio). example, if scale our input image rectangle dimensions of 320x240, use this: ffmpeg -i input.jpg -vf scale="'if(gt(a,4/3),320,-1)':'if(gt(a,4/3),-1,240)

ios - Converting CLLocationCoordinates2D into an NSValue -

i'm trying convert cllocationcoordinates nsvalue used in array brought later in app. here code: nsuinteger count = [self.locations count]; cllocationcoordinate2d coordinates[count]; (nsinteger = 0; < count; i++) { coordinates[i] = [(cllocation *)self.locations[i] coordinate]; nsvalue *locationvalue = [nsvalue valuewithmkcoordinate:coordinates[i]]; [_locationsarray addobject:locationvalue]; nslog(@"location = %@", _locationsarray); } however nslog displays array filled (null) values. i'm not sure have gone wrong here, point me in right direction? i didn't see need in coordinates array. , didn't initialised it. try: _locationsarray = [nsmutablearray array]; (cllocation *location in self.locations) { nsvalue *locationvalue = [nsvalue valuewithmkcoordinate: location.coordinate]; [_locationsarray addobject:locationvalue]; nslog(@"location = %@", _locationsarray); }

Integration in python -

the code have written integrate giving wrong results.i c_0,c_1,...c_4 zeros! doing wrong? using 0.7.6 on mac. from numpy import * matplotlib.pyplot import * sympy import * x = symbol('x') f = 1.0*sin(np.pi * x) phi_0 = 1.0 phi_1 = 1.0*x phi_2 = 1./2*(3*x**2-1) phi_3 = 1./2*(5*x**3-3*x) phi_4 = 1./8*(35*x**4-30*x**2+3) c_0 = integrate(f*phi_0, (x, -1.0, 1.0)) c_1 = integrate(f*phi_1, (x, -1.0, 1.0)) c_2 = integrate(f*phi_2, (x, -1.0, 1.0)) c_3 = integrate(f*phi_3, (x, -1.0, 1.0)) c_4 = integrate(f*phi_4, (x, -1.0, 1.0)) print c_0 print c_1 print c_2 print c_3 print c_4 other need import numpy np, don't see problems in recent version (0.7.6). values 0 (as expected due symmetry consideration) others not: >>> print c_0 0 >>> print c_1 0.636619772367581 >>> print c_2 0 >>> print c_3 -0.330926260628403 >>> print c_4 0

javascript - last index array without loop -

good morning/afternoon i want create object whitch simulate array, new browsers no pb change proto of array mine oldest version of ie need know length of false array finding last index. have found way ie: var getlastpos = function(){ for( var in falsearray){ //do nothing } return } but if faster way exists, rather like. try pass regex lastindexof seems don't work thanks. when want find last index array, use <array>.length so not need loop, , function, use falsearray.length if need value last position use this: falsearray[falsearray.length-1] //decrement one, because index array starts 0 i hope helpful.

c++ - Objects Colliding -

i creating function checks if cars colliding , if speed reduced. works different car types not when same car type hits same car type both stop this method being called timer. basically if car hits carwithtrailer car slows down. but if car hits car both stop because same object. ---> last logic in if statement problem !(typeid(*(colliding_items2[i]))== typeid(this)) qlist<qgraphicsitem *> colliding_items2 = collidingitems(); for(int i=0, n= colliding_items2.size();i<n;++i){ if(((typeid(*(colliding_items2[i]))== typeid(carwithtrailer)) ||(typeid(*(colliding_items2[i]))== typeid(car)) ) && (!(typeid(*(colliding_items2[i]))== typeid(this)) )){ speedofcar = speedofcar-1; return; } } i want check if hitting same object type wont stop. any appreciated.

sql - Unique constraint excluding NULLs in UDT field -

i using sql server 2012 , have following user defined table type create type [dbo].[identifiercodetable] table( [id] [dbo].[identifier] null, [code] [dbo].[code] null ) i trying enforce id must unique except null values. have following code , working fine non null values when try insert 2 null values not allow me it. create type [dbo].[identifiercodetable] table( [id] [dbo].[identifier] null, [code] [dbo].[code] null, unique(id) ) is there way exclude null values unique constraint can in regular indexes filter? i think need know (it sql server 2008 think applies sql server 2012 either). a nonclustered index cannot created on user-defined table type unless index result of creating primary key or unique constraint on user-defined table type. (sql server enforces unique or primary key constraint using index.) source: https://technet.microsoft.com/en-us/library/bb522526%28v=sql.105%29.aspx

scheduled tasks - Scheduler on Debian -

upstart not exist in debian on beaglebone , not want mess that. there script developed in https://github.com/web2py/web2py/blob/master/scripts/setup-scheduler-centos.sh uses chkconfig add service start up. chkconfig not exist in debian. tried modify script , use update-rc.d, attempts failed. want run periodic tasks , suggestion welcome , appreciated. know celery found massimo's argument scheduler convincing , wanted use it. way, main drawbacks of web2py cron? should try use that? if want run simple periodic background tasks suggest using web2py's "homemade task queues." using following terminal command give python script access application's models, while running in background (you can use cron schedule command run on startup): nohup python web2py.py -s myapp -m -r applications/myapp/private/myscript.py your custom script (usually kept in /private folder of application) may this: ## in file /myapp/private/mail_queue.py import time while true:

c# - Changes to entity not registering -

i trying update list in 1 of entities. i'm doing: var loggedinuserid = user.identity.getuserid(); var applicationdbcontext = new applicationdbcontext(); var x = request["groupcode"]; var affectedgroup = db.studentgroups.firstordefault(s => s.code == x); var groupid = affectedgroup.id; if (affectedgroup != null) { if (affectedgroup.studentids == null) { affectedgroup.studentids = new list<string>(); } if (affectedgroup.studentids.contains(loggedinuserid)) { tempdata["errormessage"] = "you member of group"; } else { affectedgroup.studentids.add(loggedinuserid); db.savechanges(); } } here studentgroup model: public class studentgroup { public int id { get; set; } [required(errormessage = "the group must have name.")] public string name { get; set; } [required(errormessage = "the code required.")] public string code { get;set;

jquery - Adding responsiveness to pivottable -

i have been using ( http://nicolas.kruchten.com/pivottable ) pivottable.js in 1 of application. table has been rendered fine facing issues while adding responsiveness ui. table don't shrink div sizes defined small view port using media queries. regardless of view-port table plots same size. width of columns of table seems non-changeable. have tried change defined classes col in pivot.css doesn't seem trick. table.pvttable .pvtcollabel {text-align: center; width:50px;} table.pvttable .pvttotallabel {text-align: right; width: 50px;} also below how have used media queries on div on "graph" class table plotted: @media (min-width: 320px) , (max-width: 640px) { /*making gray box span across screen*/ body { padding-left: 0px; /*changed avoid hz scroll on mobile device*/ padding-right: 0px; /*changed avoid hz scroll on mobile device*/ padding-top: 0px; } #console { /* negative indent footer it's height */ marg

node.js - Create Private Mirror of http://nodejs.org/dist -

i'd create proxy or local mirror of nodejs.org increase speed , support build repeatability. sonatype nexus fails nodejs.org/dist isn't quite npm wget fails, i'm not sure why wget --mirror --convert-links --adjust-extension --page-requisites --no-parent http://nodejs.org/dist please let me know if have suggestions wget can not mirror because of robots.txt rules. can ignore them using -e robots=off . if know doing , really wish turn off robot exclusion, set robots variable ‘off’ in .wgetrc. can achieve same effect command line using -e switch, e.g. ‘wget -e robots=off url...’. from wget manual

setting border property in excel using a vbscript macro -

i have macro written vbscript populated excel worksheet data pulled database. need format line have top border across 3 columns. nothing i've tried works. here's need border objexcel.cells(rownum + 2, 6).value = "sub total" objexcel.cells(rownum + 2, 8).value ="=sum(h7:h"&finalrownum&")" 'extended cost subtotal' objexcel.cells(rownum + 2, 9).value ="=sum(i7:i"&finalrownum&")" 'low price subtotal' objexcel.cells(rownum + 2, 10).value ="=sum(j7:j"&finalrownum&")" 'list price subtotal' objexcel.cells(rownum + 2, 11).value = "=h"&finalrownum + 1&"*l"&finalrownum + 1 'price quote' 'for included markup going on subtotal quoted items objexcel.cells(rownum + 2, 12).value ="2.00" objexcel.cells(rownum + 2, 12).interior.color = rgb(255, 255, 153) i got

udp - perl - how do I capture a multicast [video] stream? -

i trying record multicast stream coming webcam, , record file. can access multicast stream , see video vlc, can't see when try play file i'm writing via perl. here's code: use strict; use warnings; use io::socket::multicast; $group = shift @argv; $port = shift @argv; # set stream $stream = io::socket::multicast->new(proto=>'udp', localport => $port); $stream->mcast_add($group) or die "couldn't set group: $!\n"; # date , time. we'll use name stream file $fname = `date +%y-%m-%dt%h_%m_%s`; chomp $fname; $fname .= ".mpg"; open (my $file, ">", $fname) or die "couldn't open file $fname writing: $!"; binmode($file); print "streaming $group:$port $fname!\n"; $i (0..500){ $data; next unless $stream->recv($data,1024); print "data received! $i \n"; print {$file} $data; } close ($file); wireshark shows protocol of stream mpeg ts . i appreciate assis

c++ - Trackbar name and size in OpenCV? -

when test tutorial, trackbarnames not displayed in case. why? http://opencv-srf.blogspot.fr/2011/11/track-bars.html also, width of scrollbar not match width of window in tutorial. why? could please us?

neo4j - @Query result type different between ImpermanentGraphDatabase and SpringCypherRestGraphDatabase? -

i using @query annotation on repository interface method retrieve list of nodes contained in path. if switch impermanentgraphdatabase springcypherrestgraphdatabase, having errors while parsing results because type returned query different : context : using sdn 3.3.0.release , neo4j 2.1.7 code used in junit test my graph : (t:type1)-[:has_key]->(:key)-[:next]->(:key)-[:next]->(:key)-[:next]-> .... , on (yeah, sounds linkedlist ^^) the query "i want keys associated type" used path query : match (key:key)<-[:has_key]-(:type1 {typeid :{0}}), p=(key)-[:next*]->(:key) return nodes(p) order length(p) desc limit 1 using impermanentgraphdatabase : my query returns iterable<iterable<object>> , have cast "object" inside nodeentity using neo4joperations.convert(...) method because objects of type nodeproxy . using springcypherrestgraphdatabase : my query returns iterable<iterable<map<string, string>>>

In what situation would one use expectationForNotification in swift testing -

i'm little confused what/when expectationfornotification opposed expectationwithdescription . i've been unable find clear examples in swift when , call. i'm assuming perhaps test notifications looks might more convenient wrapper around whole addobserver() call of notification center. could give brief explanation of does, when use it, , perhaps few lines of sample code? thanks as have imagined expectationfornotification convenience expectation checking if notification raised. this test: func testitshouldraiseapassnotificationv1() { let expectation = expectationwithdescription("notification raised") let sub = nsnotificationcenter.defaultcenter().addobserverforname("evpassed", object: nil, queue: nil) { (not) -> void in expectation.fulfill() } nsnotificationcenter.defaultcenter().postnotificationname("evpassed", object: nil) waitforexpectationswithtimeout(0.1, handler: nil) nsnotificat

forms - Javascript change drop-down box options based on another drop-down box value -

this question has answer here: populate 1 dropdown based on selection in another 3 answers i practising programming in javascript , have found problem must answered experts regarding drop-down boxes. the scenario is: i have drop-down box gives possible options provinces , second 1 (town) depends on selected in provinces drop-down . is there way in javascript when chose among provinces, second drop-down gives options province selected? here simple example started. it works attaching event listener change event province dropdown, looks towns in province via provs object. see comments detailed explanation of each line does. window.onload = function() { // provs object can think of lookup table var provs = { 'british columbia': ['victoria', 'sanitch'], 'ontario': ['bracebridge',

facebook - Can not share a pretyped text with ACTION_SEND to socials -

i trying use action_send intent sharing aplication throug can post text select. i use code public void sharebutton(view v){ intent sharingintent = new intent(intent.action_send); sharingintent.settype("text/plain"); sharingintent.putextra(android.content.intent.extra_text, html.fromhtml("<p>try android application https://link...</p>")); startactivity(intent.createchooser(sharingintent,"share by")); } for example want select facebook , should load facebook app , in text field there should be: "try android application https://link ..." instead either doesnt show me option sharing via facebook if use sharingintent.settype("text/html"); (it show emails, dropbox , blootooth) or doesn't place text inside if use sharingintent.settype("text/plain"); have solution me? feel free help. you should integrate facebook sdk , use share pretyped text on facebook, in twit

laravel 5 model class not found -

i’m new laravel 5. tried create customer model in models folder. created both customercontroller , customer via php artisan make:... , error: fatalerrorexception in customercontroller.php line 30: class 'app\http\controllers\cusomter' not found. my customer model: <?php namespace app\models; use illuminate\database\eloquent\model; class customer extends model { // protected $table = 'customer'; protected $primarykey = 'cid'; // protected $fillable = [ // 'name', // 'gender', // 'address', // 'discountpercent', // 'email', // 'phone' // ]; } my customercontroller : <?php namespace app\http\controllers; use app\http\requests; use app\http\controllers\controller; use illuminate\http\request; use app\models\customer; class customercontroller extends controller { /** * create new controller instance. * * @return voi

activerecord - Rails multiple has many relationships on the same model, one with an alias and polymorphic -

i have 2 models, user model , task model. prior setting new relationship, there simple has_many , belongs_to relationship, ex: class user < activerecord::base has_many :tasks end class task < activerecord::base belongs_to :user end this relationship in application represents user created task record, example when user creates 1 sets current user's id equal tasks.user_id . i want relationship (the same exact type) "assigned" feature. means relationship above represents creator of task, while assigned_id represents assigned to. however, assigned_id can user , vendor , or carrier . hence polymorphic relationship. i've set on task model , has assignable_id , assignable_type column on in database. i added task model: belongs_to :assignable, :polymorphic => true . what line can add make association work in user model. there has_many :tasks different purpose. how can done? try below: has_many :assigned_tasks, class_n

lua - Issue using math.atan2 when rotating an object -

well... issue comes quality of life preference honest. i'm @ day job can't provide specific code; however, can give pseudocode , provide actual code when home. i have created virtual joystick , want map object circles screen math.atan2 angle. this works if use obj.rotation = angle . what want do(and have stayed night trying figure out) make transition of object go smoothly joystick angle instead of equaling isn't jittery. idea come getting delta of 2 , subtracting obj.rotation delta/4. that works part, when angle math.atan2 goes 359 0 messes up. has ever run and/or willing me out? there way make math.atan2 spit out numbers > 360? i've been banging head on keyboard long on this. many in advance. local function movepaddle(event) local obj = right local mmin = math.min; local mcos = math.cos; local msin = math.sin; local matan2 = math.atan2; local msqrt = math.sqrt; local mfloor = math.floor; local mpi = math.pi; local radtodeg = 180/mpi; local degtor

c# - How to version middle tier .NET application classes/methods -

we have typical n-layer .net application sits in between our database , web api service layer. application consists of business layer, data repository/access along related dtos , business objects. we have solutions in place version our stored procedures , our web api endpoints. issue solution version middle layer, actual class methods , schema objects. google searches come results versioning source code in source control solution or how version using assembly info, neither of these referring results limited. so example, have 2 endpoints: ...api/v1/tax/charges ...api/v2/tax/charges v1 must hit 1 version of method calculatetaxpctgs , v2 hits version updated business logic. along both needing use different versions of poco tax , taxitems changed name of 1 field in v2. the easy develop hard manage , rigid/static solution create 2 different methods, calculatetaxpctgs_v1 , calculatetaxpctgs_v2. doesn't seem idea. hard find best practices or alternative solutions dilemma.

unit testing - Slow test file compilation in Swift 1.2, Xcode 6.3.1 -

i experienced slower compilation of swift unit test files after migrating project xcode 6.2 6.3.1. my unit test use quick/nimble framework. in each test file have: import myapp the interesting thing when comment out import, compilation lightning fast. tested out on dummy unit test files, in fact don't use of application's code. import makes huge difference compilation time. i didn't observe big impact when using xcode 6 - 6.2. have ideas how improve compilation speed now? according 1 of replies in http://devforums.apple.com/message/1128702#1128702 . enabling whole module optimization in build settings makes issue walked around.

java - Spring's application context available everywhere - Set application context in a static variable -

instead of "struggling" inject or pass common spring beans everywhere needed, in non spring managed class, practice set spring's application context in static variable anywhere ? doing allow example jdbctemplate singleton in non spring managed class (or hibernate session factory). there reason not doing ? for example : @component public class springcontext implements applicationcontextaware { private static applicationcontext applicationcontext; @override public void setapplicationcontext(applicationcontext applicationcontext) throws beansexception { springcontext.applicationcontext = applicationcontext; } public static jdbctemplate getjdbctemplate() { return applicationcontext.getbean(jdbctemplate.class); } public static sessionfactory getsessionfactory() { return applicationcontext.getbean(sessionfactory.class); } public static session getcurrentsession() { sessionfactory sf = applicationco

python - Can be saved into a variable one condition? -

it possible store condition in variable, rather immediate return it, when declare it? example: a = 3 b = 5 x = (a == b) print(x) = 5 print(x) the return is false false however, expected get false true i'm having fun magic of python. know possible using function, wonder if possible using variable. the condition evaluated immediately. if want evaluate on demand, make function or lambda expression: x = lambda: == b print(x()) also, black magic , make class evaluates condition when it's printed: class condition: def __init__ (self, cond): self.cond = cond def __str__ (self): return str(self.cond()) x = condition(lambda: == b) print(x) this educational purposes though, don't use in production. note onl works in print statements - make work in if statements etc have override __bool__ (python 3) or __nonzero__ (python 2).

javascript - The color of selected item on AngularJS disappears -

i need color of selected item not disappear after click other part of page. index.html <div class="collapse navbar-collapse navbar-collapse-bottom-right navbar-collapse-default"> <ul class="nav navbar-nav navbar-right navbar-bottom-right"> <li class="menuitem" ng-repeat="item in menu"><a href="/#!/{{item.url}}">{{item.title}}</a> </li> </ul> </div> app.js $rootscope.menu = [ { title: 'product', url: 'product' }, { title: 'about', url: 'about' }, { title: 'contact', url: 'contact' }, { title: 'register', url: 'register' }, { title: 'login', url: 'log

swift - Error Cannot invoke initilizer of type 'Box<T>' -

why not allowed? class box<t>{ let value: t init(_ value:t){ self.value = value } func map<u>( f: t -> u)->box<u>{ return box(f(self.value)) } } error @ return box(f(self.value)) : error : cannot invoke initilizer of type 'box<t>' argument list of type '(u)' you have specify type box object you're returning: class box<t> { let value: t init(_ value:t){ self.value = value } func map<u>(f: (t) -> (u)) -> box<u> { return box<u>(f(self.value)) } } within context of box<t> class implementation, references box assumed box<t> unless explicitly specify type (as did box<u> , in return statement, above).

plugins - Naming audio plug-ins using JUCE framework -

i've been working on developing audio plugins using juce framework. i'm having issue regarding naming plugin. i've created separate projects entirely different plugins. when load plugin starting logic pro x, seem recent plugin built, however, plugin title first plugin made. say, seems when make new plugin, takes on name of previous plugin , replaces it. i've tried renaming plugin code, au validation tool recognizes plugin having plugin code of previous plugin. has come across problem or have suggesting might causing it? additionally, using wdl framework before using juce , had same problem. of course makes me think problem not specific juce or wdl. any input appreciated, thanks! open introjucer 1 of projects , select "config" tab in left panel. select project @ top of tree view. in right panel, should see 2 fields called "plugin manufacturer code" , "plugin code". your other project should have same plugin manufactu

twitter - Train corpus of Tweets for Sentiment Analysis, using NLTK for Python -

i'm trying train own corpora sentiment analysis, using nltk python. have 2 text files: 1 has 25k positive tweets, separated per line, other 1 25k negative tweets. i use stackoverflow article, method 2 when run code create corpora: import string itertools import chain nltk.corpus import stopwords nltk.probability import freqdist nltk.classify import naivebayesclassifier nbc nltk.corpus import categorizedplaintextcorpusreader import nltk mydir = 'c:\users\gerbuiker\desktop\sentiment analyse\my_movie_reviews' mr = categorizedplaintextcorpusreader(mydir, r'(?!\.).*\.txt', cat_pattern=r'(neg|pos)/.*', encoding='ascii') stop = stopwords.words('english') documents = [([w w in mr.words(i) if w.lower() not in stop , w.lower() not in string.punctuation], i.split('/')[0]) in mr.fileids()] word_features = freqdist(chain(*[i i,j in documents])) word_features = word_features.keys()[:100] numtrain = int(len(documents) * 90 / 100) trai

diacritics - Accents does not appear with php -

i have form post comments when comment words have accents, accents not appear. have : > bla &egrave;&egrave;&egrave;&egrave;&egrave;me i have on header : <meta http-equiv="content-type" content="text/html; charset=utf-8"/> so it's problem php not know add in form my form : <?php print_comments();?> <h3> add comments </h3> <form action="article1.php" method="post" > <span class="input-label">name</span> <input type="text" required name="comment_name" <br/> <br/> <span class="input-label">email</span> <input type="text" required name="comment_email" <br/> <br/> <textarea class="input-label" name="comment" requ

java - Random number keeps giving the number 1 -

since added while loop little rock,paper , scissors game keeps giving me number 1. package steenpapierschaar1; import java.util.scanner; /** * * @author t */ public class steenpapierschaar1 { /** * @param args command line arguments */ public static void main(string[] args) { int rock = 1 ; // waarde van rock int paper = 2; // waarde van paper int scissor = 3;// waarde van scissor int ai = 1 + (int) (math.random() *3);// maakt int ai een random getal nog niet af moet een range in komen scanner keyboard = new scanner (system.in);// naam scanner input boolean playing = true; string answer, answer2 = null; while(playing = true){ system.out.println("choose 1 rock, 2 paper , 3 scissor"); // string met keuze voor user int userchoice = keyboard.nextint();// waarde van userchoice if (ai == 1 && userchoice == 2 || ai == 2 && userchoic

c# - String function - replace instances of a character if they are between two other characters -

Image
i ran massive sql query don't want run again , saved results csv. doing processing in c# console app adds each record storage table. unfortunately, messed , did not remove ','s results, , there objects serialized in json in data contain ','. i looping through data, , columns correctly line temporarily convert ',' ';', if between curly braces in string. example: id,inputmodel,type 1,{"address":"11th street"},true 2,{"address":"11th street, new york"},true my code follows: for (int j = 0; j < alllines.length; j++) { string line = alllines[j]; // replace ',' ';' if between curly braces string[] data = line.split(','); myinsertmethod(data); } desired result: id,inputmodel,type 1,{"address":"11th street"},true 2,{"address":"11th street; new york"},true you can match comma inside curly b

ios - Auto-resize label + UitableView. Doesn't resize -

Image
i have table cell 3 labels. 2 of them has "lines: 0". i set hugging , resistance priority http://www.raywenderlich.com/73602/dynamic-table-view-cell-height-auto-layout and works fine, if tableview located in "tabbarcontroller". if put same tableview simple viewcontroller, label1 not expanding. fine: wrong: i use 1 cell class , cell xib both of tables. , 1 class tables delegate/data source. tables delegate: func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { var cell = table.dequeuereusablecellwithidentifier("gravetableviewcell") as? gravetableviewcell if (cell == nil) { cell = nsbundle.mainbundle().loadnibnamed("gravetableviewcell", owner: self, options: nil)[0] as? gravetableviewcell cell?.configurecell(data[indexpath.row]) } return cell! }

c++ - "Disallowed system call: SYS_socketcall" when I try to solve the "sum the largest n integers in the array" programming challenge -

i'm trying come solution sum n largest integers in array of integers every integer between 0 , 9 int sumnlargest(int* andata, int size, int n) programming challenge prompt, solution other obvious 1 of sorting copy of array , returning sum of last 9 elements.so tried writing linear solution below #include <iostream> int sumnlargest(int* andata, int size, int n) { // sum n largest integers in array of integers every integer between 0 , 9 int cntarr [] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; (int = 0; < size; ++i) ++cntarr[andata[i]]; int sum = 0; (int = size - 1; >= 0; --i) { sum += (n - cntarr[i]) >= 0 ? cntarr[i] * : n * i; --n; if (n <= 0) break; } return sum; } int main() { int myarray [] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 11, 12, 15}; std::cout << sumnlargest(myarray, sizeof(myarray)/sizeof(int), 2); return 0; } but i'm getting error disallowed system call

c# - ASP.NET MVC5 Model Binder - Null when binding collection of collections -

i have researched on net here can me. i have following viewmodel classes: public class personeditviewmodel { public person person { get; set; } public list<dictionaryrootviewmodel> interests { get; set; } } public class dictionaryrootviewmodel { public long id { get; set; } public string name { get; set; } public icollection<dictionaryitemviewmodel> items; public dictionaryrootviewmodel() { items = new list<dictionaryitemviewmodel>(); } } public class dictionaryitemviewmodel { public long id { get; set; } public string name { get; set; } public bool selected { get; set; } } in edit view use custom editortemplate layout collection of interests using @html.editorfor(m => m.interests) . there 2 editortemplates rendering: dictionaryrootviewmodel.cshtml: @model platforma.models.dictionaryrootviewmodel @html.hiddenfor(model => model.id) @html.hiddenfor(model => model.name) @html.editorfor(model =

python - Change the order in which Django migrate app during testing -

i using custom user model inherits abstractbaseuser class. when try migrate after makemigrations command django.db.utils.programmingerror: relation "custom_user_users" not exist this happening since django trying migrate other apps first depends upon custom user model. tried changing order of app contains custom user model in installed_app no luck. i know can force migrate custom_user model first let django migrate other models. solves problem during running test runs migration in order django decides. how can alter order in apps migrated during test ? other way solve dependency problem ? i using django 1.8 put your apps before django apps in installed_app in settings.py file

html - VB WebBrowser control dropdownlist -

on webpage: https://www.youtube.com/upload_defaults want control dropdown category. when inspect element don't find id can't use getelementbyid. i have tried code doesn't work: dim allelements htmlelementcollection = webbrowser1.document.all each webpageelement htmlelement in allelements if webpageelement.getattribute("value") = "category_id" webpageelement.setattribute("value", "20") end if thanks in advance. after inspecting element, you're right, category dropdown not have id, has name: category_id . condition check if current looped htmlelement category dropdown, wrong. replace line: if webpageelement.getattribute("value") = "category_id" with this: if webpageelement.getattribute("name") = "category_id" or this: if instr(webpageelement.name, "category_id") because, don't forget, category_id dropdown's name.

python - Comparing values in lists from classes -

i looking create "top trumps"-style game gcse computer science class. have managed set superhero class, , created couple of superheroes (hulk , thor). want able pick attribute thor , automatically compare hulk , higher. eventually have list of, say, 20 superheroes, split evenly 2 lists of lists. this, player's card should display them choose compare corresponding attribute in opponent's list (without being seen until chosen). winner remove superhero 1 list , place in another, until 1 list depleted. i not know how lists of lists set , compare values once selected. import random class superhero (object): """a class makes super hereos.""" def __init__(self, name, beastrating, power, intelligence, specialpower, fightingskills, speed): self.name = name self.beastrating = beastrating self.power = power self.intelligence = intelligence self.specialpower = specialpower self.fighti

Powershell Value Output, disable default -

when open powershell on 2 of servers, value returned: windows powershell copyright (c) 2012 microsoft corporation. rights reserved. 64-bit powershell loading sql provider which means, of return true value scripts, broken. there workarround disable 64 bit , sql provider information? there writehost commands in default powershell profile - problem solved

Optimizing string parsing with Python -

i have string in form 'ab(ab(ddc)c)a(baac)dab(abc)' . each character represents element ( a , b , c or d ). between parentheses, on right, there child of each element (which may absent). in example, having 'ab(ab(ddc)c)a(baac)da' , top level ab (ab(ddc)c) a (baac) da --> [a, b, a, d, a] , corresponding children [none, ab(ddc)c, baac, none, none] . children parsed recursively. i have implemented solution here: def parse_string(string): = 0 parsed = [] while < len(string): if string[i] in ('a', 'b', 'c', 'd'): parsed.append([string[i], none]) += 1