Posts

Showing posts from August, 2013

c# - Display equivalent of "MMM d, yyyy" in current culture info -

i've perused standard datetime formatters c# offers, , can't seem find 1 matches "short date" requirement: "may 4, 2013". know can custom format string accomplish goal: mydatetimeoffset.tostring("mmm d, yyyy"); however, application may go other countries. there way current culture's equivalent particular format string? mydatetimeoffset.tostring("mmm d, yyyy", cultureinfo.currentuiculture); and have adapt equivalent "short date" format in foreign culture? i don't think there's default format option baked in maches specific requirement ( d may come close). i've overview in bookmarks more 10 years now, , find still useful: http://samples.pdmlab.com/ anyway, app may not available infinite amount of languages, think best choice use kind of datetime extension method , format depending on actual language being used, if necessary.

c# - SharePoint Event Reciever Works On One Machine/computer/user -

so have created updated version of wsp sharepoint 2010 due our migration/update 2007 2010. the wsp event handler/reciever itemadded() , have working intended. issue operation seems work 1 computer/machine , no others. when item added list wsp creates folder in shared documents library, creates wiki page, updates new list item links shared doc , wiki. when triggered machine #1 , user #1 operations work, when machine #2(m2) , user #2(u2) or m3 , u3 non of tasks take place when new item created. user #2 can log in on m1 , create new item , operations work. if u1 uses m2 or m3 create item events don't trigger. machine #1 able trigger event many times want no other computer able to. if able follow code or sort of cache setting on local machine or sp server, or else? appreciated. update: machines on same network. non of machines server various personal laptops. development done on separate machine. accessing via same url. users have same access. on our test site switch

jQuery Grid Layout Image Size -

i using jquery plugin grid-a-licious ( http://suprb.com/apps/gridalicious ). want show on desktop browsers real image sizes. $.gal.settings = { selector: '.item', width: 450, gutter: 1, animate: false, animationoptions: { speed: 200, duration: 300, effect: 'fadeinonappear', queue: true, complete: function () {} }, }; https://github.com/suprb/grid-a-licious/blob/master/jquery.grid-a-licious.js my next problem how can set borders of images. css thought make nth-child did not solve it. here link example http://jsfiddle.net/ajjph/1/ i suggest freewall. cross-browser , responsive jquery plugin create many types of grid layouts include image layout. can see demo image layout: http://vnjs.net/www/project/freewall/example/image-layout.html the project's github homepage https://github.com/kombai/freewall

java - Is Graphics2D.draw performed if the Shape is offscreen? -

i'm working on rendering code, , wondered if graphics2d.draw(shape) performed exact same way onscreen offscreen. if is, there way check if shape (a line2d) onscreen? depends on mean "exactly same way". as far calls draw-something() code concerned, take place normally. different, somewhere in rendering chain condition shape not fall actual rendering area detected , no pixels output shape. as detecting if "on screen", depends define screen as. reasonably define area described graphics object (that may part of screen, or off screen, heck printer!). provided have not changed clip area of graphics instance, getclipbounds() gives rectangle graphics rendered. if graphics comes swing component, can substitute components dimensions rendering area. once have actual rectangle, can make use of methods provided shape detect collisions (contains(), intersects() etc.).

validation - Can hibernate validator be used to validate a field depending on a field value from another class -

i have scenario need validate fields of class depending on value of field class. for ex: street, city, postal code of address class should not null if employee has registered group retirement plan. can scenario handled using custom validator of hibernate validator? candidate hibernate validator ? if so, provide me examples. i have gone through cross field validation examples like: cross field validation hibernate validator (jsr 303) if have boolean indicator indicate whether user registered group retirement plan in address domain class, know can come custom validator verify fields. but, want avoid adding indicator address class. well, address not field in employee class nested validation. the frameworks using spring mvc , mybatis data access. validation happening @ spring rest api call @valid annotation. i guess custom class level constraint might work, depends on actual domain classes. not clear how example employee, group retirement plan , these other entities

ios - Rails "as_json" method returning invalid json? -

i trying have ios application read json generated rails server. now, having text file, eventual goal retrieved via route. the ios application throwing errors trying read (which generated as_json): {"created_at"=>fri, 16 aug 2013 13:21:07 utc +00:00, "gender"=>"m", "id"=>1, "location_id"=>1, "max_hit_points"=>nil, "my_name"=>"jim bob", "npc_type_id"=>nil, "universe_id"=>1, "updated_at"=>fri, 16 aug 2013 13:21:07 utc +00:00} when give json validator ( http://jsonformatter.curiousconcept.com ) i several errors everything, how has "=>" rather colon. am doing weird? why rails seem not generate valid json? there somehow multiple types of valid json (arrows vs colons?) how can make generate json ios app (or validator) likes? as_json used prepare hash suitable json rendering. ( see doc ) you need call to_json real

php - string value contains (') in the insert statement. -

i have following insert statement, work fine if pname doesn't have (') value, when text contain of ('), query return syntax error. idea how fix this? many thanks. $queryinsert = "insert cart (cartpid, cartpname, cartprice,cartcustid, cartdate) values ( $pid, '$pname', $pprice, $custid, (now()))"; you need escape inputs before saving in database. example, mysql_real_escape_string . $pname = mysql_real_escape_string($pname); $queryinsert = "insert cart (cartpid, cartpname, cartprice,cartcustid, cartdate) values ( $pid, '$pname', $pprice, $custid, (now()))"; this kind of situation can lead sql injection , should check topic . first thing move prepared statements, save headache sql injection prevention.

amazon web services - JMeter 3: Clearing DNS Cache with DNS Cache Manager -

i'm doing performance tests against aws elb, , older version, used dns cache manager in order working. (so hits every instance under load balancer, instead of picking 1 , re-using ip). great. but i'm using jmeter 3 same test plan - i'm noticing using wireshark dns cache manager not causing same behaviour lb, again picking 1 instance's ip , reusing it. i've tried moving around under thread group, unticking "clear cache each iteration", changing dns servers list, , using system dns resolver. logs show start-up against each thread in test. i'm using httpclient4 http request implementation. am missing in new version should on in order work again? or bugged?

osx - How can I kill a zombie process whose parent is PID = 0? -

often, when running lldb on osx, debugger sporadically crash (this seems nature of lldb). when happens, zombie process (the 1 debugging) looks strange. has parent pid = 0: my process called: worker here output of ps aux | grep worker root 22785 0.0 0.0 0 0 ?? z 3:48pm 0:00.00 (worker) as can see, process has pid, has no parent pid. nothing sudo kill -9 <pid> in fact, nothing short of restart seems rid of it. how can kill process that? need process die, because holds on ports need. zombie name given processes died. not run longer , do not consume system resources longer. listed in process table not updated @ time zombie process finished running. reason why not assigned meaningful parent. therefore can not kill zombie second time (as name implies, in contrary happens in medium-level horror movies :-)). in operating systems enough wait time zombie processes disappear list of processes. or have reboot if can not live

Vimeo Pro Player - make custom logo link to site, or add link icon? -

i considering upgrading vimeo pro account in order customize video player. see can upload own logo, want make sure can set logo link url of choice. if not through logo, there way add custom icon provide such link? finally, if not through either of above, such functionality available through "3rd party players"? can't find info on 3rd party players. thank you! yes, can set logo link url. under videos go embed check use custom logo , can check link logo to , enter desired url.

testing - How to validate the number of columns in a table? -

i trying validate number of columns generated in table through ranorex. example car being bought , payment done in 12 installments. application divide amount in 12 equal installments , display them in table. have put screenshot in report. show there 12 columns in table. how can achieve this..please help. get xpath table spy tool. , add usercode method. public void testmethod() { var rows = host.local.find<trtag>("/dom[@caption='tryit editor v3.0']//iframe[#'iframeresult']/?/?/table/tbody/tr"); int rownum = 0; foreach (var row in rows) { rownum++; } report.info("total rows: " + rownum); }

php - Why would json_encode return an empty string -

i have simple php structure 3 nested arrays. i not use particular objects , build myself arrays 2 nested loops. here sample of var_dump of array want convert json. array (size=2) 'tram b' => array (size=2) 0 => array (size=3) 'name' => string 'ile verte' (length=9) 'distance' => int 298 'stationid' => int 762 1 => array (size=3) 'name' => string 'la tronche hôpital' (length=18) 'distance' => int 425 'stationid' => int 771 16 => array (size=4) 0 => array (size=3) 'name' => string 'bastille' (length=8) 'distance' => int 531 'stationid' => int 397 1 => array (size=3) 'name' => string 'xavier jouvin' (length=13) 'distance' =&g

r - dplyr split string into a comma separated list -

i'm trying use dplyr split string comma separated string , i'm not having luck. dat<-data.frame(key=1:4,labels=c('a','ab','abc','b')) i'm trying labels column c('a','a,b','a,b,c','b') i've tried of below variations nothing seems work. dat %>% mutate(labels=str_split(labels,'')) dat %>% mutate(labels=str_split(labels,'')[[1]]) dat %>% mutate(labels=paste(str_split(labels,''),collapse=',')) dplyr or mutate has nothing question. problems more along lines of trying treat list (returned str_split ) vector. i write little function it: comma_sep = function(x) { x = strsplit(as.character(x), "") unlist(lapply(x, paste, collapse = ',')) } you can mutate(dat, labels = comma_sep(labels)) # key labels # 1 1 # 2 2 a,b # 3 3 a,b,c # 4 4 b but of course jam meat of function 1 line well.

php - How to throw custom exceptions in codeigniter? -

i want know how throw custom exception messages in codeigniter when situations following happen: connection database failed reason (i intentionally gave non-existent database name in application/config/database.php file test , tried try-catch on $this->db->get() did not work. codeigniter gave own error message) 2.a method fails execute. tried :: try { $this->model_name->myfunc();//myfunc non-existent method other reason failure should handled using custom message }catch(exception $e) { echo "method failed run"; } this did not worked too there many kind of exceptions, maybe you'll need catch example mysqli_sql_exception try{ // code connect db }catch(mysqli_sql_exception $e) { return 'custom message'; }

objective c - Making a conditional for table view buttonpress -

i have table view , don't know how access row number when user presses 1 of cells. data of table view small array , closest come... in ib, control dragged reusable cell view controller push works fine. unsure how row number in conditional this... - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { // bunch of stuff before this, not important question //-- > line if([indexpath row] == 1) doesn't work... ideas? { if(totalpoints < 10 && number != 0) { [self savenumber:@"1"]; } else if (totalpoints < 10 && attachment == 0) { [self savedata:@"1"]; int newpnts = totalpoints + 1; [self savepoints:[nsstring stringwithformat: @"%d", newpnts]]; } thanks it should work - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { nslog(@"%@",indexpath.row

arrays - Javascript unbind variables -

this question has answer here: how correctly clone javascript object? 51 answers i have following code copy variable value change value. var = [{name: 'john doe'}]; var b = a; document.write(b[0].name + '<br />'); document.write(a[0].name + '<br /><br />'); b[0].name = 'jane doe'; document.write(b[0].name + '<br />'); document.write(a[0].name + '<br />'); but somehow change first variable value how make variable keep value? you assigning a -reference b . may want copying array changes a not reflected b . see this thread different assignments in javascript. take @ fastest way duplicate array . it's speed of different array copy methods. quick answer is: var b = a.slice(); the slice() method creates new array same elements original one. caref

html - ul is applying styles but from where? -

i'm having trouble find reason why class named nav in ul element applying styles. i'm using nav element directly style (without using classes). gave ul element class named nav , applying styles (but where?). i had give ul margin: 0 , still have left padding , these styles coming from? i'm not experienced css , i'd appreciate help. this reproduced body { background-color: #fff; margin: 0; font-family: 'open sans', sans-serif; font-size: 14px; line-height: 1.42857143; color: #333; } /* header */ header { min-height: 750px; background: url(https://static.inmopaco.tk/images/banner2.jpg) no-repeat 0px 0px; background-size: cover; position: relative; } /* top bar menu */ .top-menu { background: rgba(78, 197, 241, 0.81); padding: 0.5em 0; } /* nav links */ nav { background: none; border: none; margin: 2.2em 0 0; float: left; padding-left: 5%; min-height: 50px; } nav:nth-child

Why would a specific comparison return records from a SQL Server Stored Proc but an IN clause containing the same value return nothing? -

i have 2 stored procedures identical except 2 things: (a) 1 works (returns records) , other doesn't (returns no records) (b) working 1 searches single match, whereas nonworking 1 casts wider net, including additional values in being sought the differences (besides sp names) between 2 stored procedures are: 1) working stored proc contains this: where upper(up.unit) = 'rock bottom' ...the nonworking stored proc contains this: where upper(up.unit) in ('chophouse', 'craftworks sc', 'gordon biersch', 'old chi franchise', 'old chicago', 'rock bottom') 2) where working stored proc contains this: where upper(up.unit) = 'rock bottom' , c.begindate <= @calendarenddate , c.enddate >= @calendarbegdate ...the nonworking stored proc contains this: where upper(mp.unit) in ('chophouse', 'craftworks sc', 'gordon biersch', 'old chi franchise', 'old chicago', '

python - Pygal - Click bar and post data? -

i trying create simple charting web app using pygal , flask chart financial data have stored in mysql database. data in db hierarchical, , want app start @ top of hierarchy , allow user drill down clicking on relevant parts of chart. i using flask display dynamically generated pygal charts. sample db data: guid | name | value | parentguid | description ------------------------------------------------ 1234 | cat1 | 1 | null | blah, blah 4567 | cat2 | 55 | null | asfdsa 8901 | cat3 | 22 | 1234 | asfdsa 5435 | cat4 | 3 | 8901 | afdsa etc... i have no problem drilling down hierarchy using python + sql, i'm stumped how drill down using links in pygal chart. @app.route('/', methods=['get', 'post']) def index(): if request.method == 'post': chart = graph_sub(request.form['guid']) return render_template('graph3.html', chart=chart) else: chart = graph_main()

user_image for desire2learn LTI provider -

i creating lti tool, not see user_image parameter being passed desire2learn/brightspace. how can retrieve this? brightspace not pass optional parameter in lti launches. can, however, use brightspace apis retrieve current, launching user's profile image . (one subtle point there, though: retrieving user's profile image requires (authorized) api call, can store api call retrieve url, however, you'll need wrap auth tokens when calling it.) d2l's reference topic on remote plugin service contains extended example showing how simple tool provider can use brightspace apis in conjunction lti launch

linux - How to delete the first subset of each set of column in a data file? -

i have data file more 40000 column. in header each column's name begins c1 , c2, ..., cn , each set of c has 1 or several subset example c1. has 2 subsets. need delete first column(subset) of each set of c. example if input looks : input: c1.20022 c1.31012 c2.44444 c2.87634 c2.22233 c3.00444 c3.44444 1 1 0 1 0 0 0 1 2 0 1 0 0 1 0 1 3 0 1 0 0 1 1 0 4 1 0 1 0 0 1 0 5 1 0 1 0 0 1 0 6 1 0 1 0 0 1 0 i need output like: c1.31012 c2.87634 c2.22233 c3.44444 1 0 0 0 1 2 1 0 1 1 3 1 0 1 0

ip - Getting number of IPv6 addresses from Ipv6 CIDR in PHP -

is there way number of ipv6 addresses ipv6 cidr? for example: cidr: 2403:3e00::/32 => need number of ipv6 addresses: 79228162514264337593543950336 an ipv6 address has 128 bits, of (slightly simplified) number dedicated network address, , rest dedicated host addresses. in case, 32 bits dedicated network part ( /32 ), other 96 dedicated host addresses. 2^(128-32) = 2^96 = 79228162514264337593543950336 hosts

c++ - how to wrap an external library in a conan package, adding support for building as a shared library -

i attempting wrap google's gumbo parser conan package. have succeed supporting linux mac , windows, having issues creating (and consuming) shared library in windows (.dll + .lib). my current progress here . have decided bypass gumbo's autoconf build system provide cmakelists.txt copy when fetching sources. way hoped able support windows. i not familiar visual c++, understand visual c++ different other compilers in not export symbols default, gcc , clang export everything. this causing conan package fail build in scenarios, because in shared mode generating .dll (and no corresponding .lib). tried using cmake's generate_export_header module, did little help, since i'd have use macros generated in methods should exported. i'm trying wrap library without having fork , adapt it. another option use .def file . might work in case (not many symbols export), not helpful me (harder test if exported should have, harder maintain, not helpful solving same issue in

html - Web scraping using excel VBA -

i looking @ html code link below: <h1 class="wer wer"> <a href="http://somelink.com" rel="bookmark" title="permanent link title of page covers random topic"> short title of page...</a> </h1> i using below code pull out innertext ("short title of page...") for each ele in .document.all select case ele.classname case "wer wer" rowcount = rowcount + 1 sht.range("a" & rowcount) = ele.innertext end select next ele how can modify code pull out title ("permanent link title of page covers random topic") , href (" http://somelink.com ")? any appreciated. thanks.

algorithm - How does SVM work? -

is possible provide high-level, specific explanation of how svm algorithms work? high-level mean not need dig specifics of different types of svm, parameters, none of that. specific mean answer explains algebra, versus solely geometric interpretation. understand find decision boundary separates data points training set 2 pre-labeled categories. understand seek finding widest possible gap between categories , drawing separation boundary through it. know how makes determination. not looking code, rather explanation of calculations performed , logic. know has orthogonality, specific steps "fuzzy" everywhere find explanation. here's video covers 1 seminal algorithm quite nicely. big revelations me (1) optimize square of critical metric, giving value that's positive, minimizing square (still differentiable) gives optimum; (2) using simple, not-quite-obvious "kernel trick" make vector classifications compute easily. watch @ how unwanted terms d

swift - Integer value not updating -

i creating game , trying keep record of enemy's killed sklabel node not updating. here's how i'm implementing class gamescene: skscene, skphysicscontactdelegate { var enemy1killcounter:int = 0 var enemy1killcounterlabel = sklabelnode () override func didmovetoview(view: skview) { createenemykilledlabel() } func createenemykilledlabel() { enemy1killcounterlabel.text = "\(enemy1killcounter)" enemy1killcounterlabel.fontsize = 65 enemy1killcounterlabel.fontcolor = skcolor .blackcolor() enemy1killcounterlabel.position = cgpointmake(400, 400) self.addchild(enemy1killcounterlabel) } func updateenemy1killcounter() { enemy1killcounter = enemy1killcounter + 1 print(enemy1killcounter) } // use next method because call method in enemy class when enemy "killed" func enemy1dieg () { updateenemy1killcounter() } does know why label not being updated? when update enemy1killcounter , need upd

jquery - Javascript :not selector not working -

i have javascript / jquery wraps every 2 <td> elements <div class="table-half"> , state in variable not want take effect if table has #profilecontent parent. var divs = $("div:not('#profilecontent') table.form tr td"); for(var = 0; < divs.length; i+=2) { divs.slice(i, i+2).wrapall("<div class='table-half'></div>"); } however, reason wrapping still takes place html in structure: <div id='profilecontent'> <table width="100%" class="form"> <tr> <td></td> <td></td> </tr> </table> </div> any ideas why? the reason it's not working because table nested in multiple levels of div, , selector written match table that's descendant of div. parent matches id, :not excludes it, grandparent not have id, it's it's not excluded. instead of putting :not

user interface - Load webpage in Python GUI window -

i've searched on google , stackoverflow having trouble finding answer, though seems should easy do. how can use python load url own window, rather in browser? imagine should trivial in tkinter or other gui package. yeah. that's easy qwebview in pyqt/pyside you instantiate new qwebview , pass url it qwebview.load(qurl('http://www.www.pythoncentral.io')) you can read more here http://pythoncentral.io/pyside-pyqt-tutorial-qwebview/ and in pyqt docs http://pyqt.sourceforge.net/docs/pyqt4/qwebview.html

parsing - FParsec only parses expr between parentheses -

i coding parser (for learning pourpuses). i want parse constructions like let myvar 40 plus 2 and let myvar (40 plus 2) with no problems... parser not "understand" former. sees 40 , thinks "well, it's literal numeric 40 ". when put parentheses, parser works great. i having hard time understand why. parser: type value = | boolean of bool | numeric of float | string of string type arithmetic = sum | sub | mul | div | pow type logic = , | or | equal | notequal | greater | smaller type identifier = | identifier of string type expression = | literal of value | arithmetic of expression * arithmetic * expression | negative of expression | negation of expression | logic of expression * logic * expression | variable of identifier type statement = | assignment of identifier * expression | print of expression | read of identifier let private ws = spaces let private str s = pstring s .>>

objective c - Filtering Mutable Array using NSPredicate -

Image
i have mutablearray 6 sub arrays , many subarrays within each subarray each array contains details of station......(there 146 arrays altogether) my goal filter array "name", @ same time want extract remaining details too. i'm trying using predicate method failing. my searchresults array should having filtered arrays details of station on bases of "name". can me in achieving this? in advance. -(void)filtercontentforsearchtext:(nsstring *)searchtext{ nspredicate *resultpredicate = [nspredicate predicatewithformat:@"any name contains[cd] %@",searchtext]; _searchresults = [ _stationsarray filteredarrayusingpredicate:resultpredicate]; } - (bool)searchdisplaycontroller:(uisearchdisplaycontroller *)controller shouldreloadtableforsearchstring:(nullable nsstring *)searchstring{ [self filtercontentforsearchtext:searchstring]; return yes; } can try this!!! #import <foundation/foundation.h> @interface stationdetail : ns

xml - XSLT copy - make 2 nodes from 1 node -

i have following xml: <records> <record> <id>111</id> <amount>123.45</amount> <taxcode>a</taxcode> </record> </records> i need copy nodes in above create additional copy of of nodes have value of, lets say, taxcode. how achive following: <records> <record> <id>111</id> <amount>123.45</amount> <taxcode>a</taxcode> </record> <!-- copy of node above amount , taxcode changed --> <record> <id>111</id> <amount>-123.45</amount> <taxcode>b</taxcode> </record> </records> i tried using following simple xsl copies once: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl=

Using for loop for statistics by data frame column in R. -

i have been trying make loop takes vector of column names want use , loop statistical tests column determines group of sample. here how looks now. sink('df_statistics.txt') df <- `df.tsv` columns <- c("column1" , "column2" , "column3" , "column4") (x in columns) { wilcox.test(formula = x ~ group, data = df) } sink() when run error: error in model.frame.default(formula = data ~ group, data = df) : variable lengths differ (found 'group') my groups determined numbers 1 , 2, tried naming them control , experimental keep getting same error above. suggestions? thank you we can use lapply lapply(df[columns], function(x) wilcox.test(x~df$group)) data columns <- c("column1" , "column2") set.seed(24) df <- data.frame(group = rep(1:2, each=5), column1 = rnorm(10), column2 = rnorm(10))

c++11 - Why implicit conversion is occurring in "if expression" although it should be explicit conversion -

this code not supposed compile , why ? principle of context in if expression ? class b { public: b() {} explicit operator bool () {} }; int main (){ b bp; //bool check = bp // error if (bp){ //o.k return 1; } return 0; } thanks that code supposed compile. standard expended great deal of effort ensure does. there number of places expression "contextually converted bool" in places, explicit bool conversions called if they're available. 1 of contextual conversions if expression, in case. this language allows explicit operator bool types still used conditional checking if(expr) , can't other things without explicit conversion. can't pass function takes bool ; can't return function returns bool , , forth. all of contextual conversions explicit expressions in language features. explicit operator bool protects implicit user-defined conversions, while still allowing language-defi

multithreading - Scala Play thread -

i'm using scala / play2 framework / mongodb (reactivemongo) have function in request doing : find maximum value in collection, increase maximum number random, , save new value collection, , return new value. def generatecode():future[string] = { // find maximum maximum = future[].... map { maxvalue => // increase maxvalue newvalue = maxvalue + random // save database } } the problem want code 1 thread run @ time. because if 2 thread run same time, value con conflicted. example: thread 1: read max = 100, thread 2 read max = 100 thread 1: increase max = 105, thread 2 increase max = 102 thread 1: save 105 db, thread 2 save 102 db finally maximum in db 102, in should 105. how can ? as rule reactivemongo api , operations on future require implicit executioncontext in scope. can define single threaded execution context , use in class defined generatecode() method , in class call reactivemongo api. import java.util.concurrent.executors imp