Posts

Showing posts from February, 2014

python 3.x - Accessing values in a dictionary -

here dictionary: {'request': [yearcount( year=2005, count=646179 ), yearcount( year=2006, count=677820 ), yearcount( year=2007, count=697645 ), yearcount( year=2008, count=795265 )], 'wandered': [yearcount( year=2005, count=83769 ), yearcount( year=2006, count=87688 ), yearcount( year=2007, count=108634 ), yearcount( year=2008, count=171015 )], 'airport': [yearcount( year=2007, count=175702 ), yearcount( year=2008, count=173294 )]} i need figuring out how access yearcount - count value. because i'm trying find letter frequency of each word such 'request', 'wandered', , 'airport'. count total number of each letter occurring in words in input data set. number divided total number of letters in words. if that's dictionary can access list of yearcount objects doing: objects = my_dict['request'] you can iterate on list , access .count values: for year_count in objects: print(year_count.count)

shell - LInux restore script returning unexpected token -

i creating recycle bin restore function linux. far have 1 script moves file recycle bin restore script not working. the purpose of restore script promt user directory move selected file recycle bin directory. when run script encounter error "unexpected token; fi" or whatever token try end file with. can see error in script? #!/bin/bash #changes directory location of recycle bin while read -r filename echo "where file restored to?" read newlocation mv -i ~/recycle/$filename $newlocation echo "file has been restored!" fi the syntax of while loop wrong. in bash while loops should this: while read -f filename ; # here goes loops body code done notice how added " ; " in loop head , how close loop "done" instead of "fi".

java - Spark Streaming App submit through code -

i trying submit spark streaming application through code sparkconf sparkconf= new sparkconf(); javastreamingcontext jssc = new javastreamingcontext(master, appname, new duration(60*1000), sparkhome, sparkjar); have given obsolute path dor sparkjar , sparkhome master spark://xyz:7077 i tried submitting batch processing in same way , worked not working streaming following error.. 14/11/26 17:42:25 info spark.httpfileserver: http file server directory /var/folders/3j/9hjkw0890sx_qg9yvzlvg64cf5626b/t/spark-cd7b30cd-cf95-4e52-8eb4-1c1dccc2d58f 14/11/26 17:42:25 info spark.httpserver: starting http server 14/11/26 17:42:25 info server.server: jetty-8.1.14.v20131031 14/11/26 17:42:25 info server.abstractconnector: started socketconnector@0.0.0.0:50016 14/11/26 17:42:25 info server.server: jetty-8.1.14.v20131031 14/11/26 17:42:25 info server.abstractconnector: started selectchannelconnector@0.0.0.0:4040 14/11/26 17:42:25 info ui.sparkui: started sparkui @ http://xxx.xx.xxx.xx:4040

c++ - Do Vectors resize automatically? -

i sorry asking such beginner question finding contradictory information online. ask @ university out until february next year. do vectors resize automatically? or need check current size periodically , resize when need more room. looks resizing me automatically i'm not sure if feature or compiler waving magic wand. if use push_back or insert , yes vector resizes itself. here demo: #include<iostream> #include<vector> using namespace std; int main() { vector < int > a; a.push_back(1); a.push_back(2); a.push_back(3); (int value : a) { cout << value << " "; } cout << endl << "current size " << a.size() << endl; return 0; } it gives output as: 1 2 3 current size 3 remember if a[3] = 5 . not resize vector automatically. can manually resize vector if want. demo append following code above code. a.resize(6); (int value : a) { cout << <

java - Coordinate Issues with ImageButtons -

i programming android app/game allows users purchase buildings drag , drop imagebuttons (implementing drag , drop api). when user drags buildings around, coordinates stored in sqlite database when dropped. say user buys 2 buildings: first colonyhut , second homehut. user places 2 buildings wherever wish, coordinates of buildings saved. issue when app closed , opened again. whenever app loads up, wherever second building (homehut) left first building (colonyhut) be. i have been fighting issue forever , not why first building continually take coordinates of second building when second building moved. here code check see if these 2 buildings have been purchased previously. if have dynamically created , inserted view. newhomehutoneid = prefs.getint("newhomehutone", 0); if (newhomehutoneid != 0) { data.open(); homehutonex = data.gethomehutonex(); homehutoney = data.gethomehutoney(); data.close(); newhomehutframe = (fr

sap - How to transpose an internal table rows into columns? -

i want transpose internal table rows column , want fix first column,i trying following code not getting expected result....it not converting rows columns *types declaration types: begin of ty_t001w, ekorg type t001w-ekorg, werks type t001w-werks, name1 type t001w-name1, end of ty_t001w. **field symbols declaration field-symbols: <fs1> type any, <fs2> type any. **internal table , work area declaration data: it1_col_row type standard table of ty_t001w, wa1_col_row type ty_t001w, it2_col_row type standard table of ty_t001w, wa2_col_row type ty_t001w, cline type sy-tabix. **filling internal table data select * t001w corresponding fields of table it1_col_row ekorg = p_ekorg , fabkl = p_fabkl. **looping internal table display data loop @ it1_col_row wa1_col_row. write: / wa1_col_row-ekorg, wa1_col_row-werks,wa1_col_row-name1. endloop. write: /. **looping internal table chan

php - Running functions on form data before/during validation in Yii 2 -

ok, example if entering username , want make lowercase before or @ beginning of validation (in rules method) how can this? i know can similar trim such as: [['company_name', 'first_name', 'last_name', 'email', 'username', 'password', 'password2'], 'trim'] but assume doesn't support function? so, want run strtolower function on username, way go doing this? need use beforevalidate method or can this? ['username', 'makelower'] public function makelower($attribute, $params) { $this->$attribute = strtolower($this->$attribute); } you can use filtervalidator . ['username', 'filter', 'filter' => 'strtolower'] filtervalidator not validator data processor. invokes specified filter callback process attribute value , save processed value attribute. filter must valid php callback following signature: function foo($

python - how to send email confirmation mail, after post_save signal with djanago-allauth -

i using django-allauth in webapp account management. i have user model , userprofile model. when user gets signs creates user(an instance in user model). userprofile assosiated model user. allauth default sends email when user signs up,a confirmation email sent user when signs up. now want send email when fills userprofile. i thiking use signals here. when user fill userprofile, call post_save signal , calls function user_signed_up_ facing problem in passing request , user args function. here models.py from django.db import models django.contrib.auth.models import user allauth.account.signals import user_signed_up allauth.account.utils import send_email_confirmation django.dispatch import receiver import datetime class userprofile(models.model): user = models.foreignkey(user, unique=true) are_u_intrested = models.booleanfield(default=false) #this signal called when user signs up.allauth send signal. @receiver(user_signed_up, dispatch_uid="some.u

c - How to determine how many times Time Stamp Counter (TSC) is reset -

i need measure time based on time stmp counter (tsc) reasons. read tsc, using code below: #include <stdio.h> #include <inttypes.h> inline volatile uint32_t rdtsc32() { register uint32_t tsc asm("eax"); asm volatile (".byte 15, 49" : : : "eax", "edx"); return tsc; } inline volatile uint64_t rdtsc64() { register uint64_t tsc asm("rax"); asm volatile (".byte 15, 49" : : : "rax", "rdx"); return tsc; } int main() { while (1) { printf("%" priu64 "\n", rdtsc64()); } } when i've tested it, works fine. except 1 thing. when reaches maximum counter value (some value higher 4,256,448,731, in environment,) counter value gets reset 0 , keeps going on. in situation, there way see how many times tsc has been reset? for example, code below not print correct time difference: #include <stdio.h> int main() { long long star

Mysql/php bind_param set null -

it saying "error: column 'delivereddate' cannot null." $delivereddate = null; $stmt = $connection->prepare("insert orders (receiptid, date, cid, cardno, expirydate, expecteddate, delivereddate) values (?,?,?,?,?,?,?)"); $stmt->bind_param("sssssss", $receiptid, $date, $cid, $cardno, $expirydate, $expecteddate, $delivereddate); the related table is: create table orders( receiptid char(30) not null, date date not null, cid char(30) not null, cardno char(30) not null, expirydate date not null, expecteddate date not null, delivereddate date, primary key(receiptid)); i tried inserting values in mysql workbench , can do: insert orders value (1, '2012-12-10', 1, 1, '2014-2-3', '2012-12-23', null); try this $delivereddate = '2014-11-26 10:40:35'; // date $stmt = $connection->prepare("insert orders (receiptid, date, cid, cardno, expirydate, expecteddate, delivereddate) values

angularjs - Tab is not working in my local machine using angular js -

i trying create tab using angular js.i trying in chrome.referered these code http://jsfiddle.net/wijmo/ywuyq/ , included these file in code <script src="https://ajax.googleapis.com/ajax/libs/ angularjs/1.2.0/angular.min.js"> </script> <link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/ 2.3.1/css/bootstrap- combined.min.css"> <script type='text/javascript' src="http://netdna.bootstrapcdn.com/ twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script> got result these way bootstrap tab component content of first tab. content of second tab. i have no idea,why these not working in site?is nt problem of chrome version?anybody me?my chrome version version 39.0.2171.71 m you need include bootstrap dependencies it. suggest know bootstrap before going forward. you cant create in fly. tabs part of bootstrap looking for. add 2 li

html - inline-block img elemets have a gap when start a new line? -

when display img inline-block.but there gap between first line , second !! below sample, picture1 , picture3 have gap?i dont't want gap..so me.. img { display:inline-block; width:200px; background-color:#ccc; border:5px solid red; padding:10px; text-align:center; margin:0px; } <img alt="picture1"/><img alt="picture2"/><img alt="picture3"/><img alt="picture4"/> images make gap default, can fix using vertical-align img { display: inline-block; width: 200px; background-color: #ccc; border: 5px solid red; padding: 10px; text-align: center; margin: 0px; vertical-align: middle; } http://jsfiddle.net/opz672zn/

javascript - How to make a JSON String Valid, if it's not? -

i have requirement json string other api, , string may or may not valid json string. how check if json string valid or not, if it's not valid, how can make valid ? mean ask if there characters need escaped , if not escaped error while parsing. have api make json string valid ? i got code check if json string valid or not javascript if (/^[\],:{}\s]*$/.test('{section : "abcdefghi"jklmnop"}'.replace(/\\["\\\/bfnrtu]/g, '@'). replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[ee][+\-]?\d+)?/g, ']'). replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { console.log('valid'); }else{ console.log('not valid'); } that non trivial problem. depends on definition of "valid" json. can turn string valid json escaping quote characters , treating string. example, {"foo":"bar can become {"stringified":"{\"foo\":\"bar"} and valid,

vimeo - Get all my Video On Demand VOD videos, properties, urls -

i cannot find on vimeo api how vod videos description, title, price , url buy them. ondemand/pages not showing useful info, neither google. anybody knows endpoint or how info? vimeo api endpoints: https://developer.vimeo.com/api/endpoints specifically https://developer.vimeo.com/api/playground/me/ondemand/pages if you're using , doesn't have info need, might have contact support , request added.

c# - Crystal Reports exception in Visual Studio 2013 -

Image
rptdoc.exporttohttpresponse(exportformattype.portabledocformat, response, true, "do- " + datetime.now.tostring("dd-mm-yyyy hhmmss")); above line of code throwing exception: an exception of type 'system.missingmethodexception' occurred in crystaldecisions.crystalreports.engine.dll not handled in user code additional information: method not found: 'crystaldecisions.reportappserver.datadefmodel.propertybag crystaldecisions.reportappserver.reportdefmodel.iscrexportoptions.get_exportoptionsex()' i using visual studio 2013 , crystal reports 13 once faced same issue on production server. until day before working good, next day, error showing up. after long hours struggling issue remembered testing reasons, had changed "application pool settings -> enable 32-bit applications" true, while server 64bit; changed false , got normal. if server 32 make option true, otherwise make false.

ios - Will files copied to the Document folder of an extension be backup by default on iPhone? -

i writing keyboard extension ios 8. sqlite database copied bundle document folder when keyboard started first time (not previous copy of file exists): nsstring *docpath = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0]; nsstring *dbpath = [docpath stringbyappendingpathcomponent:@"work.sqlite3"]; nsstring *bundlepath = [[nsbundle mainbundle] pathforresource:@"default" oftype: @"sqlite3"]; [[nsfilemanager defaultmanager] copyitematpath:bundlepath topath:dbpath error:nil]; in case user restores backup of iphone new iphone in future, work.sqlite3 file restored in new iphone? in place of nsstring *docpath = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0]; use func getthefilepath() -> string { var url = nsfilemanager.defaultmanage

eclipse - Android adb Logcat going crazy with some devices connected -

i'm using eclipse since long time android developing , adb logcat works fine devices. tablet, when connect device 'all messages (no filters)' run fast , messages in filters disappear fast, when application sleeping... can't ready anything. can't understand how can happen. if set logcat 'all messages (no filters)' catch every kind of event going on application and android tablet. you must add project package-name filter in order receive log events app you're developing.

android - How to get focusable in a windowmanager view -

i use windowmanager create view , add view screen,but cannot view focusable.i think set windowmanager.layoutparams correct. @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.fragment_main); pushview = layoutinflater.from(getapplicationcontext()).inflate( r.layout.push, null); btn = (button) findviewbyid(r.id.btn); cancelbtn = (button) pushview.findviewbyid(r.id.cancelbtn); windowmanager = getwindowmanager(); handler = new myhandler(); pushview.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { system.out.println("onclick"); windowmanager.removeview(pushview); } }); btn.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { windowmanager.layoutparams params = new windowmanager.layoutparams(

android - How to tag audio player for opening audio files from other apps? -

i working on music player application. when click audio file file browser, list of apps appear, can open audio file. how make player appear on list? below code have added in manifest launching activity. <activity android:name="com.view.homeactivity" android:label="@string/app_name" android:screenorientation="portrait" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> i tried following code taken : how tag video player opening video files other apps? <intent-filter> <action android:name="android.intent.action.music_player" /> <action android:name="android.intent.category.app_music" /> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> &l

html - select first element of the same class -

how access first of many grouped element of same class? lets have looks this: <div class="group"> <div class="element"></div> <div class="element"></div> <div class="element"></div> <div class="element"></div> </div> <div class="group"> <div class="element"></div> <div class="element"></div> <div class="element"></div> <div class="element"></div> </div> <div class="group"> <div class="element"></div> <div class="element"></div> <div class="element"></div> <div class="element"></div> </div> i change style first element of each group. how can achieved? tried .group{ .element:first{ ####styles

node.js - How to start nodejs server from QT program? -

im working on qt program using nodejs (communicate socket). how can start nodejs server automatic qt application? i have installed 'forever' module start node server easy. qt code: qprocess p; p.start("cmd.exe", qstringlist()<<"/c"<< qapp->applicationdirpath() + "/debugreq/startnode.bat"); p.waitforfinished(); qdebug() << p.readallstandardoutput(); i know works because shows script's outputs. startnode.bat: forever start server.js server works when run clicking startnode.bat file when run qt show outputs server doesnt start. doing wrong?

hibernate - Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType -

i new in java reflection. i checked lot of forums, haven't found working solution. the error: caused by: java.lang.classcastexception: java.lang.class cannot cast java.lang.reflect.parameterizedtype comes when trying object db: new unit().getby(3l); the method declaration @mappedsuperclass public abstract class generic<t extends generic> { @transient public class<t> entityclass; generic() { entityclass = ((class) ((class) ((parameterizedtype) getclass().getgenericsuperclass()).getactualtypearguments()[0])); } @id @generatedvalue(strategy = generationtype.table) public long id; public t getby(long id) { return jpa.em().find(entityclass, id); } second level extension @mappedsuperclass public abstract class genericdictionary<t extends generic<t>> extends generic<t> { @required public string name; @required public boolean active = true; public string ge

c# - Catch Exception thrown by ASYNC DelegateCommand.Execute() when used as ICommand -

i'm using delegatecommands (prism) inside viewmodels expose outside icommands. the caviat is: delegatecommand.execute implemented task execute(...) whereas icommand.execute implemented simple void execute(...). i noticed this, because exceptions swallowed in execute handler. while typical behaviour asyncs not awaited did not expect occur icommand.execute (which has no sign of being async). if execute icommand not able catch thrown exceptions delegatecommand since delegatecommands execute() method async whereas icommands not. is there way catch thrown exception when using delegatecommand icommand? [test] public void delegatetoicommandexecute() { var dcommand = new delegatecommand(() => { throw new exception(); }); icommand command = dcommand; command.execute(null); // doesn't fail due exception } making nunit test case async works, visual studio complains have async method without await await icommand.execute not possible. casting explicitly del

How to plot individually colored vectors over a background image in matlab? -

i have background image , vectorfield individual color information each vector want plot on background image: % random background image image = rand(100,200); % random colors color1 = rand(30,30); color2 = rand(30,30); color3 = rand(30,30); % positions x = 31:60; y = 31:60; [x,y] = meshgrid(x,y); % random vectors dx = 10 * rand(30,30); dy = 20 * rand(30,30); % vector @ (x(i,j),y(i,j)) supposed % have rgb color [color1(i,j) color2(i,j) color3(i,j)] % uniformly colored vector field - works fine imshow(image); hold on; quiver(x,y,dx,dy,'color',[0.5 0.75 1]); % - not work imshow(image); hold on; quiver(x(:),y(:),dx(:),dy(:),'color',[color1(:) color2(:) color3(:)]); a simple for-loop leads erasure of background image noted in: image gradually erased when overlayed lines , @ least matlab version r2012b (8.0.0.783). any ideas? the first problem have code is color1 = rand(30,30); color2 = rand(30,30); color3 = rand(30,30); (...) quiver(x,y,dx,dy,'col

ios - How do I select friend ids using the facebook api? -

whenever call fb.apirequest() send invites brings native facebook menu select friends. is there similar call allow me select friend's user ids in similar manner/interface above. i want user can monitor selected friend's scores in app. this first time playing around facebook api, , couldn't find info in fb's documentation. you need call /me/friends after authorizing user_friends permission , develop own selector. keep in mind can friends authorized app too.

javascript - Express + Jade: render an array of partials -

i have partial button looks like: .button button.custom_button(type='button', value='', onclick=#{functionname}) #{functionname} and render partials of res.renderpartials function comes npm install express-partial . and i want to render on user request. have controller method like: var express = require('express'); var router = express.router(); router.get('/buttons', function(req, res) { var funcs = ['func1();', 'func2();', 'func3()', .... ]; // funcs.length > 15 res.renderpartials({ // problem #1: how make in loop // problem #2: why returns func[28] rendering result 'partials/button': {functionname: funcs[0]}, 'partials/button': {functionname: funcs[1]}, .......... 'partials/button': {functionname: funcs[28]}, }); }); question: how render button partials @ once? mean pass array res.renderpartials , avoid encountering

javascript - UTF-8 characters in datepicker -

i'm using datapicker utf8 characters displaying wrong in html décembre or août . files (.jsp & .js) saved utf-8. $( "#datepicker" ).datepicker({ //... monthnames: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembreé', 'décembre'], //... }); also set this: <head> <meta charset="utf-8"> <script src="${pagecontext.request.contextpath}/resources/js/calendar.js" charset="utf-8"></script> <script src="${pagecontext.request.contextpath}/resources/js/datepicker.js" charset="utf-8"></script> try setting utf-8 in script tag example: <script src="/explorer/html/js/datepicker/locales/bootstrap-datepicker.fr.js" charset="utf-8"></script>

php - display text based on category in wordpress -

how can solve following problem. want show different sub headings based on wordpress category being used. this following code: $categ = the_category(' '); if($categ == 'news'){ $second_header = " secondry header displayed here"; }else{ $second_header = "error"; } ?> <h2> <?php the_category(' '); ?></h2> <p> <?php echo $second_header; ?></p> right not working, instead of checking against text 'news' there way check against category id? thanks in advance. you can use following store current category id: <?php $catid = the_category_id($echo=false);?> the echo false stops echo on page , stores variable. can following: <?php $categ = the_category_id($echo=false); if($categ == 1) { $second_header = " secondry header displayed here"; } else { $second_header = "error"; } ?> <h2> <

java - Cannot rename package in Intellij Idea -

i have not troubles renaming packages in idea, but... have "example" package , want rename "enum", idea not allow me that. when create new package "enum", warns me, not able create java classes within. problem??? you cannot rename package enum , because reserved keyword in java. at oracle tutorial page " naming package " says in cases, internet domain name may not valid package name. can occur if domain name contains hyphen or other special character, if package name begins digit or other character illegal use beginning of java name, or if package name contains reserved java keyword, such "int" .

performance issue in C++ codility challenge -

edit: problem algorithmic ( molbdnilo below answer ) failing case o(n2) --> quadratic. people below trying find true worst case o( n log(n) ) time complexity algorithm. i took codility challenge month. took me hour have 100% correct o( n log(n) ) time complexity algorithm. but can see in below got 75% in performance, because 1 of test took 10 times long run. , not why! could point me mistakes ? https://codility.com/cert/view/ https://codility.com/cert/view/certd6ztbr-rjtnqe24v242yrcv/details point 2 contains complete problem description , complete reports (test cases , timing) solution. roughly, add each rope after , update path root (ancestors) added node position, new maximum weight can added "under/below" each ancestors. here code: // can use includes, example: #include <algorithm> #include <vector> #include <map> #include <iostream> using namespace std; // can write stdout debugging purposes, e.

html - setting alternative img source -

i have web app written in aspx. i have img control. if required image not available alt text message displays. is there way set 'alt image' instead? img control relies on updates after default period of 10 seconds if no image acquired set default image instead. handy if there property 'alt image'. i guess use timer check interested in other approaches. thanks the onerror attribute can execute js , set new image shown below <img src="/images/200.png" onerror="this.src='/images/404.png'" >

c - Syntax to set an array-of-structs element via initializer? -

i have following c code: typedef struct { int x,y; } point2d; point2d data[5]; later in code (i.e. not during initialization of data ), want set individual elements of data x/y values. two-statement-code simple: point2d pt = {.x = a, .y = b}; data[3] = pt; but there way in c in single statement? neither of following ideas seems valid c99 code (for gcc 4.8.2): data[3] = {.x = a, .y = b}; data[3] = point2d{.x = a, .y = b}; data[3] = point2d(a,b); //c++-like syntax use compound literal: data[3] = ( point2d ){.x = a, .y = b};

javascript - AngularJS : ngRepeat in Directive with transcluded content -

i trying pass array of objects directive, use ngrepeat inside of directive output passed items in transcluded html. same issue discussed here . i tried different ways, using compile , link function guess can't wrap mind around scoping. suggested solution petebacondarwin - here work, need (want) pass array directive. here current version - plunker directive (function() { "use strict"; function mydirective() { return { restrict: "e", scope: { items: "=" }, link: function link(scope, element, attrs) { var children = element.children(); var template = angular.element('<div class="item" ng-repeat="item in items"></div>'); template.append(children); var wrapper = angular.element('<div class="list"></div>'); wrapper.append(template); element.html(''); element.append(wrapp

c++ - Segmentation Fault in push_back() -

i getting segmentation fault in push_back(), have given below sample code of project. not using image(iplimage*) inside vec since clearing temp (iplimage*) after push_back() my doubt this, should replace... a.cands.push_back(b); ...with... b.frontimg = null; a.cands.push_back(b); ...? the program: #include<iostream> #include<vector> #include<highgui.h> #include<cv.h> using namespace std; struct b { iplimage* frontimg; vector<int> num; b() { frontimg = null; } }; struct { vector<b> cands; iplimage* img1; a() { img1 = null; } }; vector<a> vec; int main() { (int = 0; < 1000; i++) { struct b b; iplimage* temp = cvloadimage("logo.jpg"); b.frontimg = temp; struct a; (int j = 0; j<1000; j++) { a.cands.push_back(b); } vec.push_back(a); //here cvreleaseimage(&temp); //some porcess } } error message comments #0 0x000000

c++ - Force QLineEdit to be a collection of double values -

consider problem. i have qlineedit in tool , should organize support follows. text of lineedit must contain double values, separated comas. f.e. 6.2 , 8, 9.0, 55 must validate, user cannot input other character numbers , comas. should write method convert text vector. thought qregexp , boost::spirit. can hard using these technique. any ideas? use next custom validator. header: #ifndef validator_h #define validator_h #include <qvalidator> class validator : public qvalidator { q_object public: explicit validator(qobject *parent = 0); signals: public slots: public: qvalidator::state validate(qstring & input, int & pos) const; }; #endif // validator_h cpp: #include "validator.h" #include <qdoublevalidator> #include <qdebug> validator::validator(qobject *parent) : qvalidator(parent) { } qvalidator::state validator::validate(qstring &input, int &pos) const { qdebug() << input<< pos;

javascript - Moving links and nodes accordingly with a click of a button D3 -

i have created a force directed graph when click button changes layout chose myself , when click different button goes force layout. i have done transition on time, thing links don't move correctly. move differently nodes. how links in same position nodes time ? also, have button goes force layout. unable go overtime ? how put delay/duration on bringing force layout play?

Update Google Play Store on Android Emulator (Exception:Google Play Services not available due to error 2) -

update google play store on android emulator (exception:google play services not available due error 2) i have problem of ad-mob video in galaxy-nexus device. , don't have device.so thats why wants update android emulator testing application. (i sorry grammar mistakes) . i solved adding permission manifest file com.google.android.providers.gsf.permission.read_gservices. or other way update google services library. suggest locating these files , manually installing them via adb so: adb -install "c:.........\com.android.vending-4452000.apk adb -install "c:.........\com.google.android.gms-4452000.apk or greater version of services

java - Swing Cannot see Horizontal scroll bar -

Image
i want have horizontal scroll bar view whats there in "description" column. when data in 2nd column exceeds want have horizontal scrollbar appear. code: ========= working example =============== import java.awt.*; import javax.swing.*; import javax.swing.plaf.basic.basicborders.marginborder; import javax.swing.plaf.metal.metalborders.tableheaderborder; import javax.swing.table.*; import javax.swing.border.*; public class tablerowrenderingtip extends jpanel { static object[] columnnames = {"allowed commands", "description"}; private final static dimension scrollpanedimenssion = new dimension(70, 200); public tablerowrenderingtip() { object[][] data = { {"one", "allow proxies act tunnels allow proxies act tunnels allow proxies act tunnels for"}, {"two", "allow proxies act tunnels allow proxies act tunnels allow proxies act tunnels for"},

objective c - Get last time with period in iPhone 4 with NSDateFormatter -

i have problem method: -(nsstring *)getlasttimemessagewithperiod:(nsdate*)lastmessagedate { nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; [dateformatter setdateformat:@"h:mm a"]; nsstring *resultstring = [dateformatter stringfromdate: lastmessagedate]; return resultstring; } in iphone 4 (ios 7.1 ) resultstring return " 12:32 " in iphone 5 (ios 8 ) resultstring return " 12:32 " what can problem makes miss period in iphone 4 ? i've tested provided code on ios 7.1 device, , gave me "3:22", problem not device or os version. problem locale, , work - (nsstring *)getlasttimemessagewithperiod:(nsdate *)lastmessagedate { nsdateformatter *dateformatter = [nsdateformatter new]; [dateformatter setdateformat:@"h:mm a"]; [dateformatter setlocale:[[nslocale alloc] initwithlocaleidentifier:@"en_us_posix"]]; return [dateformatter stringfromdate:lastmessagedate];; }

Android Wear device not detected when scanning Bluetooth devices -

i'm doing bluetooth discovery (not bluetooth le) hoping find android wear never found. code discovery i'm pretty sure it's ok, because can find other devices (tv's bluetooth, sony smartband, etc) never sony smartwatch 3. any idea if possible? here's code: final intentfilter filter = new intentfilter(); filter.addaction(bluetoothdevice.action_found); filter.addaction(bluetoothadapter.action_discovery_finished); context.registerreceiver(mbroadcastreceiver, filter); final bluetoothadapter bluetoothadapter = bluetoothadapter.getdefaultadapter(); bluetoothadapter.startdiscovery(); ... private broadcastreceiver mbroadcastreceiver = new broadcastreceiver() { @override public void onreceive(context context, intent intent) { string action = intent.getaction(); if (bluetoothdevice.action_found.equals(action)) { short rssi = intent.getshortextra(bluetoothdevice.extra_rssi, short.min_value);

ajax - jquery basic authentication failing -

consider header info: accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 accept-encoding:gzip, deflate, sdch accept-language:en-us,en;q=0.8 authorization:basic twluzvn0yxi6twluzvn0yxi= cache-control:max-age=0 connection:keep-alive host:* this header info url. trying json value url. url, when accessed alone pops username , password. try1: $.ajax({ type:'get', url: 'http://'+domainname+':9898/*/*', datatype:"json", username: '*', password: '*', async: false }).responsetext; try2 $.ajax({ type:'get', url: 'http://'+domainname+':9898/jolokia/*/*', datatype:"json", crossdomain: true, beforesend: function(xhr) { xhr.setrequestheader("authorization", "basic " + btoa('*' + ":" + '*')); }, async: fal

Split poylines with a grid in AutoCAD -

i have layer in autocad consists of many rectangle polygons (created polylines) same size touch each other. it's grid. , have layer on bottom of consists of many polylines - city boundaries, forest , agricultural areas. want "cut" second 1 according grid polylines split in size of each rectangle of grid. is possible in autocad? think can done arcgis how can autocad? one way find intersection points , redraw polyline segments each grid, delete original polylines. the article @ following link might help: http://www.acadnetwork.com/index.php?topic=181.0

asynchronous - Async Handler for Update Contract States Operation encountered some errors, -

the job called "contract states job" fails every times runs following message. " async handler update contract states operation encountered errors, see log more detail.detail: " i've tried setting trace verbose can't see log, or errors why job failing every time. job crucial contract entity need renew (via plugin) promptly generate contract-detail lines in time other process follow. could please point me log or how can trap error causing job fail? trace displayed errors on contracts not being able update state because totalprice not equal sum of contract lines. further diffing showed "unsupported script" change contract states - causing operation fail on these contracts. the fix have @ "unsupported script" rather.

python - How to recursively crawl whole website using scrapy -

i want crawl complete website using scrapy right crawling single page import scrapy scrapy.http import htmlresponse scrapy.contrib.spiders import crawlspider, rule scrapy.contrib.linkextractors.sgml import sgmllinkextractor scrapy.selector import htmlxpathselector scrapy.contrib.exporter import jsonitemexporter class izodspiderspider(scrapy.spider): name = 'izodspider' allowed_domains = ['izod.com'] start_urls = ['http://izod.com/'] rules = [rule(sgmllinkextractor(), callback='parse_item', follow=true)] def parse(self, response): hxs = scrapy.selector(response) meta = hxs.xpath('//meta[@name=\'description\']/@content').extract() name = hxs.xpath('//div[@id=\'product-details\']/h5').extract() desc = hxs.xpath('//div[@id=\'product-details\']/p').extract() is there way extract meta tags using portia ? there error in rule definition , inside callback. since parse function u

javascript - Templates on dynamic segments -

i have requirement make dynamic form (wizard) has multiple steps. want able add new steps wizard in future (or remove them) don;t create separate routes each step so: this.resource('wizard', { path: '/' }, function() { this.route('step1', { path: '/' }); this.route('step2'); this.route('step3'); this.route('step4'); this.route('step5'); }); i prefer have dynamic segment takes in name of step , loads corresponding template of same name, so this.resource('wizard', { path: '/' }, function() { this.route('step', { path: '/:step' }); }); is @ possible or wishful thinking. i have come solution not sure considered best... i have defined route in router take in dynamic segment name of template: this.resource('wizard', { path: '/wizard' }, function() { this.route('missing', { path: '/:step' }); }); i have created missing route t

javascript - Cloning a ShadowRoot -

i'm trying clone shadow root, may swap instances of <content></content> corresponding distributed nodes. my approach: var shadowhost = document.createelement('div'); var shadowroot = shadowhost.createshadowroot(); var clonedshadowroot = shadowroot.clonenode(true); does not work, " shadowroot nodes not clonable. " the motivation wish retrieve composed shadow tree, may use rendered html markup. edit: on second thought, may not work due nature of shadow dom, reference distributed nodes broken cloning process. composing shadow tree native feature, having searched through w3c spec, unable find such method. is there such native method? or, failing that, manual traversal (replicating tree in process), work?

neo4j - How to return the property of a single element in an array of nodes or relationships? -

if have collection of nodes, each property called name, how return value of property second element? i've tried these far: collectionofnodes[2](name) value collectionofnodes[2].name value thanks try (collectionofnodes[2]).name value

python - Extracting value from nested dictionary -

my dictionary this: query = {'fowl': [{'cateogry': 'space'}, {'cateogry': 'movie'}, {'cateogry': 'six'}], u'year of monkey': {'score': 40, 'match': [{'category': u'movie'}, {'category': 'heaven'}, {'category': 'released'}]}} fowl , year of monkey 2 entities in this. trying extract category values both entities separately no luck. none of these work: query[0] # expecting values fowl query[0]['category'] # expecting category fowl seems wrong query[0]['category'][0] # category space fowl what correct approach? well, query dictionary rather funky, one, 'fowl' , 'year of monkey' values not structured same, cannot aply same data access patterns, or categories being misspelled 'cateogry' . if can, may better off fixing before trying process further. as extracting 'fowl' data: >>&

dbus - How to use DBusWatch functions to receive asynchronous requests? -

i've seen program illustrated in dbuswatch , dbustimeout examples , don't understand why following code used in dispatch() function: while (dbus_connection_get_dispatch_status(c) == dbus_dispatch_data_remains) dbus_connection_dispatch(c); the dbus_connection_dispatch() triggers top level main loop action in dbus library in turn dispatch steps of actions other functions. actual bus message receiving should in user handler function. it can example on the bind9 code apple . message handling triggered in these steps according reading: the select() returns in main loop fd set dbus watch. the main loop calls process_watches() walks tree , call process_watch() . in end, looks dbus message handled call through (*(cs->mf)) ( cs, type, reply, serial, dest, path, member, interface, 0l, sender, signature, message, 0l, 0l, 0l, cs->def_mf_obj); the cs->mf should holding user handler function added dbus_svc_add_filter() .