Posts

Showing posts from August, 2013

c# - Set date to tbd if it is a specific date -

i tried looking around site see if question has been asked before, can't seem find it. using mvc , have controller page reads data sqlserver database display them in view contains jqgrid. my question how take specific datetime value, "1900-01-01 00:00:00.00" , have displayed tbd? this code 2 datetime columns: schedule.estimatedqastartdate = (!reader.isdbnull(4)) ? reader.getdatetime(4) : (datetime?)null; schedule.estimatedorprojectedreleasedate = (!reader.isdbnull(5)) ? reader.getdatetime(5) : (datetime?)null; the jqgrid solution have formatter date column follows here jsfiddle sample created you. function formatdate(cellvalue, options, rowobject) { if(cellvalue=="1900-01-01 00:00:00.00") return "tbd"; else return cellvalue; }; "use strict"; var mydata = [ {id:"1", docgroupname: "2", date: ...

angular - Error loading http://localhost:4200/app/subjects.component.js as "./subjects.component" from http://localhost:4200/app/app.routes.js -

what possible meaning of these errors? uncaught referenceerror: require not defined get http://localhost:4200/traceur 404 (not found) potentially unhandled rejection [5] error: xhr error (404 not found) loading http://localhost:4200/traceur @ xmlhttprequest.wrapfn [as _onreadystatechange] ( http://localhost:4200/vendor/zone.js/dist/zone.js:769:30 ) @ zonedelegate.invoketask ( http://localhost:4200/vendor/zone.js/dist/zone.js:356:38 ) @ zone.runtask ( http://localhost:4200/vendor/zone.js/dist/zone.js:256:48 ) @ xmlhttprequest.zonetask.invoke ( http://localhost:4200/vendor/zone.js/dist/zone.js:423:34 ) error loading http://localhost:4200/traceur error loading http://localhost:4200/app/subjects.component.js "./subjects.component" http://localhost:4200/app/app.routes.js here's index.html: <!doctype html> <html> <head> <meta charset="utf-8"> <title>material2app</title> ...

ruby on rails - Create new instance of Campaign in every iteration -

i working on functionality whereby table displayed records, each radio buttons reject , approve. user selects appropriate radio button , presses process. control passed process_campaigns. here breaks down data , analyses each record's status. if approved redirects approve block , same reject. the following parameters passed: parameters: {"utf8"=>"✓", "authenticity_token"=>"9tcexvcmdahawgqlopdarksowbbaxzgwznra8sbnkwm=", "campaign"=>{"2"=>{"start_date"=>"2016-07-18 15:43:00", "end_date"=>"2016-10-15 12:20:00", "merchant_revenue"=>"10", "status"=>"approved", "notes"=>""}, "1"=>{"start_date"=>"2016-07-15 12:20:00", "end_date"=>"", "merchant_revenue"=>"10", "status"=>"approved", "notes...

javascript - Why can I get console.log(variable) to give my value but not return variable? -

in code i'm loading data json using d3.json - , in order working call function once data loaded , pass json across there processing. seems working, still refuses return "undefined". my code: function getdatafromjson() { var jsondata; d3.json("http://localhost:8000/pipeline.json", function(datafromserver){ jsondata = datafromserver; newvalue(jsondata); }); } and function newvalue(data){ var jsondata = data; headers = ["won"]; var mytotal = 0; chunks = (headers.map(function(pricerange) { return jsondata.map(function(d) { return {y: +d[pricerange]}; }); })); var mytarget = 10000000; chunks.foreach( function (arrayitem) { var l = 12; for(var = 0; < l; i++) { mytotal += arrayitem[i].y; }; }); mytotal = mytotal/mytarget*100; return mytotal; } i'm running in f...

here api - Can't calculate isoline for bicycle transport mode -

i evaluating here , trying calculate isoline bicycle, keep receiving error response, follows: { "_type": "ns2:routingserviceerrortype", "type": "applicationerror", "subtype": "invalidinputdata", "details": "isoline 'bicycle' transport mode not supported", "additionaldata": [ { "key": "mode", "value": "fastest;bicycle;traffic:disabled" } ], "metainfo": { "timestamp": "2016-07-25t13:58:35z", "mapversion": "8.30.62.159", "moduleversion": "7.2.71.0-39010", "interfaceversion": "2.6.25" } } request details: https://isoline.route.cit.api.here.com/routing/7.2/calculateisoline.json?app_id=<my_app_id>&app_code=<my_app_code>&mode=fastest;bicycle;traffic:disabled&rangetype=time&start=g...

jquery - Jqgrid Formatting for lengthy text -

Image
how take text long, , shorten within jquery grid, allowing user click on text, or icon display rest of text within popup window? attached picture shows happens, , do. looking learn this, not answer, documentation, examples, etc. thanks!

c++ - Preprocessor to count number of strings in file -

i wanted have macro (or else works) can go through c/c++ file, , count number of occurrences of specific string (in physical c/c++ file). #define numinfile(str) [???] int main() { printf("blahblah"); printf("you've used printf %d times", numinfile ("printf") - 2); //-2 account call return 0; } edit: question specific using functionality exit calls. generalize use. if understand correctly, want have unique error codes, can trace line error happened? i address y question instead of x one : you can use __line__ . __line__ expands integer constant of current line number. #define quit as: #define quit(code) (quit)(__line__+(code)) void (quit)(code) { // seperate func in case want more exit(code); } keep in mind though exit code of process not best way encode such information. on posix, lower 8 bit of exit code guaranteed available. use 300 base value, assume on windows or other system isn't concern. for deb...

python - The Concept Behind itertools's product Function -

so want understand concept of product() function in itertools. mean different between yield , return. , can code shorten down anyway. def product1(*args, **kwds): pools = map(tuple, args) * kwds.get('repeat', 1) n = len(pools) if n == 0: yield () return if any(len(pool) == 0 pool in pools): return indices = [0] * n yield tuple(pool[i] pool, in zip(pools, indices)) while 1: in reversed(range(n)): # right left if indices[i] == len(pools[i]) - 1: continue indices[i] += 1 j in range(i+1, n): indices[j] = 0 yield tuple(pool[i] pool, in zip(pools, indices)) break else: return this code should work: bytes = [i in range(2**(n))] ab= [] obj in bytes: t = str(bin(obj))[2:] t= '0'*(n-len(t)) + t ab.a...

VBA referencing next cell in For loop -

i need compare cell 1 below in loop. know languages can "if cells(i,1).value = cells(i+1,1).value then..." is there way in vba reason isn't working me. thanks for = 7 ltrw if (cells(i, 1).value = 0 , cells(i + 1, 1).value = 0 cells(i, 1).entirerow.hidden = true end if next like ? for = 7 ltrw if cells(i).value = cells(i + 1).value ' can skip ", 1" optional cells(i).entirerow.hidden = true end if next

wordpress - WP Query Multiple Shortcodes not working on same page or template page -

i created shortcode slider gets ids of different pages , show display slider. shordcode works fine issue whenever copy past shortcode multiple times on same page/ template page shows first one. issue occurs only when past same type of shortcode if past other shortcode on same page works fine. here code add_shortcode( 'objectx-pages-list', 'objectx_pages_list_func' ); function objectx_pages_list_func( $atts ) { global $post; ob_start(); extract( shortcode_atts( array('ids' => '1186'), $atts ) ); $id_array = explode(',', $ids); $pages_query = new wp_query( array( 'post_type' => 'page', 'post__in' => $id_array, 'order' => 'asc', 'orderby' => 'title', ) ); if ( $pages_query->have_posts() ) { ?> <div class="carousel-wrapper"> <div class="owl-carousel owl-theme carousel-1" id="carousel-rooms"> <?php while ( ...

servlets - How to execute code after response in JavaEE -

i tried, unsuccessfully, find way run code after response. in case, server sends me data in order let me job action can long (send sms 5000 contacts , check received it, example). server expects http 204 no content response sure data has been received. webapp performs action , send status on rest api. my problem is: how send response , execute code ? for tried: dofilter asynccontext executorservice in each case, in order test if connection closing before end of action, call external url takes 10s on purpose answer. each time, server takes 10s answer. my servlet hanging on, waiting end of code. i unable make code works executors (new this), if got error during execution of thread, want send http 204 , handle error on hand. is there easy way ? i use background threads poll queue tables things don't have done before response sent , take longer 0.1 seconds. example, email sender thread handles sending emails in response user's action, "thanks ...

bash - C++ system() causes "Text file busy" error -

i need execute multiple times fortran program, requires user insert 4 numeric values each time. found solution make automatically python script...this script creates @ each iteration .sh file containing following lines (a.out name of fortran program have execute automatically) ./a.out<<eof param01 param02 param03 param04 eof makes executable, , executes it. so, i'm trying same in c++...i wrote like int main() { long double mass[3] = {1.e+10,3.16e+10,1.0e+11}; double tau[3] = {0.5,0.424,0.4}; double nu[3] = {03.0,4.682,10.0}; long double reff[3] = {1.0e+3,1.481e+3,3.0e+3}; int temp=0; (int i=0; i<3; i++) { ofstream outfile("shcommand.sh"); outfile << "./a.out<<eof" << endl << mass[i] << endl << nu[i] << endl << reff[i] << endl << tau[i] << endl << "eof" << endl; temp=system("chmod +x shcommand.sh"); temp=system("./shc...

bash - stat command using sftp (mtime) -

i'm trying write bash script, automates finding reports being uploaded ftp site. want use mtime ( stat -c %y <file> ) in if statement test against static time parameter further processing. there analogous command while using sftp? 'stat ' doesn't work, nor 'sftp stat ', both returning 'invalid command'. thanks with openssh sftp , closest can ls -l /remote/path/to/file if have shell access, use ssh instead: ssh user@example.com stat /remote/path/to/file

sql server - SQL need to insert into table which only consists of a primary key but no auto increment -

i need insert value table consists of 1 column, is, primary key . furthermore, null not allowed, identity set false , both identity seed , identity increment set 0 . i try insert insert table(id) values (null) not work. insert table(id) default values not work. how can fill column correctly incremented id? implementing identity or sequence best solution, if cannot alter schema alternative lock table in transaction, create new value, unlock table. note can have performance consequences. create table dbo.ids ( id int primary key clustered ); go insert dbo.ids values ( 1 ), ( 2 ), ( 3 ), ( 4 ) ; go declare @newid int; begin transaction set @newid = ( select top( 1 ) id dbo.ids ( tablockx, holdlock ) order id desc ) + 1 ; insert dbo.ids values ( @newid ); select @newid; commit go 20

javascript - How is this ES6 function declaration valid? -

how function declaration valid in es6? mean? i've found in source code of react native project. 'use strict'; import react, { component } 'react'; // more imports... function setup():react.component { class root extends component { // constructor , render functions... } return root } export default setup; i have removed few lines not important see issue. i not find related es6 or javascript regarding function declaration followed colon. that code typed flow , facebook's static type checker (akin typescript). it's not valid es6, it's superset of es6 syntax.

How to run a MYSQL script using a password from a command line? -

when try connect remote mysql database through command line works fine despite warning: /sdzf => mysql -h db3 -u auser -ppassword db_6 -a warning: using password on command line interface can insecure. however, running script not work /sdzf => mysql -h db3 -u auser -ppassword db_6 -a< findrec.sql warning: using password on command line interface can insecure. error 1045 (28000) @ line 1: access denied user 'auser'@'50.206.86.74' (using password: yes) despite login statement included database name still needed point database first in sql script when running in batch mode: use db_6; if login first using same script "mysql -h db3 -u auser -ppassword db_6 -a" not need point database in sql.

add offset to multiple columns in gnuplot -

i trying plot multiple column file first column x , rest should y columns this: plot for[col=2:36:1] 'datafile' using 1:col lines lc rgb 'black' notitle this works fine want offset y columns constant value. i tried this: plot for[col=2:36:1] 'datafile' using 1:(col-const) lines lc rgb 'black' notitle but doesn't work (it seems plot difference between variable col , constant value const). is there way this? have found here how offset y column 2 column file (or specific column in file) plot 'otherdatafile' using 1:($2-const) lines but can expanded case? thanks in advance, lucian using 1:(column(col)-const) should work

pyspark - Applying User Function to Entire Spark DataFrame column -

spark dataframe schema: in [177]: testtbl.printschema() root |-- date: long (nullable = true) |-- close: double (nullable = true) |-- volume: double (nullable = true) i wish apply scalar-valued function column of testtbl . suppose wish calculate average of 'close' column. rdd rdd.fold(0, lambda x,y: x+y) but testtbl.close not rdd,, column object limited functionality. rows of testtbl rdds, columns not. how apply add , or user function single column? if want apply function entire column, have execute aggregation operation column. for instance imagine want compute sum of values in column values . though, df not aggregated data, valid apply aggregated functions dataframes . from pyspark.sql.functions import * df = sc.parallelize([(1,), (2,), (3,)]).todf(["values"]) df.agg(sum("values").alias("sum")).show() +---+ |sum| +---+ | 6| +---+ you can find example in pyspark's aggregation documentation . for second p...

asp.net - Data-bound RadioButtonList binding but now showing up in GridView -

i have gridview control column containing data-bound radiobuttonlist. rbl binding datatable not showing in gridview. adding listitems in markup show, , label control showing - did these 2 test. see i'm missing? tia assistance. mike markup: <asp:templatefield headertext="preset text" headerstyle-horizontalalign="center"> <itemtemplate> <asp:radiobuttonlist id="rblpresettext" runat="server" datavaluefield="pkey" datatextfield="contents" groupname="presettext" repeatdirection="vertical"></asp:radiobuttonlist> </itemtemplate> </asp:templatefield> codebehind: protected sub page_load(sender object, e system.eventargs) handles me.load globalvar.loaddata(session("userpkey")) header1.connectionstr = globalvar.connectstring header1.hdlawfirm = globalvar.lawfirmdir if page.ispostback = false ...

php - Two tables not being accessed one after the other with mysqli -

i trying first insert values tripdetails table , take values tripdetails , insert them tripmembers table. the code follows: $query="insert tripdetails values('','$date','$time','$number','$destination','$status','$id')"; $result=mysqli_query($conn,$query); $query="insert tripmembers(tripid,id) select max(tripid),id tripdetails"; $result=mysqli_query($conn,$result); values being inserted tripdetails no such effect on tripmembers . please help.

python - Biopython/EMBOSS WindowsError [Error 2] -

i trying locally align set of around 100, long (>8000 sequence) sequences using biopython wrapper emboss. essentially need locally align each sequence in fasta file against every other sequence in fasta file. far have tried run basic code below: from bio.emboss.applications import needlecommandline bio import alignio seq_fname1 = 'gross-alignment.fasta' seq_fname2 = 'gross-alignment.fasta' needle_fname = 'pairwise_output.txt' needle_cli = needlecommandline(asequence=seq_fname1, \ bsequence=seq_fname2, \ gapopen=10, \ gapextend=0.5, \ outfile=needle_fname) """this generates needle file""" needle_cli() """that parses needle file, aln[0] , aln[1] contain aligned first , second sequence in usual format (e.g. - gap)""" aln = alignio.read(needle_file, "emboss") p...

making scorecard with data pulled from flat files more dynamic in excel-VBA -

Image
i made sports data none of accurate or remotely right sake of real data using. (sorry it's long explanation) overview: picture of scorecard working on reports on various metrics related sports data. starts scoring of overall category of sports , scoring breakdown of each sport. can call "sports" parent category , ones right child categories. how data read in: example, games won sub looks through games won column in separate flat file (games won) of data "g t 50 ga" (greater 50 games). looks through category column make sure it's sports category, , goes athlete name find won games. macro writes if athlete, , won more 50 games, add athlete's sport denominator , numerator, else didn't win 50 games add denominator. however, flat files don't contain specific sport each athlete name goes why has outlined in macros tedious , seems unnecessary. heres flat file: what i'd able do: have created reference file pictured above here has each ...

c# - Show collection of groupdescription from a list as source -

Image
sorry misleading title. anyway i'll try explain better. want show collection within collections in listview. display should use expanders show inner collection items. items should appear in appropriate columns. did this: xaml <collectionviewsource x:key="groupeditems" source="{binding countries}"> <collectionviewsource.groupdescriptions> <propertygroupdescription propertyname="name"/> </collectionviewsource.groupdescriptions> </collectionviewsource> ... <listview itemssource="{binding source={staticresource groupeditems}}" name="playing"> <listview.view> <gridview> <gridviewcolumn header="country" width="150" displaymemberbinding="{binding source={x:static sys:string.empty}}" /> <gridviewcolumn header="leagues"> <gridviewcolumn.celltemplate...

javascript - Issue with logging not working correctly when using retries in Mocha -

i have use case i'm testing on our network, , network takes little longer usual , test ends checking early. ideally, able set test retry this.retries(1). when that, indeed retry , works; however, breaks logging. i'm running lot of tests, , if don't use retry function logging each suite gets split appropriately. if test gets retried, stops splitting logs , located under 1 test suite. have no idea why , haven't been able find similar reports. appreciated. instead of retrying can try timeouts because made this. this may resolve issue timeouts make mocha wait more time before setting test failed doesn't change logs.

javascript - How to prevent redirection that occurs when pressing enter key in an input field? -

i have form input email. <form action="." method="post"> <div id="email-wrapper"> <input type="text" placeholder="your email" name="email" ref="email" onchange={this.handlechange}/> </div> <span class="signup-error">please provide valid email.</span> </form> .... .... <button id="next-btn" onclick={this.saveandcontinue}>next</button> when button pressed validate simple regex confirm email address, , working fine. however, if press enter ( key=13 ), directs someother page , error see: cannot post / i thought script handle problem, didn't: handlechange = (event) => { event.preventdefault(); var keycode = event.keycode || event.which; if (keycode == '13'){ console.log('enter pressed'); } } what's going on? how can prevent redirection occurs when press enter ...

php - WordPress upload image and media via XMLRPC -

i want upload media , images wordpress site via xml-rpc used code pupose: $filename = 'sample.jpg'; $mime = 'images/jpeg'; $data = file_get_contents($filename); var_dump($wpclient->uploadfile($filename, $mime, $data, false)); the file uploads media , output that: array(13) { ["attachment_id"]=> string(4) "7430" ["date_created_gmt"]=> object(stdclass)#3 (3) { ["scalar"]=> string(17) "20160727t19:57:29" ["xmlrpc_type"]=> string(8) "datetime" ["timestamp"]=> int(1469649449) } ["parent"]=> int(0) ["link"]=> string(56) "http://url.com/wp-content/uploads/2016/07/sample.jpg" ["title"]=> string(10) "sample.jpg" ["caption"]=> string(0) "" ["description"]=> string(0) "" ["metadata"]=> string(0) "...

android - Text input in SearchView doesn't show -

Image
i noticed couple days ago inputting text in searchview doesn't show up. maybe problem started longer ago , hadn't noticed it, know working when first set search functionality. here screenshot (i have entered text, , can see not showing): i have tried change colour of text on searchview , this question , , i've tried changing text colour in searchable configuration xml file. after found none of these work, undid changes can see code have below: mainactivity.java @override public boolean oncreateoptionsmenu(menu) { ... // associate searchable configuration searchview searchmanager searchmanager = (searchmanager) getsystemservice(search_service); menuitem searchmenuitem = menu.finditem(r.id.action_search); searchview searchview = (searchview) searchmenuitem.getactionview(); searchview.setsearchableinfo(searchmanager.getsearchableinfo(new componentname(this, searchresultsactivity.class))); // note: getsearchableinfo(getcomponentname...

java - Item doesn't store in ArrayList with different XML structure -

currently i'm doing exercise on processing xml , storing arraylist, work when i'm using this xml. when switch this xml, data not stored in arraylist. have done output testing , seems data did not pass here feeditems.add(new feeditem(title,date)); . hope can explain me going on code , how can fix issue. mainactivity.java new readrss(mainactivity.this, listview, "http://www.thestar.com.my/rss/editors-choice/main/").execute(); readrss.java public void parsexmlandstoreit(xmlpullparser myparser) { int event; string text; string title = null; string date = null; feeditems = new arraylist<feeditem>(); try { event = myparser.geteventtype(); while (event != xmlpullparser.end_document) { string tagname = myparser.getname(); switch (event){ case xmlpullparser.start_tag: if(tagname.equalsignorecase("item")){ int eventchi...

ruby on rails - Abide Required tag in simple-form without "data-" -

with foundation 6 , abide want have tag in simple-form form: <input class="string optional" pattern="text" type="text" name="service[street_address]" id="service_street_address" required> with required attribute. i tried this: <%= service.input_field :street_address, data: {:required => ''}, pattern:"text" %> but the required tag becomes data-required , breaks abide validation: <input data-required="" class="string optional" pattern="text" type="text" name="service[street_address]" id="service_street_address"> is there way have required or required="" ? if required: true doesn't work, try: <%= service.text_field :postal_box, required: "required", pattern: "text" %>