Posts

Showing posts from July, 2012

javascript - Filter td elements in a tr out, that are not displayed -

i have datatable in asp.net want modifiy. select <tr> rows of datatable jquery: var rows = $("#dginformation tr:gt(0)"); however, <tr> elements have multiple <td> elements , of them marked display:none . how can rows -variable without hidden cells? the purpose of check cells if different each other , 1 line each difference should displayed. if dont filter not displayed elements, compared , have lines, visually same. update works adding css class <td> -elements should hidden. have clean dom-tree (i hope can call way) in firebug. whole function below reference: function filtertable() { var rows = $("#dginformation tr:gt(0)"); var prevrow = null; var counter = 2; rows.each(function (index) { if (prevrow !== null) { var = 1; var changes = 0; $(this).children("td:visible").each(function () { if(i > 2)

Django Cache Implementation -

well, i'm designing web application using django. application allow users select photo computer system , keep populating onto users timeline. timeline view have list/grid of photos user has uploaded sorted chronologically, showing 50 photos , pull refresh fetch next 50 photos on timeline.the implementation works multiple users. now fast user experience of app i'm considering caching. sites store timeline of user onto cache whenever user logs in first place check information request served out of cache , if not available there go db query information. primarily in 1 line i'm trying cache timelines different users in cache now. i'm done building of webapp minus cache part. , question how cache timelines of different users?? there big difference between public caching , caching of private data. feel data private , needs different strategy. there nice overview of different ways implement testing and, more importantly, different things need take account:

c# - Sqlite: appropriate use of commit -

in server application(written in c#) multiple requests come simultaneously , server both read , write operation on sqlite db. now problem when server tries insert database @ time of other request reading database transaction.commit() throwing exception database locked , executenonquery() executing successfully. problem committing database. we committing after every insert , update query. can problem avoid committing once(keep database in memory , commit on application close)? or there other way handle situation. it seems need implement busy callback or busy timeout , sql lite has lock entire database when writing: multiple processes can have same database open @ same time. multiple processes can doing select @ same time. 1 process can making changes database @ moment in time, however. can multiple applications or multiple instances of same application access single database file @ same time?

android - TextView.getLineCount() in custom BaseAdapter -

i need show view when mtxttext has maxlinescount or more lines. checked these questions: first , second what have result in getview method: mtxttext.settext(html.fromhtml(output)); mtxttext.getviewtreeobserver().addongloballayoutlistener( new ongloballayoutlistener() { @suppresswarnings("deprecation") @override public void ongloballayout() { if (build.version.sdk_int < build.version_codes.jelly_bean) { mtxttext.getviewtreeobserver() .removeglobalonlayoutlistener(this); } else { mtxttext.getviewtreeobserver() .removeongloballayoutlistener(this); } if (iscollapseon && mtxttext.getlinecount() >= maxlinescount) { mtxtexpand.setvisibility(view.visible); } else { mtxtexpand.

c# - Converting UTC to local time returns strange result -

Image
i have solution of 3 projects: core outlook add-in asp.net website both, outlook add-in , website use same methods core project data sql server. when write data database, convert datetime values of 2 tables utc time: poll_start poll_end 2013-07-31 12:00:00.000 2013-08-01 12:00:00.000 and pick_date 2013-07-31 12:00:48.000 2013-07-31 13:00:12.000 when data in outlook add-in, correct result : when opening same in website, picks fine: but start , end time "broken" - offset added, bute wrong hours used: here's code converting, both, outlook , website, use: private static void converttolocaltime(poll item) { item.poll_start = item.poll_start.fromutc(); item.poll_end = item.poll_end.fromutc(); } private static void converttolocaltime(pick pick) { if (pick.pick_date != null) pick.pick_date = ((datetime)pick.pick_date).fromutc(); } and implementation of datetime.fromutc() : public static datetime fromutc(this dateti

html - Divs should not overlap -

i have small problem. webpage i'm working on has 3 areas: on left navigation, should on left side a content area in middle, should in middle of browser the logo area on right side, should in top right corner here's code have right now: css html, body { height: 100%; min-height:100%; padding: 0em; margin: 0em; } body { font-family: segoe ui, arial; font-size: 12px; color: #616a71; line-height: 15px; letter-spacing: 0.5px; overflow-y: scroll; background-color: #ccc; } div#navigation { position: absolute; float: left; width: 220px; left: 5px; top: 70px; z-index: 2; padding-bottom: 50px; background-color: red; } div#content { position: relative; width: 1014px; margin: 0 auto; top: 70px; padding: 10px; background-color: #f6f6f3; box-shadow: 0 0 5px rgba(0,0,0,0.2); border-radius: 2px; line-height: 20px; } div#right { positio

javascript - Upload files without refreshing the page by using ajax post -

i have page file-upload.jsp code snippet below: <form action="" id="frmupload" name="frmupload" method="post" enctype="multipart/form-data"> <input type="file" id="upload_file" name="upload_file" multiple="" /> <input type="submit" value="update" /> </form> i have 2 questions: the moment select files, i.e onchange event of input type file , file(s) should uploaded. i have java page receives multipart request parameter , uploads file said location. problem form submission onchange , java file can proceed further operations. i googled , went through lot of articles. it's not possible upload files directly via ajax, submit form iframe via ajax/jquery. i tried lot of code internet, such this: $(document).ready(function(){ $('upload_file').change(function(){ var data = new formdata(); data.appen

docusignapi - Why is the company name in the DocuSign user profile not reflected in recipient email? -

why isn't company name in user profile reflected in email sent signature recipient? seems "account name" shows in email users company name regardless of value set in user profile. what want make use of docusign custom account branding. can control , content of things signing experience, email notifications, , other aspects. have @ account branding guide: docusign custom account branding

haskell - Could not deduce (Show t) -

i have piece of code in haskell refuses compile: data (eq a, num a, show a) => mat = mat {nexp :: int, mat :: qt a} deriving (eq, show) data (eq , show ) => qt = c | q (qt ) (qt ) (qt ) (qt ) deriving (eq, show) cs:: (num t) => mat t -> [t] cs(mat nexp (q b c d)) =(css (nexp-1) c)++(css (nexp-1) b d) css 0 (c a) (c b) = (a-b):[] css nexp (q b c d) (q e f g h) = (zipwith (+) (css (nexp-1) c) (css (nexp-1) e g))++(zipwith (+)(css (nexp-1) b d) (css (nexp-1) f h)) i have error: could not deduce (show t) arising use of `mat' context (num t) bound type signature cs:: num t => mat t -> [t] i searched online , found many similar questions, nothing seems close problem. how can make code work? class constraints on data types don't mean anything. see this related question remove constraint on data type. data mat = mat {nexp :: int, mat :: qt a} deriving (eq, show)

optimization - How Significant Is PHP Function Call Overhead? -

i'm relatively new php , learning idiosyncrasies specific language. 1 thing dinged lot (so i'm told) use many function calls , asked things work around them. here's 2 examples: // change this: } catch (exception $e) { print "it seems error " . $e->getcode() . " occured"; log("error: " . $e->getcode()); } // this: } catch (exception $e) { $code = $e->getcode(); print "it seems error " . $code . " occured"; log("error: " . $code); } 2nd example // change this: $customer->setproducts($products); // this: if (!empty($products)) { $customer->setproducts($products); } in first example find assigning $e->getcode() $code ads slight cognitive overhead; "what's '$code'? ah, it's code exception." whereas second example adds cyclomatic complexity. in both examples find optimization come @ cost of readability , maintainability. is performance increase wor

Get value in a 2D array in PHP -

i have array: $array = array ( "key1" => "value 1", "key2" => "value 2", "key3" => "value 3", "key4" => "value 4", ... ); i submitting key form, want assign variable value belongs key, example: $key = $_post['key']; $value = ?????; //this need this might simple, haven't done in long time , have forgotten how it. thanks. this should trick: $value = $array[$key]; or without variable: $value = $array[$_post['key']]; if receive notice: undefined index ... should check array before try value with: $value = array_key_exists($_post['key'], $array) ? $array[$_post['key']] : null; this condition checks if key exists. if so, gets value. if not, value of $value null .

exit while loop with user prompt in python -

i've been browsing long time searching answer this. i'm using python 2.7 in unix. i have continuous while loop , need option user interrupt it, , after loop continue. like: while 2 > 1: items in hello: if "world" in items: print "hello" else: print "world" time.sleep(5) here user interrupt loop pressing "u" etc. , modify elements inside loop. i started testing out raw_input, since prompts me out every cycle, it's don't need. i tried methods mentioned here: keyboard input timeout in python couple of times, none of seem work how wish. >>> try: ... print 'ctrl-c end' ... while(true): ... pass ... except keyboardinterrupt, e: ... print 'stopped' ... raise ... ctrl-c end stopped traceback (most recent call last): file "<stdin>", line 2, in <module> keyboardinterrupt >>&g

Opening Word Document using VBA in Access 2013 -

i'm using access 2013 , created button on form open word doc instructions. here's code tried: private sub cmdhelp_click() dim wrdapp word.application dim wrddoc word.document dim filepath string set wrdapp = createobject("word.application") wrdapp.visible = true filepath = "c:\...\handout.docx" set wrddoc = wrdapp.documents.open(filepath) end sub the problem is, when try compile error on first line says "user-defined type not defined" please check if set appropriate reference word library in vba environment. to follow path: go vba editor >> menu >> tools >> references >> find on list microsoft word xx.x object library xx.x highest available number >> check >> press ok.

sonarqube - plugin for adding issues referring to manual rules into sonar -

import org.sonar.api.component.resourceperspectives; public class mysensor extends sensor { private final resourceperspectives perspectives; public mysensor(resourceperspectives p) { this.perspectives = p; } public void analyse(project project, sensorcontext context) { resource myresource; // set issuable issuable = perspectives.as(issuable.class, myresource); if (issuable != null) { // can used issue issue = issuable.newissuebuilder() //repository : pmd, key : avoidarrayloops .setrulekey(rulekey.of("pmd", "avoidarrayloops")) .setline(10) .build(); //works issuable.addissue(issue); issue issue2 = issuable.newissuebuilder() //repository : manual, key : performance .setrulekey(rulekey.of("manual", "performan

handlebars.js - Getting the page URL in a pages collection loop -

im trying build dynamic menu create list of pages per tag. working fine except don't know how page url populated: <section class="see-also"> {{#each tags}} <p>in <span class="tag">{{tag}}</span>:</p> {{#each pages}} <li><a href="#">{{data.title}}</a>{{pages.url}}</li> {{/each}} {{/each}} </section> any suggestions? @luis-martins should able use relative helper destination current page being rendered , destination current page in tags.pages collection generate relative url: <section class="see-also"> {{#each tags}} <p>in <span class="tag">{{tag}}</span>:</p> {{#each pages}} <li><a href="#">{{data.title}}</a>{{relative ../../page.dest dest}}</li> {{/each}} {{/each}} </section> notice the destination of current page being rendered, have use pare

javascript - jQuery - Get children from index as jQuery object -

[] , .get() both return collection element @ given index native dom element. how can if want retrieve jquery object ? i'm forced convert return value using $() everytime : var $third = $($elements.get(3)); and gets more horrible if have nest it. there kinf of .at() method used way : var $third = $elements.at(3); thanks ! the method looking .eq() var $third = $elements.eq(3);

winforms - I want to use up and down arrow keys and calender DropDown in DateTimePicker in C# -

i trying use , down arrow keys , calender dropdown in datetimepicker in c#. when using showupdown=true property of datetimepicker control arrow keys enabled calendar drop-down disabled. so please let me know how can use , down keys , calender dropdown key in datetimepicker control. if understand question, datetimepicker has showupdown=true want calendar drop down appear (with key combination). well can't , comes directly documentation of showupdown property (just press on f1 in property window) when showupdown property set true, spin button control (also known up-down control), rather drop-down calendar, used adjust time values. date , time can adjusted selecting each element individually , using , down buttons change value. you 1 or other. may want @ datetimepicker controls 3rd party vendors devexpress, may have combination looking for.

exception - showing result of try except integer check as a string -

i need function check different user input variables integers. results should confirmed user @ end. check works in keeps looping until integer typed in, cannot results display... def chkint(msg): while true: try: n = input(msg) return(int(n)) except valueerror: print("please enter actual integer.") number1 = input (chkint("please enter first value:")) number2 = input (chkint("please enter second value:")) results = (number1, number2) print ("i have accepted: " + str (results)) no answer, played , hey presto, works... def chkint(msg): while 1: try: n = input(msg) return(int(n)) except valueerror: print("please enter integer.") number1 = chkint("please enter first value:") number2 = chkint("please enter second value:") results = [number1, number2] print ("i have accepted: "

c# - Windows Phone- Internal Wrapped Exceptions -

my app throwing ms.internal.wrappedexceptions on launch. i'm not sure source of exceptions, , i'm new coding, pointers appreciated. goes directly exception while displaying loading screen. heres xaml: if need code behind, let me know <phone:phoneapplicationpage xmlns:my="clr-namespace:microsoft.phone.controls.maps;assembly=microsoft.phone.controls.maps" x:class="wpmapexample.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:microsoft.phone.controls;assembly=microsoft.phone" xmlns:shell="clr-namespace:microsoft.phone.shell;assembly=microsoft.phone" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d" d:designwidth="480" d:designheigh

Display JSON in Javascript from Python Bottle -

i trying access mongodb record within javascript function display document on webpage. using bottle framework pymongo, have tried first encode mongodb document json object pass javascript function. @bottle.route('/view/<_id>', method = 'get') def show_invoice(_id): client = pymongo.mongoclient("mongodb://localhost") db = client.orders collection = db.myorders bson.objectid import objectid result = collection.find_one({'_id': objectid(_id)}) temp = json.dumps(result,default=json_util.default) print "temp: " + temp return bottle.template('invoice', rows = temp) when try display document within html page javascript function, nothing happens. however, when call variable, rows, trying pass {{rows}} within body of html display. seems js function not display anything. <!doctype html> <html> <head> <head> <title>invoice report</title> &

python - using OR in pycassa index expressions -

is there way express or operator using pycassa's crerate_index_clause() method? know create 2 clauses , compare results, love solution create one. cassandra doesn't have support disjunction @ time. see -> using operator 'or' in cassandra indexexpression

Can't locate perl module in @inc even though error message says its in @inc -

i'm trying execute perl script , i've gotten work before when run in folder it's located in... ie, following works. \higherfolder\folder>updatetestcasesscript.pl test.feature test_cases.xls buuuuut when try run script on command line outside of folder \higherfolder>folder\updatetestcasesscript.pl realfile.feature folder\test_cases.xls i weird error: can't locate spreadsheet/parseexcel.pm in @inc <@inc contains: spreadsheet/parse excel.pl c:/strawberry/perl/site/lib c:/strawberry/perl/vendor/lib c:/strawberry /perl/lib .> @ c:...\higherfolder\folder\updatetestcasesscript.pl line 4 but if @ first few lines of script... following: #!/usr/bin/perl -w use lib 'spreadsheet/parseexcel.pm'; use spreadsheet::parseexcel; so have idea may looking @ wrong @inc somehow, have idea how fix it?? thanks!!! . in @inc , making perl in current work directory modules. stopped working when changed cwd because nothing else in @inc allowed

mysql - Access Denied for User 'root'@'localhost' (using password: YES) - No Privileges? -

i continuously receiving error. i using mysql workbench , finding root's schema privileges null. there no privileges @ all. i having troubles across platforms server used , has been of sudden issue. root@127.0.0.1 apparently has allot of access logged in that, assigns localhost anyways - localhost has no privileges. i have done few things flush hosts, flush privileges, ect have found no success or internet. how can root access back? find frustrating because when around people expect "have access" don't have access can't go command line or , grant myself anything. when running show grants root in return: error code: 1141. there no such grant defined user 'root' on host '%' thanks can provide help use the instructions resetting root password - instead of resetting root password, we'll going forcefully insert record mysql.user table in init file, use instead insert mysql.user (host, user, password) values ('%&#

ruby on rails - Why is my multiple-select with selected not working? -

i trying use multiple-selection drop-down unable figure out why not working. <%= select( map1[:field_name], "id", map1[:field_codes], :multiple => "true", :selected => optionval[value] )%> it not give me error, , adding multiple => true not make difference. multiple html_options , selected helper option. select has next syntax select(object, method, choices, options = {}, html_options = {}) so, write <%= select( map1[:field_name], "id", map1[:field_codes], { :selected => optionval[value] }, { :multiple => "true" } )%> read more select

komodoedit - Komodo Edit - Autocomplete filling script tag with wrong attributes -

i using komodo edit 8.0. whenever add <script> tag, fills tag in <script type="application/x-javascript"><!cdata[ //]]> how 1 change komodo fills in script tag? komodo dev here, because "script" triggers auto-abbreviation. snippet in toolbox name "script" has "auto-abbreviation" toggle enabled. please have @ snippets documentation: http://docs.activestate.com/komodo/8.0/snippets.html you can turn off either "script" toggling "auto-abbreviation" checkbox or globally toggling "enable auto-abbreviations" under preferences > editor > smart editing, in same area can change trigger these auto-abbreviations. example have configured trigger on "\t" (tab) can press tab trigger abbreviation.

c++ - Iterate through cv::Points contained in a cv::Mat -

i using opencv template matching find image within image. specifically matchtemplate() returns cv::mat containing similarity map of matches. is there way sort through cv::point s contained in cv::mat besides using minmaxloc() ? minmaxloc(result, &minval, &maxval, &minloc, &maxloc); i have tried: cv::mat_<uchar>::iterator = result.begin<uchar>(); cv::mat_<uchar>::iterator end = result.end<uchar>(); (; != end; ++it) { cv::point test(it.pos()); } with limited success. if understand correctly, wish sort pixels match score, , points corresponding these pixels in sorted order. can accomplish reshaping result single row, , calling cv::sortidx() indices of pixels in sorted order. then, can use indices offsets beginning of result position of particular pixel. update: noticed 1 possible issue in code. looks assume result contains uchar data. cv::matchtemplate() requires result contain fl

cordova - calabash-ios setup clang: error: no such file or directory 'UIKit' -

i porting existing mobile web application ios using phonegap. wanted test ios application using frank/calabash. facing same issue using either of test frameworks. both frank , calabash when try build app following error clang: error: no such file or directory: 'uikit' clang: error: no such file or directory: 'avfoundation' clang: error: no such file or directory: 'coremedia' in fact these frameworks exist in iphoneos6.1 sdk. to narrow down problem created demo helloworld phonegap application , tried frank , calabash got same error. demo app available @ https://github.com/jmadan/phonegap-hello.git xcode version used = 4.6.3 cordova version = 3.0.3 ios version = 10.8.4 has else faced same issue??? if yes suggestions? we had same error using calabash , frank. fix bit hit , miss found running cordova build again create whole ios app fresh eg. no frank or calabash stuff in there, putting calabash worked , able compile , run tests. how ever

amazon web services - Getting AppHarbor and AWS RDS MySql to play nice -

i have app 2 workers (web , background) on appharbor connect mysql database hosted on amazon's rds. i keep getting "unable connect of specified mysql hosts." exception. the rds instance in us-east region , have added following appharbor cidr security group. 50.17.211.192/28 54.235.159.192/27 i have added own cidr security group , connect instance fine. when app running on appharbor fails. my connection string (censored) is: server=myinstancexxxx.cykjvptrw5xs.us-east-1.rds.amazonaws.com;database=mydatabase;uid=xxxxxx;pwd=xxxxx; i have tried including port 3306 on server endpoint made no difference. am missing on getting 2 play nice 1 another? by default appharbor use amazon's internal dns service resolving hostnames. because of amazon rds instances in same region appharbor resolve private ip addresses rather public ones listed in knowledge base article, setting rules based on public ips not work of time. in case amazon's dns servi

java - What is preventing my progress bar from updating? -

i'm writing small function update progressbar , jlabel base on weighted random integers. thread sleeping correctly , random values coming through, however, progress bar , jlabel not updating. it leaving gui unresponsive. isn't locking gui (i'm able click buttons, doesn't execute functions associated buttons). throwing print statement in run() method not printed out. i'm thinking never gets in there. here method far: private void updateprogressbar(int max) { final int maxdiamonds = max; int = 0; while(i <= max) { //get random obstacle found final obstacle o = obstacle.next(); system.out.println("obstacle: " + o.getname()); //get random number of diamonds obstacle int numdiamonds = integer.parseint(numfounddiamonds.next()); system.out.println("number of diamonds: " + numdiamonds); //set currentvalue progress bar final int currentvalue = i; for(int j

python skip useless data and read specific line -

my text file has 20 pages long , need print specific data my text file looks like: 123mcx version 1.5.0 ld=fri apr 09 08:00:00 mst 2008 12/10/12 11:59:03 *************************************************************************************** 1- c ==== cells ==== 2- 1 0 1 $ outside 3- 2 102 -0.001 -1 23 51 4- c 5- 21 3 -4.15e-4 -21 $ detector 6- 22 5 -11.34 -22 21 $ pb 7- 23 6 -7.87 -23 22 $ fe tube 8- c

php - what is the best way the save fpdf into database? -

i'm new in php , want saving pdf database know best way save fpdf database? i'm using blob type save content of pdf want file pdf read table , see content when clicked file. my code content is: $query = "select nomeuser,email,nomevoucher,categoria,preco,confirmacao,filepdf historico limit $start, $per_page"; while ($stmt->fetch()) { if($confirmacao == "a confirmar"){ echo("<tbody >"); echo("<tr><td>$nomeuser</td>"); echo "<td>$email</td>"; echo("<td >$nomevoucher</td>"); echo("<td >$categoria</td>"); echo("<td>$preco €</td>"); echo("<td>$confirmacao</td>"); filepdf name save content of fpdf how can this?

string datetime format to time() unix time format in python -

i know must covered question elsewhere, questions saw on looked going in opposite direction. understand how convert time.time() human-readable datetime format follows: >>> import time, datetime >>> thetime = time.time() >>> thetime 1375289544.41976 >>> datetime.datetime.fromtimestamp(thetime).strftime("%y-%m-%d %h:%m:%s") '2013-07-31 12:51:08' what's function going inverse direction? >>> thetime = '2013-07-30 21:23:14.744643' >>> time.strptime(thetime, "%y-%m-%d %h:%m:%s") traceback (most recent call last): file "<stdin>", line 1, in <module> file "/usr/lib/python2.7/_strptime.py", line 454, in _strptime_time return _strptime(data_string, format)[0] file "/usr/lib/python2.7/_strptime.py", line 328, in _strptime data_string[found.end():]) valueerror: unconverted data remains: .744643 i'd go string seconds since epoch form

php - session_start() cash limit -

at first , should know there other topics similar topic couldn't solve problem after read these topics. so , please go to: link , see error: warning: session_start() [function.session-start]: cannot send session cache limiter - headers sent (output started @ /home3/icompir/public_html/myscript/index.php:1) in /home3/icompir/public_html/myscript/index.php on line 3 i know error has relation headers , sent headers. in "index.php" file , headers doesn't send before "session_start();" ! you can see code of page: <?php include('inc.php'); session_start(); include('header.php'); ?> <title>صفحه اصلی</title> </head> <body><div class="body"> <?php include('navigation.php'); include('sidebar.php'); ?> <div id="content"> <strong>در دست اجرا:</strong> <ul> <li>بهینه سازی اسکریپت.</li> <li>اضافه کردن امکان تغییر پ

iphone - Lock a NSMutableArray of an object but not the rest of my object when using GCD -

i have user class has various properties: @property (strong, nonatomic) nsstring *candid; @property (assign, nonatomic) bool iscandidate; @property (assign, nonatomic) nsinteger responsecode; @property (strong, nonatomic) nsmutablearray *locations; etc one of viewcontrollers may have user property i.e. @property (strong, nonatomic) user *user; and user may passed subsequent viewcontrollers launched modally. when user object first initialized going send method off in grand central dispatch fill locations array via rest. idea time using app gets screen pick location, list downloaded. what want lock locations area when gcd using it, have used like [somelock lock] ... [somelock unlock] in past want locations array locked rest of user object's methods , properties accessible main thread. best way achieve this? i fetch locations in background thread separate array, , assign user when data complete, like: dispatch_async(dispatch_get_global_queue(dispatch_

java - JDBC with MySQL - SELECT ... IN -

using preparedstatement build query looks this... select * table1 column1 in ('foo', 'bar') ...without knowing number of strings in in statement constructing string like... "'foo', 'bar'" ...and passing in ps.setstring() results in: "\'foo\', \'bar\'" which thing, makes approach problem useless. any ideas on how pass in unknown number of values jdbc preparedstatement without dynamically creating query string (this query lives in file easy reuse , i'd keep way)? i tend use method modify query modify query accordingly. basic example omits error handling simplicity: public string adddynamicparameters(string query, list<object> parameters) { stringbuilder querybuilder = new stringbuilder(query); querybuilder.append("?"); (int = 1; < parameters.size(); i++) { querybuilder.append(", ?"); } querybuilder.append(") "); ret

visual studio - Default enter and space key behavior wpf applications -

i'm trying put small application in wpf (a media player) using visual studio 2012 express desktop, , want use space bar pause. unfortunately, space bar, enter key, seem have default behavior in (just before execute commands have programmed them) re-execute or re-raise recent event in window (button clicks, keypresses, etc.). i have tried overriding onkeydown, onkeyup, onpreviewkeydown, , onpreviewkeyup in every combination, no amount of overriding eliminates behavior. have found true in other wpf applications wrote, , in windows forms application put few months ago. default aspect of applications built visual studio? , more importantly, there way rid of it? if override onpreviewkeydown can add logic want, set e.handled true , prevent event bubbling , causing behavior seeing. private void window_previewkeydown(object sender, keyeventargs e) { if (e.key == key.enter || e.key == key.space) { //your logic e.handled = true; } }

Combine Date and Time columns using python pandas -

i have pandas dataframe following columns; date time 01-06-2013 23:00:00 02-06-2013 01:00:00 02-06-2013 21:00:00 02-06-2013 22:00:00 02-06-2013 23:00:00 03-06-2013 01:00:00 03-06-2013 21:00:00 03-06-2013 22:00:00 03-06-2013 23:00:00 04-06-2013 01:00:00 how combine data['date'] & data['time'] following? there way of doing using pd.to_datetime ? date 01-06-2013 23:00:00 02-06-2013 01:00:00 02-06-2013 21:00:00 02-06-2013 22:00:00 02-06-2013 23:00:00 03-06-2013 01:00:00 03-06-2013 21:00:00 03-06-2013 22:00:00 03-06-2013 23:00:00 04-06-2013 01:00:00 it's worth mentioning may have been able read in directly e.g. if using read_csv using parse_dates=[['date', 'time']] . assuming these strings add them (with space), allowing apply to_datetime : in [11]: df['date'] + ' ' + df['time'] out[11]: 0 01-06-2013 23:00:00 1 02-06-2013 01:00:00 2

IntelliJ during debug does not show the values in Spring RedirectAttributes -

when code reaches break point return , expecting see @ least value added in redirattr debug variable shows size of 0 . know why don't see anything? using intellij @requestmapping(value="/hello", method=post) public string hello(final redirectattributes redirattr) { redirattr.addflashattribute("objects", listofobjects); return "redirect:/somewhere.htm"; } redirattr of size 0 when break point reaches return default implementation of redirectattributes - redirectattributesmodelmap extends modelmap uses normal (non-flash) attributes. can add redirectattributes.addattribute(...) methods. internally, implementation uses additional modelmap store flash attributes: private final modelmap flashattributes = new modelmap(); size of structure should change expected when executing code.

css - Resize a Div Based on Height but Retain Aspect Ratio (almost got it) Strange Reload bug -

there lots of solutions maintaining aspect ratio when resizing videos based on width of parent div. of them depend on fact "padding-top" , "padding-bottom" calculated based on width rather height. i'm trying similar, want resize video based on height of parent div. to need create div keeps aspect ratio regardless of height. may sort of lame way it, decided use image because can set height of image appropriate aspect ratio 100% , let height sort out. i close making work. of now, have been able make inner div want do, except not redraw on window resize. however, if resize window reload, works. ideas? here's demo (it's not codepen issue i've done locally well) good thought using image , height: 100% . box same aspect ratio image, doesn't reflow box on window resize whatever reason. here's demo cleaner css , javascript hack fix reflowing on window resize. full page demo code in demo, use 16px 9px data uri image set

Finding values in XML document using Python -

i have following code tries values xml document: from xml.dom import minidom xml = """<soccerfeed timestamp="20130328t152947+0000"> <soccerdocument uid="f131897" type="result" /> <competition uid="c87"> <matchdata> <matchinfo timestamp="20070812t144737+0100" weather="windy"period="fulltime" matchtype="regular" /> <matchofficial uid="o11068"/> <stat type="match_time">91</stat> <teamdata teamref="t810" side="home" score="4" /> <teamdata teamref="t2012" side="away" score="1" /> </matchdata> <team uid="t810" /> <team uid="t2012" /> <venue uid="v21

How do you get the Scope in PDFlib -

i'm starting out in pdflib, , manual (for pdflib 8) says scope ... you can query current scope scope parameter. but have no idea how @ parameter, , internet searches getting me because "get scope" everywhere. i use following construct in php: pdf_get_string($p, pdf_get_option($p, 'scope', ''), '') explanation: pdf_get_option gets current scope integer, , pdf_get_string resolves integer nice string. return "template" or "page". if use pdflib object oriented, code this: $p.get_string($p.get_option('scope', ''), ''); and should easy enough adapt java.

php - What's happening to new lines in my form textarea? -

i have simple form consisting of textarea. within textarea markdown syntax want save database. it's important preserve carriage returns/new lines. when form submitted though, newlines don't seem sent server unless use nl2br() php function. on server, grab contents of message textarea this: $content = $_post['message']; if echo with: echo $content; the text on 1 long line. if echo with: echo nl2br($content); it shows content expected. why this? i'm assuming if save value of $content database new line characters preserved? the browser submits newlines lf characters (= \n ). if output these, browser won't display them because ignores newlines in normal html rendering mode. if convert them <br> tags, browser recognize them. try setting content type text/plain , see browser renders line feeds: header('content-type: text/plain'); echo $content; save data unformatted database, i.e. not convert them <br> ta

html - CSS - td width/height 100% - height not working -

here fiddle of page. http://jsfiddle.net/3bukd/embedded/result/ in content can see key matrix 2 sets of buttons, 1 of top, 1 of left. problem buttons of left button set won't have height strechted 100% of parent td. i've set both width , height 100%, width working. .layout input[type=button] { display: block; margin: 0 auto; width: 100%; height: 100%; } how can fix please ? !

using _.omit on mongoose User in node.js -

i have mongoose user schema built this: var userschema = new schema({ username: { type: string, required: true, index: { unique: true } }, password: { type: string, required: true }, salt: { type: string, required: true} }); i want able send user object client side of application don't want sned password or salt fields. so added following code user model module u serschema.methods.forclientside = function() { console.log('in userschema.methods.forclientside'); console.log(this); //var userforclientside=_.omit(this,'passsword','salt'); var userforclientside={_id:this._id, username:this.username }; console.log(userforclientside); return userforclientside; } i have required underscore module (its installed locally via dependency in package.js). not commented out line - expecting omit password , salt fields of user object did not :( logged object had full set of properties. when replaced used var userforc

Bash Concatenating Strings Improperly -

i have text file list of mercurial repositories in it, in form: ide install installshield i'm writing bash script clone/pull/update repositories based on text file. right i'm echoing before actual cloning. if do: while read line; echo "hg clone" ${master_hg}/${line}; done < repos.txt the output expected: hg clone /media/fs02/ide hg clone /media/fs02/install hg clone /media/fs02/installshield however, if do: while read line; echo "hg clone" ${master_hg}/${line} ${reporoot}/${line}; done < repos.txt the output is: /var/hg/repos/ide02/ide /var/hg/repos/installnstall /var/hg/repos/installshieldshield it seems replacing beginning of string end of string. there kind of character overflow or going on? apologies if dumb question, i'm relative noob bash. your file has dos line endings; \r @ end of $line causes cursor return beginning of line, affects output when $line not last thing being printed before newline.

jQuery drag-and-drop issue without jQuery UI -

i trying drag-and-drop without using jquery ui. (200kb load) i have 2 problems: i not sure how snap dragged element element. know in jquery ui can provide option 'snap' not sure how in plain jquery. where can change cursor pointer icon when drag element? i have following code: var dragging =null; obj = $('table td'); $(obj).click(function(e){ if(dragging){ dragging = null; } else{ dragging = $(e.target); } }) $(document.body).mousemove(function(e){ var el_w = $(obj).width(); var el_h = $(obj).height(); if (dragging) { dragging.offset({ top : e.pagey-el_h/2, left : e.pagex-el_w/2 }) } }) i have searched google of results suggest jquery ui... :( custom build you can download custom version of jquery ui. follow link, go bottom, , click download. draggable only the size 32kb . modern web servers gzip file, result in 8.66kb in transfer. can combined

mysql - SELECT DATE_FORMAT(NOW(),'%m-%d-%Y') in php is not working well -

can me this: $querydate ="select date_format(now(),'%m-%d-%y') dat"; $query = mysql_query($querydate); $row = mysql_fetch_assoc($query); $fecha = $row['dat']; -2013-31+07 returning -2037 and want return today's date 31-07-2013 try select date_format(now(),'%d-%m-%y') dat here have more info format of date

WebGL Read pixels from floating point render target -

there confusion e.g. in terms of support levels rendering floating point textures in webgl. oes_texture_float extension not seem mandate per se, per optional support float textures fbo attachments (deprecated) , looks vendors went ahead , implement it. therefore basic understanding rendering floating point textures works in non-es desktop environments. have not been able read floating point render target directly though. my question whether there way read floating point texture using webglcontext::readpixels() call , float32array destination? in advance. attached script succeeds reading byte texture, fails float texture: <html> <head> <script> function run_test(use_float) { // create canvas , context var canvas = document.createelement('canvas'); document.body.appendchild(canvas); var gl = canvas.getcontext("experimental-webgl"); // decide on types user texture var textype, bufferfmt; if (use_float) {

sql - connect client side java program to access database -

i making practice program using java , access database. program ultimate tictactoe board , databse meant keeping track of names of players , scores. trouble having keep getting these errors. exception in thread "main" java.lang.nullpointerexception @ accessdatabaseconnection.getname(accessdatabaseconnection.java:39) @ ultimate.<init>(ultimate.java:39) @ ultimate.main(ultimate.java:82) with further research found this: [microsoft][odbc driver manager] data source name not found , no default driver specified here code. math little unfinished in sql statements im not worried yet. need connection between program , database. here area of code in constructor program connects accessdatabaseconnections class: accessdatabaseconnection db = new accessdatabaseconnection(); font f = new font("dialog", font.bold, 80); public ultimate() { super("testing buttons"); string dbname = db.getname(); string wins = db.getwins(); str

c# - Opencl kernel buffers leaking after 12k float elements -

ive written dotproduct kernel opencl in c++ , working vector length 4096(also tried 12k elements , working flawlessly) when increase vector length 16k elements, result becomes infinity while should not go beyond small float number. there leak or similar works ok n<16k elements. 16k elements , 4 byte each makes 64kb, 3 buffers sum 192kb , not 1/1000th of memory of gpu. compared result same reduction algorithm host-code(c#) , host result small expected. no precision errors build infinity also(it may capped @ finite value). here kernel(ln= local work size, n= global work size) c# passed c++ through dll-call: "__kernel void skalarcarpim(__global float * v1, __global float * v2, __global float * v3)" + "{" + " int = get_global_id(0);" + " int j = get_local_id(0);" + " __local float biriktirici [" + ln.tostring() + "];" + " barrier(clk_local_mem