Posts

Showing posts from May, 2012

javascript - Html5 audio playlist not working -

i have audio html5 player, since working fine on single audio when adding more audios : pitbull shakira bilal saeed now, click on pitbull (ok working fine) when click on (bilal saeed or shakira) song song playing instead of, pause pitbull , start shakira or bilal saeed. check on jsfiddle html <div id="playlist"> <a href="#"> <span class="glyphicon glyphicon-play-circle"> <audio preload='none'> <source src='http://freshly-ground.com/data/audio/mpc/20090119%20-%20untitled%20groove.mp3' type='audio/mpeg' /> </audio> </span> </a> <a href="#"> <span class="glyphicon glyphicon-play-circle"> <audio preload='none'> <source src='http://audio.khanqah.org/ak20021104%20rozay%20or%20taqwa%20may%20rabt.mp3' type='audio/m...

html - ASP.Net Display value for radio button selected on my confirmationpage -

i have 4pg asp.net form storing data in session , button on 3rd page clears session. working fine i'm having 2 problems radio buttons. first problem on confirmation page (pg3) displaying 'true' or 'false'. want value 'yes' or 'no'. how do this second problem how display selected value on confirmation pg? know if needs wrapped in if statement i'm unsure how write complete brain fart i'm afraid. html page radio button on <div class="form-group"> <div class="col-xs-12"> <asp:label id="label2" class="col-md-2 control-label" runat="server" text="do have kids?"></asp:label> <div class="col-md-3"> <asp:label runat="server" class="radio-inline"> <asp:radiobutton runat="server" id="pg2yes" va...

unit testing - Mockito - Null Pointer Exception -

i have stupidly simple class (right now) takes id , passes along dao. @service public class adhocreportserviceimpl { @autowired private adhocreportserviceimpl adhocreportdao; public list<adhocreportresponsedto> getadhocreportresults(string reportid) { return adhocreportdao.getadhocreportresults(reportid); } } and i'm attempting use mockito verify logic there (this app has no code coverage , i'm trying change bit) @runwith(mockitojunitrunner.class) public class adhocreportservicetest { @injectmocks private adhocreportserviceimpl adhocreportserviceimpl = new adhocreportserviceimpl(); @mock private adhocreportdao adhocreportdao; @test public void getadhocreportresultstest() { list<adhocreportresponsedto> adhocreportresponsedtolist = new arraylist<adhocreportresponsedto>(); adhocreportresponsedto adhocreportresponsedto1 = new adhocreportresponsedto(); adhocreportresponsedto adhocreportresponsedto2 = new adhocrepor...

sockets - PHP simple_html_dom and file_get_html in foreach loop. How to speed up parse time? -

i'm using php simple_html_dom , file_get_html in foreach loop loops 4,000 times. here's i'm doing. i'm extracting content multiple urls on same host. there 4,000+ urls on same host. example.com example url: example.com/product.php?prod=00283 on next pass-thru of loop example.com/product.php?prod=03418 next pass-thru of loop example.com/product.php?prod=08192 etc, etc until 4000+ urls looped over. tested 100 urls took on 1 , half minutes parse , output content. is possible setup multithreaded approach in foreach loop bring contents of 4000 urls simultaneously? in other words, use sockets or other kind of multithreaded approach iterate on urls in parallel? here sample code below can see i'm doing here. include 'simple_html_dom.php'; $partlist_file = 'parts.txt'; $partlist = file('partnumberlist.txt', file_ignore_new_lines | file_skip_empty_lines); $stock = ''; $isfirst = true; $firstline = 'sku,...

.net - Dynamic Start menu WinRT tile for a normal desktop WPF application on Windows 10? -

i remember live tiles on win8/8.1.x possible store apps. with release of windows 10, has changed? did new solutions appear in time since question last asked (besides devexpress control)? you'll able use project centennial things this: https://channel9.msdn.com/events/build/2015/2-692

regex - How do i match a specific input within a string in Java? -

i using regex in line of code: if (line.matches("^.*\b(" + incomingmachineip + ")\b.*$")) so, assume following inputs: incomingmachineip = "10.10.10.10" line = "abcde=10.10.10.10abcedf" i want if condition return true, i'm trying regex above false still returned though value of incomingmachineip found in string (line) any how resolve appreciated. you need escape backslash 1 more times , need remove second \b or replace \b because there isn't word boundary exists between last 0 , letter a if(line.matches(".*\\b" + pattern.quote(incomingmachineip) + ".*")) since you're using matches method, won't require anchors.

php - How to de-link a URL from Symfony link -

i have issue while trying deference url code. want url as: www.imaginar.fr instead getting: http://localhost/epita/web/app_dev.php/questionanswer/cat/www.imaginar.fr my twig code below: <tr><td> <a href="{{ entity.resource}}" target="_blank">{{ entity.resource}}</a></td></tr> my controller code fetches resource data database , trying open resource in new browser without symfony extension $query1 = $em->createquery('select p.id, p.question, p.answer, r.resource, r.cover epitaepitabundle:questionanswer p left join p.resource r p.id :id') ->setparameter('id', $id); $res = $query1->getresult(); without http:// prefix links appended current pages url.

java - How can I do to update a row like a pro? -

package gestionoutilbricolage; import java.sql.*; import javax.swing.table.defaulttablemodel; import javax.swing.jtable; public class fenetrelisteoutil extends javax.swing.jframe { string outil; statement stmta; statement stmt; statement stmtlisteoutil; connexion maconnexion = new connexion(); public fenetrelisteoutil() { initcomponents(); defaulttablemodel model = new defaulttablemodel(); model.addcolumn("nom de l' outil"); model.addcolumn("fabricant"); model.addcolumn("annee de fabrication"); model.addcolumn("prix"); string requetelisteoutil = "select *from outil"; try{ stmtlisteoutil=maconnexion.obtenirconnexion().createstatement(); resultset resultat = stmtlisteoutil.executequery(requetelisteoutil); while(resultat.next()){ mod...

pycharm - Error in running a python script in command prompt -

i running below line in command prompt below code script not being initiated pycharm : i checking directory script exists: k:\pycharmprojects\workshop-robot>dir volume in drive k user_shares volume serial number 569b-2f04 directory of k:\pycharmprojects\workshop-robot 28.07.2015 11:37 <dir> . 28.07.2015 11:37 <dir> .. 23.07.2015 10:12 <dir> .idea 27.07.2015 17:37 837 abbott.robot 24.07.2015 14:20 752 allianz.robot 24.07.2015 16:08 748 diageo.robot 24.07.2015 16:08 756 freenet_ag.robot 24.07.2015 16:09 770 friesland_campina.robot 28.07.2015 11:37 209.277 log.html 28.07.2015 11:38 12.261 output.xml 28.07.2015 11:37 212.337 report.html 29.07.2015 17:45 <dir> resources 28.07.2015 11:37 30.228 selenium-screenshot-1.png 28.07.2015 11:37 30.228 selenium-screenshot-10.png ...

c# - Decrypting CryptoStream into MemoryStream -

i have written process file encrypted , uploaded azure, download process has decrypted fails "padding invalid , cannot removed" error, or "length of data decrypt invalid." error. i've tried numerous solutions online, including c# decrypting mp3 file using rijndaelmanaged , cryptostream , none of them seem work , end bouncing , forth between these 2 errors. encryption process uses same key/iv pair decryption uses, , since decrypt portion of stream feel that's working fine - ends dying above errors. here code, ideas? please note 3 variants ( cryptostream.copyto(decryptedstream) , do {} , while ) aren't run - here show options i've tried, of fail. byte[] encryptedbytes = null; using (var encryptedstream = new memorystream()) { //download azure cloudblockblob.downloadtostream(encryptedstream); //reset positioning reading out encryptedstream.position = 0; encryptedbytes = encryptedstream.converttobytearray(); } //used b...

SQL Select, different than the last 10 records -

i have table called "dutyroster". want make random selection table's "names" column, but, want selection different last 10 records same guy not given second duty in 10 days. possible ? create temporary table 1 column called oldnames have no records initially. each select, execute query select names dutyroster dutyroster.names not in (select oldnamesfrom temporarytable) limit 10 and when execution done add resultset temporary table

JavaScript: Can't access array in object -

Image
i'm experiencing extremely strange behavior when accessing property of object. running code: console.log(myobj); console.log(myobj.items); console.log(myobj); i output in console: how possibly happen? console.log , during execution, outputs string representation of value in console. depending on chrome's mood, might show [object object] or object {} . doesn't matter. now note little blue i beside it. means object has been modified between time logged , time expanded in console, , shows current value (with 2 items), not value during console.log 's execution (no items). can hover on blue i explanation. to replicate issue, open console , run snippet: var obj = {arr: []}; console.log(obj); console.log(obj.arr); console.log(obj); // time, see 2 object logs, 1 empty array // (representation differs time time) // > object // [] // > object obj.arr.push(1,2); // when try expand objects, array of 2 items magically appear...

vigenere - Pset2 Need help encrypting words -

vigenere encrypting message incorrectly example if key "hello" , message hello, encrypted text "eipsv" when should "hello". i appreciate tips on fixing bug. string message = getstring(); int m = strlen(message); int = 0; if(isalpha(message[i])) { for(int j = 0; j < n; i++) { key[j] = tolower(key[j]) - 97; j++; (i = 0; < m; i++) { char c = message[i]; if (islower(c)) { c = (((c - 'a' + key[j%n])%26) +'a'); j++; printf("%c", c); } if (isupper (c)) { c = (((c - 'a' + key[j%n])%26) +'a'); j++; printf("%c", c); } else if (!isupper(c) && !islower(c)) { ...

c++ - Flexible and Non frustrating parameter passing for Request processing system -

preface problem have run surprisingly , must admit there many ways solve can think of, way using variadic function (bye bye type safety), using hash map (more type issues , feels overkill) or condemning users of class repetitive menial tasks getting system work. turning community try , find way this, doesn't hurt soul. the problem use request processor example of paradigm, can see how same may apply other non request processing systems or slight mutations of request processing systems. say have request processor looks : http://pastebin.com/xriga8u3 there multiple instances of request processor (for reasons) , each of them, comments point out, can have own defaultserializedconfiguration . the method unsigned int processrequest(const float nonserializedrequestconfigparam,const requestconfiguration* requestconfig = 0); however accepts "requestconfiguration*" parameter in case particular request needs tweaked params, in general however, instances of reques...

Excel vba can't find date when entered by user -

i'm still new vba , code worked earlier today reason stopped finding date in selected column if present. i'm reading through each row , looking 2 criteria (1. date migration, 2. network). once done, copy rows depending on criteria separate worksheets , consequently save them later on. problem despite date enter, doesn't find anymore - , make sure enter in dd/mm/yyyy format that's underlying format. despite put it boots me err_execute. here kind of data i'm working with: cola pcname (i.e. john's machine) colb user name (i.e. john doe) colc devicetype (i.e. laptop) cold network (i.e. jody's network) cole migration wave (i.e. 1st wave) colf top user of device colg last person login colh location of device coli migration date (looked in workbook still formula) colj user's email colk sr# coll migration date (copied value instead of formula) sub test() dim lsearchrow integer dim lcopytorow1 integer dim lcopytorow2 integer dim lsearchva...

python - Why is my timezone datetime wrong? -

i use code format time time comes out 5 hours wrong. should 06 in calcutta , formats time 01... something. wrong code? def datetimeformat_viewad(to_format, locale='en', timezoneinfo='asia/calcutta'): tzinfo = timezone(timezoneinfo) month = months[to_format.month - 1] input = pytz.timezone(timezoneinfo).localize( datetime(int(to_format.year), int(to_format.month), int(to_format.day), int(to_format.hour), int(to_format.minute))) date_str = '{0} {1}'.format(input.day, _(month)) time_str = format_time(input, 'h:mm', tzinfo=tzinfo, locale=locale) return "{0} {1}".format(date_str, time_str) update this code worked according answer below. def datetimeformat_viewad(to_format, locale='en', timezoneinfo='asia/calcutta'): import datetime dt import pytz utc = pytz.utc to_format = dt.datetime(int(to_format.year), int(to_format.month), int(to_format.day), int(to_format.hour), int...

concatenation - Concatenate two columns based upon another column in SQL Server 2005 -

i have database follows a b 1 ereee 2 ereee 2 sdfsd 3 nere 1 sdfsd i want have data follows a b 1 ereee,sdfsd 2 ereee,sdfsd 3 nere what query? your question didn't specify kind of database. following works mysql , perhaps few others: group_concat(expr) function returns string result concatenated non-null values group. https://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat select a, group_concat(b separator ',') b table group update 2015-07-30 09:43 +0000 since it's been made clear sql server 2005, question might duplicate of this: simulating group_concat mysql function in microsoft sql server 2005?

sql - GROUP BY next months over N years -

i need aggregate amounts grouped "horizon" 12 next months on 5 year: assuming 2015-08-15 sum amount 0 12 next months (from 2015-08-16 2016-08-15) sum amount 12 24 next months (from 2016-08-16 2017-08-15) sum amount 24 36 next months ... sum amount 36 48 next months sum amount 48 60 next months here fiddled dataset example: +----+------------+--------+ | id | date | amount | +----+------------+--------+ | 1 | 2015-09-01 | 10 | | 2 | 2015-10-01 | 10 | | 3 | 2016-10-01 | 10 | | 4 | 2017-06-01 | 10 | | 5 | 2018-06-01 | 10 | | 6 | 2019-05-01 | 10 | | 7 | 2019-04-01 | 10 | | 8 | 2020-04-01 | 10 | +----+------------+--------+ here expected result: +---------+--------+ | horizon | amount | +---------+--------+ | 1 | 20 | | 2 | 20 | | 3 | 10 | | 4 | 20 | | 5 | 10 | +---------+--------+ how can these 12 next months grouped "horizons" ? i tagged postgresql i...

Getting password and username in spring -

have configuration fails build in netbeans please missing. using wicket <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi= "http://www.w3.org/2001/xmlschema-instance" xmlns:security="http://www.springframework.org/schema/security" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd"> <security:authentication-manager alias="authenticationmanager"> <authentication-provider> <jdbc-user-service data-source-ref="datasource" users-by-username-query="select username,password registration username=? , password = ?...

javascript - React.js: Uncaught TypeError: Cannot read property 'tasks' of undefined -

first time using react.js. building todo app react.js front end , rails backend. tasks.js.jsx file: "use strict"; var list = react.createclass({ renderitems: function() { return _.map(this.props.tasks, function(task) { return <li classname="list-group-item pointer" >{task.name}</li>; }); }, render: function() { return <ul classname="list-group"> {this.renderitems()} </ul>; } }); var tasks = react.createclass({ getinitialstate: function(){ return { tasks: this.props.data } }, getdefaultprops: function(){ return { tasks: [] } }, renderlist: function(complete){ return <list tasks={_.filter(this.state.tasks, function(x) { return x.complete === complete; })} />; }, render: function() { return <div classname="todos"> <div classname="incomplete-todo...

email - php mail() not sending after upload to my host -

this question has answer here: php mail function doesn't complete sending of e-mail 24 answers i have finished developing website on localhost tested mail() function , worked perfectly. but when went ahead , uploaded hosting, no email coming trough. looks if working, validation working , no email coming trough? maybe host blocking outgoing mail? quite common hosts limit mail functionality in war against spam. i suggest check hosting provider whether have mail privileges.

VLOOKUP with String in google-spreadsheet -

so iam trying is: find string in spreadsheet1!a:a , give value in b:b right next found value in a:a output. my approach: =vlookup(b1;spreadsheet1!a:a;spreadsheet1!b:b) the problem: vlookup wont give strings value. need string formula. there workaround, not include scripting? thank you! try this: =vlookup(b1;spreadsheet1!a:b;2,false) b1 should value can found in spreadsheet1!a:a

PHP 5.5 : how to convert array with 1 element to property of parent -

i have this: $foo = foo::getfoobyid(100); public static function getfoobyid($id) { return foo::where('id', $id)->with('locations')->firstorfail(); } this returns eloquent collection. $foo gives following properties: $foo->name $foo->locations $foo->locations array 1 element just want: $foo->location = $foo->locations[0]; unset($foo->locations); this code works, terrible, because happens on different places. how can in clear way? you haven't shown it, assume you've defined foo having one-to-many relationship locations. if there single location given foo, should define one-to-one relationship rather one-to-many, you'll able $foo->location single location object rather $foo->locations array of them. in other words, guess have code in foo model looks this: public function locations() { return $this->hasmany('locations'); } you need replace more this: public function locat...

asp.net - website cannot be started another website may be using the same port -

trying set default website in iis. when trying start website error message: "website cannot started website may using same port." i don't see other bindings on port 80 in iis. there way determine else might using port on machine? thanks go cmd, type netstat -a local address or local port 80, or http

java - Getting Exception: "Read a negative frame size (-2147418110)!" While running hive queries multithreading way -

i've integrate hive, hdfs, sqoop functionality java & working fine. executing in sequential manner . so i'm trying implement multithreading improve performance. this sample template of workflow. 1) main java class --> calling 1 dao class function:(in method i've write several hive opertation join on table, group etc. inserting matched result antoher tables) 2) in dao class there lots steps(loading data hdfs, filter out records & insert table etc.) figured out steps independent of each other. put steps 4 different threads, step execute in parallel. 3) in 4 threads i'm calling functions of other class, again performaing different hive queries. i'm performaning operation on hive parallely. so here quesion 1) can execute hive queries in multithreading ways? 2) if yes. parameters need set in hive-site.xml file?. 3) can hive handle concurrent jdbc statements? this exception i'm getting java.sql.sqlexception: org.apache.thrift.tra...

Is there a pure Javascript equivalent to jQuery's $.fn.extend? -

in jquery this: $.fn.extend({ hello: function() {console.log(this + ' says hello world.')} }); and $('div').hello(); can in pure javascript without loading whole jquery that? well, technically this: function extendingqueryselector(selector, extension) { var el = document.queryselector(selector); for(var key in extension) { if(extension.hasownproperty(key)) { el[key] = extension[key]; } } return el; } though doesn't seem idea extend basic dom objects. there's no jquery wrapper around here, though of course make such wrapper.

wso2esb - How ro read files from multiple locations using wso2 vfs transport? -

this proxy service developed using wso2 service.. <parameter name="transport.vfs.fileuri">file:///home/user/test/in</parameter> <!--change--> <parameter name="transport.vfs.contenttype">text/xml</parameter> <parameter name="transport.vfs.filenamepattern">.*\.xml</parameter> <parameter name="transport.pollinterval">15</parameter> <parameter name="transport.vfs.moveafterprocess">file:///home/user/test/original</parameter> <!--change--> <parameter name="transport.vfs.moveafterfailure">file:///home/user/test/original</parameter> <!--change--> <parameter name="transport.vfs.actionafterprocess">move</parameter> <parameter name="transport.vfs.actionafterfailure">move</parameter> <target> <endpoint> <address format=...

Memory consumption for Spark SQL with aggregation function -

i have hive table few bigint or string columns, on 38 million rows, total size on 1gb, test environment small standalone cluster 4 worker nodes , each has 8gb memory, spark 1.4. spark-sql shell, tried execute sql create table bla select user_id, brand_id, sum(cnt) foo group user_id, brand_id several times , job got stuck in first stage few tasks hanging. gc report seems indicate there not enough memory store transient objects , process waiting full gc finish. gc output 1 hanging node: 4572.821: [gc [psyounggen: 1707488k->595392k(1963136k)] 5871286k->5321918k(7555584k), 1.2474880 secs] [times: user=16.32 sys=0.43, real=1.25 secs] 4575.891: [gc [psyounggen: 1739840k->559488k(1970304k)] 6466366k->5882382k(7562752k), 0.9950000 secs] [times: user=12.69 sys=0.72, real=1.00 secs] 4576.886: [full gc my question is: sql need more 32gb memory run against 1gb data? or there quick optimization settings missed? sql executed less amount of records, or full d...

java - Is it possible to filter MongoDB query results? -

i developing simple web application fetches data mongodb. what need do, show data matching query on webpage. let's user has choose programming language [java, c#, python] project creation time [all, max week ago, max month ago] implemented algorithm [heapsort, quicksort, mergesort] now, mongodb collection contains types of object, of not algorithm @ (this unavoidable, unfortunately). because of fact, have specific query finds documents eligible further processing. finditerable<document> docs = collection.find(filters.ex(programminglanguage)); and here comes final question: when have finditerable object, can filter specific documents selected documents chosen? for example, need line of code, give me documents created no longer month ago written in java, given docs object. desirably implement this: create function applies additional filter on finditerable object public static finditerable<document> applylastmonth(finditerable<document...

jquery - How to correctly select default option in list? -

i have 6 lists whiich populate via script. im using angular js , html looks this: <div class="advancedsearch hidden"> <div class="col-md-4 col-xs-12"> <select name="number" ng-model="numbers" ng-change="listsearchchnage(numbers, 'number')" class="form-control" > <option value="">choose nummer</option> <option ng:repeat="number in numbers" value="{{number}}">{{number}}</option> <!-- select month --> </select> </div> <div class="col-md-4 col-xs-12"> <select name="objdesc" class="form-control" ng-model="objektdescriptions" ng-change="listsearchchnage...

gradle - Coverage on Android Build -

i trying coverage android project based on gradle. so add application build.gradle jacoco { } and testcoverageenabled true inside debug. this working ok . can report createdebugcoveragereport or connectedcheck . the problem debug builds used developers run , test app. having code coverage enabled inside build might slow build , not needed usage. so thought add new configuratuon coverage { initwith buildtypes.debug testcoverageenabled true } unfortunately there no createcoveragecoveragereport , connectedcheck not run coverage type. when decompile apk dex2jar , inside jd-gui see jacoco calls inside debug , coverage there not launched gradle plugin coverage. this makes me think coverage hardcoded debug builds. the questions are: 1. thinking need coverage buildtype ok ? think debug build should separate of build coverage 2. jacoco report available in debug build? if not how run on coverage type? 3. can find source code of jacoco exte...

java - How configure Spring-Boot app to continue to use RestEasy? -

i have old web application (pure servlet, without spring) want run fat-jar. app provides lot of rest services. don't want modified old code. how configure spring-boot app continue use resteasy? you can use resteasy spring boot starter. here how it: adding pom dependency add maven dependency below spring boot application pom file. <dependency> <groupid>com.paypal.springboot</groupid> <artifactid>resteasy-spring-boot-starter</artifactid> <version>2.1.1-release</version> <scope>runtime</scope> </dependency> registering jax-rs application classes just define jax-rs application class (a subclass of application) spring bean, , automatically registered. see example below. see section jax-rs application registration methods in how use resteasy spring boot starter further information. package com.test; import org.springframework.stereotype.component; import javax.ws.rs.applicationpath; impor...

node.js - On Gitbash - Bower : ENOGIT git is not installed or not in the PATH -

Image
i have project bower.json file , im trying load it's bower libraries on windows. turn on gitbash, cd project directory , type in bower install / bower update. receive error: bower enogit git not installed or not in path but there path git: $ git /bin/git so wierd thing works in cmd on windows, but doesnt work gitbash . value have in system path env variable regarding git: c:\program files (x86)\develop\vcs\git\cmd i tried re-install msysgit , chose option: run git windows command prompt so: it still doesnt seem work.. bower version: $ bower --version 1.4.1 git version: $ git --version git version 1.9.5.msysgit.1 bower installed globally using npm edit: found cause of issue: have file in profile home directory .bashrc use in order define general aliases , on , added line: export path="~/appdata/roaming/composer/vendor/bin":$path and somehow when line present receive error in gitbash, wierd though, add path global composer packag...

javascript - req.body empty for textarea in http form (Using Express) -

i have following form have user upload file , submit text: form(action='/createpost' enctype="multipart/form-data" method='post' id="imgform") input(type='file' name='imgpath' size = "60") br textarea(name="posttext" form="imgform") enter post text here... br input(type='submit' value="submit") when run this: router.post('/createpost', function(req,res){ console.log("post form body", req.body.posttext); res.end(); }); i undefined in console. how value of input inside textarea? try removing enctype="multipart/form-data" part in form , see if works. think servers interpret data sent in multipart differently. i don't know if understand enctype="multipart/form-data" does, i'd use when uploading file form , node module multiparty

user interface - Why does Qt ColumnView widget crash in this situation? -

i'm testing application in qt uses qcolumnview widget. widget has 2 columns , when item in first column (parent) clicked, it's items (children) shown in second column. the problem i'm having this: if parent has more children there parents, application crashes if of "excess" children selected. in other words, if there 5 parents , each parent has 5 (or less) children, fine. however, if parent has 6 or more children, application crashes if child index greater the first 5 selected. i hope above clear. thanks. it turns out needed following: if(!hasindex(row, column, parent)) return qmodelindex(); in "qabstractitemmodel::index()" function. didn't think view widget call "index()" out of bound row/column combinations since can use "qabstractitemmodel::rowcount()" , qabstractitemmodel::columncount()" structure of model.

performance - Why is dict faster than if-else in python? -

i tried compare dict , if-else faster follows. d = { str : lambda x: "'%s'" % str(x), int : lambda x: str(x), float: lambda x: str(x), } items = ['a', 'b', 'c', 1, 2, 3, 4, 5, 1.0] def use_dict(): r = [] in items: r.append(d[type(i)](i)) return r def use_if(): r = [] in items: if isinstance(i, str): r.append("'%s'" % str(i)) elif isinstance(i, (int, float)): r.append(str(i)) return r if __name__ == '__main__': timeit import timeit print 'use_dict:', timeit(use_dict) # -> use_dict: 9.21109666657 print 'use_if :', timeit(use_if) # -> use_if : 10.9568739652 i found dict faster if-else. means when want write switch-statement, dict better solution. have doubt why dict faster? can explain it. thanks. if want idea of how code executes, take @ dis module. a quick example......

ios - Add a type function to a Swift unit test target -

how 1 go making type function (defined in extension) visible test target in swift? if have following extension in project: extension nsdata { class func xor(inputdata: nsdata, withkey key: nsdata) -> nsdata { ... return nsdata(bytes: output.baseaddress, length: inputdata.length) } } the xor function visible the main project not in test target. have @testable import mymodule in test file. (as aside, interestingly variables added in extension visible test target). there 3 ways (that can recall) of making function visible within test target. add test target target membership of file containing extension. promote function internal (which implicitly set omitting access modifier) public . upgrade xcode 7 beta , use swift 2's new @testable attribute import module. doing implicitly promote internal variables/methods/etc public make them visible within tests target. @testable import mymodule

node.js - Koa-pg Can't find module pg -

hey i'm trying nodejs koa talk postgres using koa-pg module, keep getting 'can't find module pg' error. i've tried follow koa-pg examples, have come short...so advice on how progress appreciated. if created app.js file follows: var koa = require('koa'); var route = require('koa-route'); var koapg = require('koa-pg'); var roads = require('./controllers/roads'); var app = module.exports = koa(); app.use(route.get('/roads/bbox/', roads.bbox)); app.listen(3000); console.log('listening on port 3000'); and created controller file follows: var credentials = require('../credentials.js'); var environment = credentials.dev; app.use(koapg('postgres://' + environment.user + '@' + environment.host + ':' + environment.port + '/' + environment.database)) module.exports.bbox = function * bbox(next) { var result = yield this.koapg.db.client.querypromise('select now()') ...

bash - How to Pass Quotes "" in a shell argument to java with argument containing white spaces -

i trying execute following command ./launch.sh -version 212 -file "/root/desktop/local test/list.csv" the launch.sh assigns arguments variable my_variable when value assigned quotes around file path removed , echo $my_variable gives following result: ./launch.sh -version 212 -file /root/desktop/local test/list.csv now launch.sh calls java , gives my_variable argument but java splits argument file , try process /root/desktop/local , end error while should taking /root/desktop/local test/list.csv . how can ignore white spaces in java argument or keep quotes while assigning value variable make sure give correct arguments. you can try add 2 escaped quotes ( \" ) this: "\"/root/desktop/local test/list.csv\""

php - Mysql query for sorting Time in hms format -

i trying sort data in mysql descendingly based on time videos. i have video_duration column in database in store time videos in hms format( example 1h54m3s, 9m3s, 0m3s). when try sort database using query below getting output 9m0s, 9m0s first instead of time more time(like 1h35m29s). i using following query sort database $sql = "select * videos category_name='$category' order video_duration desc limit 50"; can guys me solve problem unfortunately data saved database not in best way. varchar sortable follows rules of alphabetical order. example if want order first 12 numbers with: select top 12 value number_in_order order value asc i obtain this: 0 1 10 11 2 3 4 5 6 7 8 9 that wrong. the correct way handle length of video files using int field store amount of seconds , via php retrive value , format in user-readable way. what suggest create new column called "new_video_duration" int, using simple routine in php read data varc...

ColdFusion (9) mysteriously removes characters 'D' and 'F' after numbers when exporting to Microsoft Excel (2007) -

here's code snippets example: thesheet = spreadsheetnew("rates","true"); spreadsheetaddrow(thesheet,"4a,4b,4c,4d,4e,4f,4g,4h,4i,4j"); spreadsheetaddrow(thesheet,"4k,4l,4m,4n,4o,4p,4q,4r,4s,4t"); spreadsheetaddrow(thesheet,"4u,4v,4w,4x,4y,4z,4d4,4f4"); and <cfheader name="content-disposition" value="attachment; filename=#gettickcount()#.xlsx"> <cfheader name="expires" value="#now()#"> <cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" variable="#spreadsheetreadbinary(thesheet)#"/> the issue "4d" , "4f" (and not others) lose 'd' , 'f' , formatted number. i tried this: formattext = structnew(); formattext.dataformat="@"; spreadsheetformatcolumns(thesheet,formattext,"1-10"); i verified set format in excel "text", see number 4 in text-formatted c...

How to hide image with src in wkwebview when loading html in ios? -

i'm using wkwebview loading html string, end of html string have few of ugly image links, want hide them. the css use hide image, not works. .article img[src* = "/smilies/"], .article img[src* = ".feedburner.com/~ff/"], .article img[src* = ".feedburner.com/~r/"], .article img[src* = ".feedblitz.com/"] { display: none; } the sample html string feedburner src want hide : <div> <a href="http://feeds.feedburner.com/~ff/venturebeat?a=h9eoocii8xi:sanx3-jfwnw:yil2auoc8za"><img src="http://feeds.feedburner.com/~ff/venturebeat?d=yil2auoc8za" border="0"></a> <a href="http://feeds.feedburner.com/~ff/venturebeat?a=h9eoocii8xi:sanx3-jfwnw:qj6idk7rits"><img src="http://feeds.feedburner.com/~ff/venturebeat?d=qj6idk7rits" border="0"></a> <a href="http://feeds.feedburner.com/~ff/venturebeat?a=h9eoocii8xi:sanx3-jfwnw:v_sglipbpwu"...