Posts

Showing posts from January, 2015

Rails use ruby in link_to -

instead of hard coding link description, use ruby code. this original: <li><%= link_to "open projects list", workorders_index2_path %></li> this didn't work me: <li><%= link_to "<%= current_tenant.name_workorder.capitalize.pluralize %>", workorders_index2_path %></li> thanks help! you don't need use quotes @ all: <li><%= link_to current_tenant.name_workorder.capitalize.pluralize, workorders_index2_path %></li>

javascript - NVD3 Sparkline not rendering correctly from CSV file -

i'm trying use nvd3 d3.js make simple sparkline. i've created several sparklines .csv data, when tried use different data set, gave strange looking sparkline. see here . if change first data value 92 0, shows sparkline. is bug in nvd3 or doing wrong? the problem y values strings. changed monthlydata.push({x: data[i].month, y: data[i].data}); to monthlydata.push({x: data[i].month, y: +data[i].data}); so y value becomes number. here's the updated version .

symfony - Twig - Bubbling inline scripts from included subtemplates to javascripts block -

i'd include widget in different pages , have related scripts, defined in sub-template, happened automatically @ end of page other scripts without having several includes. i tried use block in included sub-template , add script in block defined in base.html.twig scripts load @ end of page. in base.html.twig have <html><body> <div>{% block content %}{% endblock %}</div> <aside>{% block aside %}{% endblock %}</aside> ... {% block javascripts %} <script src="..."></script> <script src="..."></script> ... {% endblock %} {% block widgetinlinescript %}{% endblock %} </body></html> i have template profile.html.twig extends base.html.twig , looks {% extends '::base.html.twig' %} {% block content %} ... {% endblock %} {% block aside %}{% include 'applicationrcbundle:include:promo/adspace_topright.html.twig' %}{% endblock %}

c# - System.ArgumentException: The table type parameter must have a valid type name -

i trying pass in user defined table type query in c#. the type defined 2 columns (org , sub org) this code looks like: dataset ds = new dataset(); try { datatable filteredorgsuborg = new datatable("orgsuborgvaluetype"); filteredorgsuborg.columns.add("org", typeof(string)); filteredorgsuborg.columns.add("suborg", typeof(string)); filteredorgsuborg.rows.add(org, orgsub); using (sqlconnection conn = new sqlconnection(ccon.getconn())) { using (sqlcommand cmd = conn.createcommand()) { cmd.commandtext = "select * mytable ex year = @year' , qtr = @qtr" + " , exists(select 1 @orgsuborg tt ex.org tt.org" + " , ex.orgsub = tt.suborg )"+ " order ex.org,year, qtr desc"; // 2. set command object knows // execute stored procedure // 3. add parameter command,

regex - c# regular expression pattern -

[code]> 10 /td>[/code] i want 10 line. need preserve pattern. how can write expression gets: , newline, ignorewhitespace or included indeterminate spaces, 10, ignorewhitespace or included space, /td thanks, joe k. ok, i'll nice , time. =) i assumed number looking can change. var result = regex.match( "[code]> 101 /td>[/code]", @"(?<=\>\s*)\d+(?=\s*/td\>)").value; but please, try doing next time... i'll point tool in designing , learning regex: http://www.radsoftware.com.au/regexdesigner/

How can I use the task scheduler to run Excel Macro w. Windows 7? -

i know there other posts similar cannot seem work. want create .vbs file use scheduler kick off macro in excel on monthly basis. here have been trying: option explicit dim xlapp dim xlbook set xlapp = createobject("excel.application") set xlbook = xlapp.workbooks.open("c:\test\test.xlsm", 0, true) xlapp.run "macro1" xlbook.close xlapp.quit set xlbook = nothing set xlapp = nothing wscript.quit i warning message every time saying test.xlsm exists , want overwrite it. when click yes, changes never take effect. i don't want message @ all, , don't know why changes macro not occurring. i've tried use xlapp.saveas and cannot work either. plus workbook appears not closing correctly. thanks in advance, new maybe missing stupid.

timer - How to calculate time in android .? -

i want calculate time after button pressed ,so can keep track has been passed.i have search , find android timer can couldn't useful answer that. thanks in advance. on start button press: long start = system.currenttimemillis(); on update/end button press: long runtime = system.currenttimemillis() - start;

sql server - Using Ubuntu, how do I install DBD::Sybase from CPAN? -

whenever try build dbd::sybase connect mssql error, $ sudo cpanp install dbd::sybase installing dbd::sybase (1.15) running [/usr/bin/perl /usr/bin/cpanp-run-perl /home/ecarroll/.cpanplus/5.14.2/build/dbd-sybase-1.15/makefile.pl installdirs=site]... can't find sybase libraries in /etc/lib or /etc/lib64 @ /home/ecarroll/.cpanplus/5.14.2/build/dbd-sybase-1.15/makefile.pl line 155, <in> line 44. begin failed--compilation aborted @ /usr/bin/cpanp-run-perl line 11, <in> line 44. [error] not run '/usr/bin/perl makefile.pl': can't find sybase libraries in /etc/lib or /etc/lib64 @ /home/ecarroll/.cpanplus/5.14.2/build/dbd-sybase-1.15/makefile.pl line 155, <in> line 44. begin failed--compilation aborted @ /usr/bin/cpanp-run-perl line 11, <in> line 44. -- cannot continue [error] unable create new distribution object 'dbd::sybase' -- cannot continue *** install log written to: /home/ecarroll/.cpanplus/install-logs/dbd-sybase-1.15-137460

CSRF Struts 1.3 saveToken/isTokenValid BACK BUTTON -

i using savetoken / istokenvalid in old struts application. have been able implement savetoken , istokenvalid attributes prevent csrf attack, if press button try submit same form hit error. possible in struts prevent csrf attack using these utilities allow ability go , resubmit form? i on thinking csrf , resetting token on each page, means old tokens invalid. instead save token once , reset needs be.

theory - Complexity of bin packing with defined function of bin weight -

i'm struggling following problem: given n integers, place them m bins, total sum in bins minimized. trick once numbers placed in bin, total weight/cost/sum of bin computed in non-standard way: weight_of_bin = sigma - k * x sigma sum of integers in bin k number of integers in bin x number of prime divisors integers located in bin have in common. in other words, grouping numbers have many prime divisors in common, , placing different quantities of numbers in different bins, can achieve "savings" in total sum. i use bin-packing formulation because suspect problem nphard have trouble finding proof. not number theory person , confused fact weight of bin depends on items in bin. are there hardness results type of problem? p.s. know numbers integers. there no explicit limit on largest integer involved in problem. thanks pointers can give. this not complete answer, gives things think about. first, way of clarification: know prime divisors of i

php - Serving up a static image in IE results in Quirks Mode -

following approach mentioned here can serve png, gif, or whatever images want since don't have control on <!doctype> of page (that know of) ie9 (and presumably others) decide "document mode" "quirks" default. ie displays image (just slight shadow around edge of document provides clue of problem) maybe should content , disregard dreaded quirks mode status given page created in way. my approach similar 1 in above answer: # other processing not output / echoed # <-- can else sent here calm ie down? header('content-type: image/png'); readfile($imagepath); this approach results in html document looks according ie's developer tools: <html> <head> <title></title> <body> <img src="theurlofthepage" /> is there way tweak doctype (or lack thereof) without getting in way of header sent nor image want output? attempts pass doctype @ various stages of above process

asp.net - The Web site {site name} does not exist -

so have taken on asp site. i have copied solution directory local machine. when go open solution, 9 out of 10 of projects open fine except web project. the following error in out put window error : unable open web site 'c:\users\john.smith\documents\visual studio 2010\websites\xxx'. 'the web site c:\users\john.smith\documents\visual studio 2010\websites\xxx' not exist. should case? should source sode need refer websites directory? thanks! in earler visual studio versions web sites have been split 2 directories. need copy second directory well, yes.

What does this bool operator actually do in C++? And how does this weird thing can be useful? -

when read c++ book encountered strange operator !(): class myclass { public: bool operator !() const {}//what it?? }; can explain me purpose please. that ill-formed program, taken operator! declared return bool not return anything. being fixed, negation operator , can called on object prefixing ! . myclass c; !c; // c.operator!()

java - string manipulation : insert words at certain indexes in string, simultaneously -

i have searched lot couldn't find allow me insert words @ indexes simultaneously. example : have string : rock climbing fun, love rock climbing. i have hashmap words indicate index in string : e.g. : rock -> 0,29 climbing -> 5,34 fun -> 17 now question : want put [start] tag @ start of these words , [end] tag @ end of them, in string. can't 1 one since in case once insert [start] @ index 0, other indexes modified , i'll have recalculate them. there way in can insert of tags @ once or something? can suggest other solution problem? i can't use regular expressions(replaceall method), since i'll have sentence : rocks hard. and hashmap : rock -> 0 i looking faster solutions here. edit : sentence : rocks hard frocks beautiful. rocks -> 0 here don't want replace frocks tags. this not doing want, consider alternative solution tries achieve goal via different means. i suppose 2 different things, firstly, suppo

python - Understanding indexing issues in Pandas 0.8.1 (and 0.11) -

here example ipython session straightforward indexing , assignments pandas dataframe work , don't work when seem straightforward: in [652]: dfrm = pandas.dataframe(np.random.rand(10,3), columns=['a', 'b', 'c']) in [653]: dfrm out[653]: b c 0 0.777147 0.558404 0.424222 1 0.906354 0.111197 0.492625 2 0.011354 0.468661 0.056303 3 0.118818 0.117526 0.649210 4 0.746045 0.583369 0.962173 5 0.374871 0.285712 0.868599 6 0.223596 0.963223 0.012154 7 0.969879 0.043160 0.891143 8 0.527701 0.992965 0.073797 9 0.553854 0.969303 0.523098 in [654]: dfrm['a'][dfrm.a > 0.5] = [1,2,3,4,5,6] in [655]: dfrm out[655]: b c 0 1.000000 0.558404 0.424222 1 2.000000 0.111197 0.492625 2 0.011354 0.468661 0.056303 3 0.118818 0.117526 0.649210 4 3.000000 0.583369 0.962173 5 0.374871 0.285712 0.868599 6 0.223596 0.963223 0.012154 7 4.000000 0.043160 0.891143 8 5.

javascript - jQuery refuses to post after validation -

i've added validation jquery code check blank text fields before posts message doesn't seem working. no messages being posted @ wall. idea how can fix this? html <div id="header"> <div class="container"> <span id="text_header">virtual idea wall</span> </div> </div> <div id="main"> <div class="container"> <div id="chat"></div> </div> </div> <div id="footer"> <div class="container"> <p> <label for="title">please give idea title</label> <br /> <input type="text" id="title" name="title"/> </p> <p> <label for="message">please provide details of idea</label> <br> <input type="text" id="message" name="me

HTML Button Run Java -

i have html form want user fill out, , send pressing button. there way have button run java program html input parameters? looked bit, , people recommended servlets. there way without servlet? edit: i'm not trying use servlet because of restrictions. if have restriction against running servlet you're pretty out of luck in terms of using java. use jsp, that's servlet @ end of day. use javascript pop-up mail-to form parameters entered body of email assume user has mail program configured. use service http://www.emailmeform.com/ (i have no idea if 1 good, googled it...).

html - Print/Save as PDF (keeping the CSS layout) -

when print (like on paper), or save pdf page (using browser built-in tool), css ignored , ugly lines after lines of content!! is there way (without having convert html 2 pdf/image)? thanks! you should media types in css... set 1 printing , should go. i've found this page helpful.

ms access - Form transition and data refresh -

i have form button , when push it, opens form. when close second form need refresh first form. so need insert first form name in global variable access form name second form refresh first form. i tried create this: global formname form formname = activeform.name but receive error saying: option read only. on click event of button can pass name of form openargs property of docmd.openform . private sub command4_click() docmd.openform "frmstaff", , , , , , me.name end sub on close event of second form can check (string) value: private sub form_close() if me.openargs <> "" 'msgbox me.openargs forms(me.openargs).refresh 'or .requery end if end sub

xcode4.5 - On xcode, how do I say the length of the screen -

i have image appear in middle of screen. when change ios simulator iphone 4s 5, image doesn't appear in middle of screen, appears more top. i thinking there way like: uiimageview.center.y = length of screen/2 please let me know if there way that. you going want screen dimensions first cgrect. can use cgrect screens height , width. cgrect screensizerect = [[uiscreen mainscreen] bounds]; cgfloat width = screensizerect.size.width; cgfloat height = screensizerext.size.height;

xmlhttprequest - download progress with jsonp via ajax -

in internet many example how extend $.ajax download (or upload) progress. this example work perfect plain-text, xml, json, not work jsonp. there no reaction event-listeners. wrote example on pure javascript, no result. know script-append-to-dom-way. using method can not progress. how can download progress jsonp , via xmlhttprequest? i know script-append-to-dom-way. jsonp is script-append-to-dom-way. there no "progress" events on script tags afaik.

node.js - TypeScript: tsc.exe --execute: Error cannot find module -

i have following directory setup: /app/ioc.ts /tests/test.ts i'm in tests directory. contents of app/ioc.ts unimportant, contents of tests/test.ts are: import ioc = module('../app/ioc'); var container = new ioc.container(); if compile so: tsc test.ts then run so: node test all's good! file runs without errors. however! if run this: tsc -e test.ts i following error: module.js:340 throw err; ^ error: cannot find module '../app/ioc' @ function.module._resolvefilename (module.js:338:15) @ function.module._load (module.js:280:25) @ module.require (module.js:364:17) @ require (module.js:380:17) @ object.<anonymous> (d:/dropbox/work/sandbox/prototyping/typescript/tests/test.js:1:73) @ module._compile (module.js:456:26) @ object.run (c:\users\nathan\appdata\roaming\npm\node_modules\typescript\bin\tsc.js:56041:30) @ batchcompiler.run (c:\users\nathan\appdata\roaming\npm\node_modules\typescrip

Extract Path up until the last occurrence of "\" in Batch -

the task simple: given path: c:\auto\proj output: c:\auto. i.e. extract given path until not including last occurrence of "\" in batch. try this: set "givenpath=c:\auto\proj" /f "tokens=1,2 delims=\" %%a in ("%givenpath%") set "givenpath=%%a\%%b" echo %givenpath%

php - Issue with URL data returned by get_file_contents used on XML feed -

i using file_get_contents() retrieve xml feed data, parsing. image url's however, getting base url prefixing image url - this:- http://server.com/http://server2.com/image.png here's code: <? php $context = stream_context_create( array( 'http' => array( 'follow_location' => false ) ) ); $content =file_get_contents("http://xyogasangeetax.api.channel.livestream.com/2.0/latestclips.xml", false, $context); $data = new simplexmlelement($content); foreach($data->channel->item $entry) { if ($media = $entry->children('media', true)) { $attributes = $media->content->attributes(); $src = $play_attributes['url']; if ($media->thumbnail) { $attributes = $media->thumbnail->attributes(); $imgsrc = (string)$attributes['url']; echo "<img src=\"'$imgsrc'\" alt=\"\" \/>"; } } $pub_date= explode("-",$entry->pubdate); echo date('f

c++ cli - Accessing a dictionary key by its index -

it's easy question how access value of dictionary key in specific row. let's dict { 1,13; 3,14; 5,17 } second key 3 . how value? tried dict->key[2] gave error , can't find reference update: gives me need maybe there faster way. dictionary<double, double>::keycollection^ keycoll = dict->keys; double first; double last; int counter=0; int dictionarycount = dict->count; each( double s in keycoll ) { if(counter==0){ first=s; } if(dictionarycount == counter+1){ last=s; } //dict[first] first key //dict[last] last key the dictionary<> class has indexer , use applying [] operator directly object reference. named item in msdn library articles. indexer dictionary takes key , returns value key. sample code: auto dict = gcnew dictionary<int, double>(); dict->add(1, 13); dict->add(3, 14); dict->add(5, 17); auto value = dict[3]; you use trygetvalue() method instead if not sure if key present. the d

windows phone 7 - I want open marketplace with specific app after clicking button -

i want open marketplace specific app after clicking button, , can't find solution that. help? try using marketdetailtask class in button's "tap" event handler. insert id of app want display below. here's example how: using microsoft.phone.tasks; marketplacedetailtask marketplacedetailtask = new marketplacedetailtask(); marketplacedetailtask.contentidentifier = "app-id-goes-here"; marketplacedetailtask.contenttype = marketplacecontenttype.applications; marketplacedetailtask.show();

Subclassing QGLWidget using Qt Creator error -

i'm trying make simple subclass of qglwidget using qt creator, generated .h , .cpp file using qt creator wizard generated following code: viewport.cpp #include "viewport.h" viewport::viewport(qobject *parent) : qglwidget(parent) { } viewport.h #ifndef viewport_h #define viewport_h #include <qglwidget> class viewport : public qglwidget { q_object public: explicit viewport(qobject *parent = 0); signals: public slots: }; #endif // viewport_h i added qt += opengl .pro file got rid of of errors i'm left 2 don't understand: /projects/tree_gen/qt_project/tree_gen-build-desktop-qt_4_8_4_in_path__system__debug/../tree_gen/viewport.cpp:4: error: invalid conversion 'qobject*' 'qwidget*' /projects/tree_gen/qt_project/tree_gen-build-desktop-qt_4_8_4_in_path__system__debug/../tree_gen/viewport.cpp:4: error: initializing argument 1 of 'qglwidget::qglwidget(qwidget*, const qglwidget*, qt::windowflags)' ive no

Copy specific files into subfolder in batch -

i have windows batch file i'm running move specific files subfolder. @echo off echo start copy setlocal enabledelayedexpansion set source_dir=c:\users\paul.ikeda\support\sndatademo91\solidcad\inventor_in set dest_dir=c:\users\paul.ikeda\support\sndatademo91\solidcad\inventor_in\files import set filenames_to_copy=sn_router_1.ipt sn_router_2.ipt sn_router_3.ipt /r "%source_dir%" %%f in (%filenames_to_copy%) ( if exist "%%f" ( set file_dir=%%~dpf set file_intermediate_dir=!file_dir:%source_dir%=! echo file "%%f" xcopy /y "%%f" "%dest_dir%!file_intermediate_dir!" ) ) echo. pause this copying 3 desired files subfolder, keeps going , creates subfolder in subfolder, copies 3 files again subsubfolder, , it's repeating many files in original source folder. want copy 3 files copy destination folder , stop there. can spot problem? don't know enough batch code debug this. if wan

java - Cannot save value in SharedPreferences -

i encountering problem in android application app crashes when try save value. making online currency converter. here part of code: view.onclicklistener myhandler1 = new view.onclicklistener() { @override public void onclick(view v) { string text1 = spinner1.getselecteditem().tostring().trim(); string text2 = spinner2.getselecteditem().tostring().trim(); if (text1.equals("us dollar - usd") && text2.equals("euro - eur") && edittextdollars.length() > 0 && edittexteuros.length()==0) { try { convertvalues("usd", "eur"); float k = float.parsefloat(convertvalues("usd", "eur")); sharedpreferences settings = getactivity().getsharedpreferences("pref", 0); sharedpreferences.editor editor = settings.edit(); editor.putfloat("dollarseuros", k); editor.commit();

emacs - If frame named "xyz" exists, then switch to that frame -

could please give me hand function detects whether frame named "xyz" exists, , if so, switch frame. i'm using frame-cmds give each frame user-defined name:   http://www.emacswiki.org/emacs/frame-cmds.el i imagine similar buffer, i'm not finding on google. here buffer function: (defun buffer-exists (bufname) (not (eq nil (get-buffer bufname)))) (defun lawlist-switch-to-buffer-xyz () (interactive) (if (buffer-exists "xyz") (switch-to-buffer "xyz") )) here semi-related post:   https://superuser.com/questions/358037/emacsclient-create-a-frame-if-a-frame-does-not-exist edit (september 15, 2014):  modified function ido-switch-frame make frame-to let-bound variable, , removed message . removed previous edits functions get-a-frame , get-frame-name written drew adams sufficient when used in conjunction select-frame-set-input-focus -- see answer below. (defun ido-switch-frame () (interactive) (when (not (minibuf

android - Receiving click/swipe events on a view behind a transparent item of a listview -

i have layout similar foursquare (image) , view (in case, map) behind listview , visible because first element transparent. i need view behind listview take touch , swipe events. there way make only first invisible item of listview ignore these events , allow events propagate view behind it, have rest of listview items take events usual? i'm hoping won't have abandon listview , use scrollview instead, because i've implemented lot of listview specific features. scrollview on work normaly unless click button: <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <scrollview android:id="@+id/bottom" android:layout_width="match_parent" android:layout_height="match_parent"> <textview android:

javascript - js_of_ocaml and Deriving_Json -

i need js_of_ocaml working. there's not information on net, , manual sparse (no snippets or usage examples, no comment sections). i have card module on server card record. i'm sending card list client using ajax, , there want read , traverse list. end this: let json = json.unsafe_input (js.string http_frame.xmlhttprequest.content) in ...where json has type 'a , according documentation (not when run it, of course). i can log json##length , correct length of list. go here? ideally, i'd use deriving_json type-safe card list again, use for-loop (not elegant, whatever). type declarations type name = ... deriving(json) creates json_name module. here example. type card = {a: int; b: string; } deriving(json) type t = card list deriving(json) let _ = let str = json.to_string<t> [{a = 10; b = "abc";}; {a = 20; b = "xyz";}] in let rs = json.from_string<t> str in firebug.console##log(js.string str); list.ite

python - Accessing an html file from cache memory -

i writing code in python following things: 1) gets html file internet. 2) extracts urls. 3) compare these urls search key , opens correct webpage user wants open. using following code: def open_page(name): try: links = lxml.html.parse('http://www.w3schools.com/html/').xpath("//a/@href") url in links: if re.search(name, url): self.get_webpage.open('http://www.w3schools.com/html/'+url) break except indexerror e: pass` i have call method many times in module making process of opening webpage slow. tried check execution time of each line of method , came know lxml.html.parse() consuming of time. if try use html file stored in local system, method works speedily. there way can html file of webpage http://www.w3schools.com/html/ cache after first time? p.s. not want save html file permanently in local system, because in case can miss updates/changes on html file. it sounds

google search - Rich-snippets - Double movie authors -

i did not understand how behave in case there multiple items of same type, writers of movie. have repeat itemprop="author" each writer or can include them in single div? <div itemprop="author" itemscope itemtype="http://schema.org/person"> <span itemprop="name"><a href="#">cesare frugoni</a></span> <span itemprop="name"><a href="#">enrico vanzina</a></span> </div> or <div itemprop="author" itemscope itemtype="http://schema.org/person"> <span itemprop="name"><a href="#">enrico vanzina</a></span> </div> <div itemprop="author" itemscope itemtype="http://schema.org/person"> <span itemprop="name"><a href="#">cesare frugoni</a></span> </div> the latter right. first snippet means p

width - DIVS / WEBSITE NOT FILLING ENTIRE SCREEN ON MOBILE -

im having trouble getting website fill entire screen on mobile devices. my meta tag looks this: <meta name="viewport" content="width=device-width, initial-scale=1"> and css body, html { margin: 0; width: 100% ; } http://www.girlsskateaustralia.com anyone have ideas?? looks fine on mobile ie browsers might picky initial scale value; use: <meta name="viewport" content="width=device-width, initial-scale=1.0">

osx - Pyqtgraph with anaconda python on MAC gives nib error -

i'm trying use pyqtgraph anaconda python on mac os python 2.7.5 |anaconda 1.6.1 (x86_64)| (default, jun 28 2013, 22:20:13) [gcc 4.0.1 (apple inc. build 5493)] on darwin i installed pyqtgraph pip install pyqtgraph , seemed work fine. however, if run command library error: qt internal error: qt_menu.nib not loaded. .nib file should placed in qtgui.framework/versions/current/resources/ or in resources directory of application bundle. i found so thread , seems related c++ app. in case have no application.app folder i'm bit lost. the solution use python.app (or equivalent pythonw ) run program, instead of python . if pyqtgraph installed commands, you'll need edit them shebang line calls #!/path/to/anaconda/bin/python.app/contents/macos/python .

jquery - bounce effect not working -

Image
i want make list items bounce on hover, can't seem figure out why it's not working. link coding on jsfiddle: http://jsfiddle.net/wrdweaver6/amhjk/ here code using in html head: <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#nav > li').hover(function() { $(this).effect('bounce',{times: 2},'slow'); }); }); </script> </head> here body: <body> <div id="nav"> <ul> <li>word lists</li> <li>games</li> <li>stories</li> <li>parents</li> <li>email</li> </ul> </div> </body> try following js fiddle http://j

c# - How to prevent error when deleting last DataRow from DataTable bound to DataGridView? -

in winforms application, have following logic triggered button press: private void executeselectedconsolecommand() { var commandsrow = getcommandsrow(); var consolecommand = getconsolecommand(commandsrow); task.factory.startnew(() => { var runningcommandrow = runtimedataset.runningcommands.addrunningcommandsrow(guid.newguid(), consolecommand.onelinedescription); consolecommand.run(null); runningcommandrow.delete(); }); } a bindingsource used let datagridview automatically update itself. as of now, without following hack, error saying the "index 0 invalid". // prevents error when removing last row data bound datagridview var placeholder = runtimedataset .runningcommands .addrunningcommandsrow(guid.newguid(), "placeholder"); with above code, causes there

Android custom ArrayAdapter not staying on scroll -

i have created custom arrayadapter (code below) works fine until scroll. once scroll items go green , have been pulling hair trying figure out why. appreciated. the custom adapter intended make text of listview item 3 characters long turn green while others should remain default color of black. public class foundadapter extends arrayadapter<string> { private final activity context; private final arraylist<string> names; static class viewholder { public textview text; } public foundadapter(activity context, arraylist<string> names) { super(context, r.layout.found, names); this.context = context; this.names = names; } @override public view getview(int position, view convertview, viewgroup parent) { view rowview = convertview; if (rowview == null) { layoutinflater inflater = context.getlayoutinflater(); rowview = inflater.inflate(r.layout.found, null); viewholder viewholder = new viewholder(); v

javascript - Unable to pass a response form facebook to another function -

if view question thank in advance!, working on pulling data facebook. i trying pull username facebook can use in later stage have embedded following code in fb root div. i know retrieve works! not able pass on function returndata relative new javascript please me out? have tried there alert in there check if retrieving data <div id="fb-root"></div> <script type="text/javascript"> $(document).ready(function() { var appid = "121070974711874"; // if logging in facebook canvas application use url. var redirecturl = "http://apps.facebook.com/bggressive"; // if logging in website this. sure add host application's app domain list. var redirecturl = window.location.href; // if user did not grant app authorization go ahead , tell them that. stop code execution. if (0 <= window.location.href.indexof ("error_reason")) {

Mysql Help Needed -

i have table named group info. has 3 fields namely id,user_id, , group_id. question how assign unique users group i-e same user may not repeated in same group. table structure group info follows; id int(11) auto increment,primary key not null, user_id int(11) not null, group_id int(11) not null i have made user_id unique.but there 2 groups(2 group_id(1 , 2)).selecting users groupb gives error duplicate entry. user_id = 1,2,3,4,5,6,7,8; group_id= 1,2; kindly me how solve this.iam not in english apologies language. alter table `tbl_name` add unique ( `col1` , `col2` ); change col1 user_id , col2 group_id , tbl_name table name.

python - What's the difference between nan, NaN and NAN -

in numpy there nan , nan , nan . what's sense of having three, differ or of these can used interchangeably? >>> numpy.nan numpy.nan numpy.nan true it's convenient. they're same.

sql - not able to retrieve if the table column has null value -

i have stored procedure find customer, working fine. if customer_city_name null in table not able retrieve row. sp fails . how have result if customer_city_name or customer_country_code is null exec findcustomer null,'%',null,null, sp code: create procedure findcustomer @customernumber nvarchar(100), @customernamepattern nvarchar(35), @customercitynamepattern nvarchar(35), @customercountrycode nvarchar(5) begin declare @sql nvarchar(4000) set @sql = ' select c.customer_number, c.customer_name, c.postal_address_identifier, c.customer_street_or_road_name, c.customer_city_name, c.customer_territory_code, c.customer_postal_code, c.customer_country_code, c.telephone_number, c.mobile_telephone_number, c.fax_number, c.email_address customer c c.customer_number ' + case when @customernumber not null '''' + @customernumber + '''' else 'c.customer_number' end + ' , c

jquery - How to change select box values based on the other drop down list values in rails query ajax -

Image
here have model user , usertype. if change usertype user belongs particular usertype listed in drop down. code. *.html <div class="control-group string optional payslip_user_type_id"> <label class="string optional control-label" for="payslip_user_type_id">employee type</label> <div class="controls"> <%= f.collection_select :user_type_id, usertype.all, "id", "name", prompt: '--select--' %> </div> </div> <div class="control-group string optional payslip_user_id"> <label class="string optional control-label" for="payslip_user_id">employee name</label> <div class="controls"> <%= f.collection_select :user_id, @users, "id", "name", prompt: '--select--' %> </div> </div> the jquery file is $("#payslip_user_type_id&quo

asp.net - Guidelines for the development of web Gis Application -

respected sir/mam i want develop webgis application , want know right path move ahead, start work smoothly.i in .net , c#, jquery, html, azax etc. working on project data preset in shp files, digitized in arc-gis,some data in sql server. confuse how can develop application use data , display on map below queries need discuss. how can integrate data(present in shp file,sql server , excel) front end, display data in map. is there open source need integrate in project displaying data in map window , integration .net . can perform several function zoom in, zoom out,search etc. is there middleware accessing data shp file in project. rest ask when in confident it, i requesting please me. thank in advance. please see ideas below set out answer questions. i think way integrate amount of data sources the opengeo suit. open source software stack includes geoserver wms source , gxp libraries , examples front end client. can found here http://opengeo.org/ there numbe

python - Counting occurrences in a loop -

gzip_files=["complete-credit-ctrl-txn-se06_2013-07-17-00.log.gz","complete-credit-ctrl-txn-se06_2013-07-17-01.log.gz"] def input_func(): num = input("enter number of min series digits: ") return num in gzip_files: import gzip f=gzip.open(i,'rb') file_content=f.read() digit = input_func() file_content = file_content.split('[') series = [] #list of min line in file_content: min = line.split('|')[13:15] x in min: n = digit x = x[:n] series.append(x) break #count number of occurences in list named series in series: print #end count result: 63928 63928 63929 63929 63928 63928 that part of result. actual result shows long list. want list unique numbers , specify how many times showed on list. 63928 = 4, 63929 = 2 i use collections.counter class here. >>> = [1, 1, 1, 2, 3, 4, 4, 5]

Listing files in a directory recursively - python -

this question has answer here: directory listing in python 2 answers i want display file , folder structure recursively in output . actual structure: root--| | dira--| | dirc--file5 file3 file4 file1 file2 dirb--| | no file expected output: root: file1 file2 root/dira file3 file4 root/dira/dirc file5 root/dirb no file found i have written following code below. need inputs in how modify required output. code import os.path path = 'c:\\my\\path\\here' root, dirnames, filenames in os.walk(path): subdirname in dirnames: print subdirname filename in filenames: print os.path.join(root, filename) actual output dira dirb c:\my\path\here\file1 c:\my\path\here\file2 dirc c:\my\path\here\dira\file3 c:\my\path\here\dira\

php - CSS Alignment Issues with IE -

this page showing different alignment in internet explorer other browsers. guide me in correcting it. please add proper document type @ start of document. ie rendering document in quirk mode. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> in ie 10 page rendering correctly, ie 9, 8, 7 having issue. apply above fix , solve problem. for second problem refer following failed connect mailserver @ "localhost" port 25

MongoDB: Different return values on .find() at shell access, and at php -

i started use mongodb 2.4.4, , have iritating case query-ing post, field in php. in mongoshell, db.posts.find({page_id:345671} (for example) gives me 293 count of document. the php equivalent: $connection = new mongo('mongodb://localhost:27017'); $db = connection->selectdb('post_db'); $posts = $db->posts->find(array('page_id' => 345671)); alway return zero, but, when find array empty, gives entire collection. also, ->explain() , .explain() gaves me different params. what wrong? there's no sharding, no indexes, test data, i'm in begining of things. solved, many vitaly muminov ! "i'm not quite sure that, can try setting ini_set('mongo.native_long', 1); or wrapping numbers mongoint64 class" the solution wrap number mongoint64 !

jquery - How to permanently change the color of some elements? -

i have php page on want user can change color of elements, , next time load page choices should loaded default. i'm using jquery click() function change colors, , save changes on server side suppose best way using jquery/json, i'm totally new this. should have separate json file color options stored? found many stories on web jquery/json, still need example how accomplish task. please useful link or code example. #div01 { background:#008080; color:#ffffff; } $('#btnblue').click(function () { $('#div01').css('background', '#0000ff'); $('#div01').css('color', '#ffffff'); }); $('#btnred').click(function () { $('#div01').css('background', '#ff0000'); $('#div01').css('color', '#0000ff'); }); if looking concrete example on how this, might trick. first, use javascript library: https://github.com/carhartl/jquery-coo

apache pig - How to allocate specific number of mappers to multiple job in Hadoop? -

i executing multiple pig scripts script1, script2, script3, script4. in script1 executing independently , script2,3,4 executing parallely after scripts executed. giving input file of size 7-8 gb. after executing script1, observing instead of parallely executing script 2,3,4 script2 executing consuming 33-35 mappers. other remain in queue (means script3,4 have not mapper allocation). due time requires execute scripts. so thinking if able set limit of mapper each script may time require execute wll less scripts may allocation of mappers. so there way allocate specific number of mappers multiple scripts? if map number correctly set (according core/node , disks/node values), having 1 job consuming maps or having n job consuming mapnumber / n maps have same result. if want distribute maps on amount of jobs can set per job map number ( mapreduce.job.maps in mapred-site.xml think). considering still have free map slots, there config enable jobs parallel executions discuss

c# - Resharper wants me to implement an interface member that is implemented in WPF generated code -

simple class: public partial class mainwindow { public mainwindow() { this.initializecomponent(); } } class mainwindow underlined red, resharper complaining icomponentconnector.connect not implemented . checking file obj\debug\mainwindow.g.i.cs method there, , compiler not complain anything. what missing? bug in r#? i've got many false solution errors @ moment - count useless. update problem persists after: removing _resharper files a fresh checkout source control remove system.windows project references. according docs icomponentconnector moved windowsbase system.xaml . think system.windows may involved, isn't documented.

objective c - How to convert a JSON String into an NSArray? -

i facing issue while converting nsstring nsarray. my string : ["default", "discipleship", "faith", "family", "hope", "life building", "love", "missions", "relationships"] what want elements(default,discipleship etc.) out of string , put them nsarray. i have tried lot couldn't done, please great , in advance first convert string nsdata: nsstring* str = @"[\"default\",\"discipleship\",\"faith\",\"family\",\"hope\",\"life building\",\"love\",\"missions\",\"relationships\"]"; nsdata* data = [str datausingencoding:nsutf8stringencoding]; then, use: nserror *e; nsarray *array = [nsjsonserialization jsonobjectwithdata:data options:nil error:&e]; the object array contains elements of json text.

jquery - django form wizard ajax next step -

i creating 9-step proposal form using django form wizard. well, until wanted use ajax load next step. i'm having hard time configuring ajax call in jquery because django forms don't have action url included in form tag. why anyway? win-win situation me have loading screen next step , if there upload file process in step, show percentage loading uploaded file. thanks! i'm using code, , it's working me. don't put action inside form, can see. use jquery 'on' function when form submited because form reloading , changing inside div#creation. ajax url must 1 displays form. in case, first step of form rendered through ajax get, when click on button. that's why there's isn't form in div @ first. (i'm using bootstrap's modals). <div id="creation"> <!-- form display through ajax --> </div> the template reload in formwizard class in views following html: template_name = 'creation_form.html'

php - how prevent include 2 times but if not included before include now -

i have 1 file named header-guest.php when open link http://royta.ir/badurl code run: if(!isset($headerload)){ if(isset($_cookie['userid'])){ include_once('tmp/header.php'); } else{ include_once('tmp/header-guest.php'); } } and when click on بازگشت به خانه ajax code run in #content if(!isset($headerload)){ if(isset($_cookie['userid'])){ include_once('tmp/header.php'); } else{ include_once('tmp/header-guest.php'); include_once('block/index-visitor.php'); } } and in header-guest.php have code <? echo $sitetitle; $headerload = 1;?> but when click on badurl , click on بازگشت به خانه header-guest.php run 2 times how prevent it? to prevent loading resources twice use require_once or include_once . prevent resource being loaded twice if happen put 2 include_once statements same resource.

python - Play a sound with QAudioOutput in PyQt -

my app should work both on windows , linux(ubuntu). have reimplement notification sounds, because qsound not work under ubuntu. trying qaudiooutput. i can't run code, , don't understand have do. have tips? or perhaps idea works on both os? from pyqt4.qtgui import qapplication import sys pyqt4.qtmultimedia import qaudiooutput, qaudioformat pyqt4.qtcore import qfile, qiodevice app=qapplication(sys.argv) #1st edit output=qaudiooutput() soundfile=qfile() soundfile.setfilename("c:\\users\\delete_2.wav") soundfile.open(qiodevice.readonly) output.start(soundfile) app.exec_() #1st edit i don't know if it's issue, need create qapplication object , start main event loop. add beginning of program: app = qapplication() add end of program: app.exec_()

java - InplaceEditor does not save property when focus lost -

i have little netbeans app custom inplaceeditor integrated in propertysheet. when creating editor, followed tutorial: http://netbeans.dzone.com/nb-custom-float-propertyeditor . i'm not posting code because it's same in tutorial. inside inplaceeditor there jspinner. when change value of spinner clicking up/down property saved correctly. works fine when enter number via keyboard , press enter. when enter number without pressing enter afterwards, property value jumps old state when focus lost. i need mechanism save property value when focus lost (without forcing user hit enter). tried adding various listeners (e.g. keylistener, focuslistener) spinner change property manually, reason doesn't work. thanks help.

jquery - move div to index position -

i have 3 divs on page. you can see sample here- fiddle on page fading divs on click. goes fine according assumed. now if click on div tab, siblings fading out , fading-in again on show button click. when div goes hide, comes left position default. want div click should go @ middle of page. tried giving index position of second-child not working. how can index position of second child moving box @ middle? jquery- $(function () { var index = $('.span4:nth-child(2)').index(); $('.container .row-fluid .span4 ').click(function () { $(this).show().siblings().fadeout(); $(this).css('margin', index); }); $('.show-all').click(function () { $('.span4').fadein(); }); }); maybe should use .position() instead of .index() $(function () { var index = $('.span4:nth-child(2)').position().left; var left = $('.span4:nth-child(2)').pos