Posts

Showing posts from March, 2014

java - Formatting a double to 2 decimal places - compilation error -

i'm trying format double 2 decimal places in program i'm writing. i have import java.text.decimalformat; public class testd { double d = 1.234567; decimalformat df = new decimalformat("#.##"); system.out.println(df.format(d));​ } could tell me i'm going wrong? this line giving me errors: system.out.println(df.format(d));​ you need put system.out.println method or in block compile. run need main method. public class test { // class name should start capital public static void main(string[] arg){ double d = 1.234567; decimalformat df = new decimalformat("#.##"); system.out.println(df.format(d));​ } }

css - Best practice for creating inline anchor tags -

so if have anchor list, prefix wont accidently styled css? <ul class="inline-list"> <li><a href="#list1">list 1 </a></li> <li><a href="#list2">list 2</a></li> </ul> <h2 id="list1">list 1 heading</h2> if list1 speciifed in global css, styling. best practice this?

javascript - Google Analytics: Events sent, but not showing up in reports -

i sending events google analytics via ga() function: ga('send', { 'hittype': 'event', 'eventcategory': 'article', 'eventaction': 'purchase', 'eventlabel': window.location.href.split('?')[0], 'eventvalue': r.data.price, 'usebeacon': true, 'hitcallback': function() { googlesent = true; } }); the callback get's executed properly, chrome analytics debuger shows events being sent google analytics. nothing showing – neither in realtime reports nor in regular reports. any ideas can cause particular problem? thanks everyone, today figure out real issue behind behavior was: eventvalue float, has integer, wasn't count on analytics servers. that's all.

html - CSS Clipping Text in Dynamic Header -

i've been trying dynamic header clip text using text-overflow:ellipsis, can't seem working need. have @ we've implemented here https://dl.orangedox.com/selzde notice file name extends on controls, we're trying fix using text-overflow css property. this i've tried .toolbar { width: 100%; height: 45px; background-color: #fff; border-bottom: 1px solid #d5d5d5; } .middle { text-align: center; } .left { text-align:left; } .right { text-align:right; } .border { border:thin solid silver; } .clip { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

c# - Getting started with Xamarin Forms App -

i've been trying xamarin studio create new forms project on osx me no success. i selected files>new solution>c#>mobile apps>blank app , sure enough project gets created. lets call project mvvm now. there 1 folder called mvvm unified codebase, 1 folder called mvvm.drvoid, 1 called mvvm.ios. in untouched state, neither builds work. when building ios, warning pops "warning mt0030: executable name (mvvm.ios) , app name (mvvmios.app) different, may prevent crash logs getting symbolicated properly." tried solution listed here doesn't work. as android, there no build option set up. way run manually right click on mvvm.droid folder, select build, select run. it confuses me no end think why xamarin not set sample projects properly. know doing wrong? or should functional forms application set up? welcome world !!!! sorry, had yell out last statement.. whole-heartedly agree you. xamarin team reason doesn't make easy out of box template

haskell - Confusion with function composition -

beginning learn haskell: *main> map double [1,2,3] [2,4,6] *main> sum (map double [1,2,3]) 12 *main> (sum . map) (double) ([1,2,3]) <interactive>:71:8: couldn't match type ‘[b0] -> [b0]’ ‘[[t0] -> t]’ expected type: (b0 -> b0) -> [[t0] -> t] actual type: (b0 -> b0) -> [b0] -> [b0] relevant bindings include :: t (bound @ <interactive>:71:1) probable cause: ‘map’ applied few arguments in second argument of ‘(.)’, namely ‘map’ in expression: sum . map according answer: haskell: difference between . (dot) , $ (dollar sign) "the primary purpose of . operator not avoid parenthesis, chain functions. lets tie output of whatever appears on right input of whatever appears on left.". ok, why example not work? actual , expected types different, why? after all, according description map should take (double) ([1,2,3]) on input , pass output sum 's input? the reason . allows function take one argument before b

wpf - How to Style AvalonEdit ScrollBars -

i'm trying change thumb color of scrollbars in avalonedit. i've tried number of approaches: style scrollviewer - lots of examples can't of them compile , when don't work. use findtemplate , change thumb colors @ runtime. works in many not cases. all want change thumb color. come'on wpf, throw me bone. please put me out of misery , show me how. follow up: i able of wanted changing default thumb style: <usercontrol.resources> <style x:key="{x:type thumb}" targettype="{x:type thumb}"> <setter property="opacity" value="0.1" /> </style> </usercontrol.resources> however, if try add control template style, has no effect. every time think understand wpf styling, happens convince me know nothing. based on page: msdn you can this: <style targettype="{x:type thumb}" x:key="scrollbarthumb"> <setter property="t

javascript - AngularJS select required -

i'm having issues setting validation select. code reads like html <form name="customerform" novalidate="novalidate" data-ng-submit="submit()"> <li class="has-error" data-ng-if="customerform.country.$error.required"> {{ 'countryrequired' | translate }} </li> <label for="ddlcountries">{{ 'country' | translate }}</label> <select id="ddlcountries" name="country" class="form-control" data-ng-model="selectedcountry" data-ng-options="option.text option in countries track option.id" data-ng-change="countrychange()" required="required"> <option value="" selected="selected">{{ 'selectcountry' | translate }}</option> </select> </form> js controller $scope.countries = []; countryservice.getco

rapache - OpenCPU: how to change the default port? -

is there way have opencpu listening on port different :80 ? it should easy using docker, i'm running dedicated ubuntu machine recommended here . ps. i'm using opencpu-server without opencpu-cache , without nginx. it runs on additional port 8004 default. should able changed in /etc/apache2/sites-available/opencpu.conf file.

java - JNA how do I go from a C int* to a JNA struct -

i have following c code trying map java: int32 query( void* qrybuffer, uint32_t qrylength) { static int8_t sendbuffer[max_request_size]; message* querymessage; ... querymessage = (message*)sendbuffer; memcpy( &sendbuffer[0], &qrylength, sizeof(qrylength) ); memcpy( &sendbuffer[sizeof(qrylength)], qrybuffer, qrylength ); ... query_ex(querymessage); } typedef struct { uint32 length_u; } message; the jna equivalent message struct is: public static class message extends structure { public int length_u; public message() { super(); } protected list getfieldorder() { return arrays.aslist("length_u"); } public message(int length_u) { super(); this.length_u = length_u; } public static class byreference extends omni_message implements structure.byreference { }; public static class byvalue extends omni_message implement

javascript - How to set :hover as default and reset once moused over? -

i working on website has 2 columns of square images. each column has 3 images, 6 images total. each image has hover state text , 'learn more' link. the intent users hover on each image learn more client's company. facilitate users hovering on images, trying force first image have it's hover state default view. if mouse on it, once mouse leaves, resets plain image, , resumes normal hover functionality. if possible, best way accomplish effect? if it's ok use jquery, keep reading. instead of having pseudo class :hover on first item, can give real class such .active , either in markup or through jquery, , make style same :hover . remove class when hovered once. demo: http://jsfiddle.net/96mwjs0x/1/ html <ul> <li>11111</li> <li>22222</li> <li>33333</li> </ul> css li:hover, li.active { color: red; } jquery $(function() { $("li:first-child").addclass("active

jQuery - Find top parent before div (parent of a parent of a parent...) -

my question title bit vague, couldn't think of less confusing, sorry! here's want: find first anchor inside top level div. find top parent of anchor before above div. sorry if still confusing. example: <div id="container"> <div id="thisshouldbeignored"></div> <div id="ignorethistoo"></div> <div id="one"> <div id="two"> <div id="three"> <a href="" class="anchor">hello</a> </div> </div> </div> </div> what want returned here div id of one . here's i'm doing, i'm using .html example. var firstanchor = $('#container a')[0], parentid = $(firstanchor).parent().attr('id'); $(firstanchor).html(parentid); this returns three expect. the next step i'm struggling. how continue parent until hit t

php - Create a multi page PDF from a dynamically created table (div) that is bigger than a single page -

i dynamically creating table using php , mysql containing div , print using jspdf . until table exceeds single page. first page. have spent weeks, hours of reading, trying , testing , can't print more first page. here's have: <!-- jspdf scripts --> <script src="//mrrio.github.io/jspdf/dist/jspdf.debug.js"></script> <script src="//html2canvas.hertzen.com/build/html2canvas.js"></script> $(document).ready(function() { $("#pdfdiv").click(function() { var pdf = new jspdf('p','pt','letter'); pdf.addhtml($('#rentallistcan').first(), function() { pdf.save("rentals.pdf"); }); }); }); i have tried printing page directly formatting doesn't hold. i have tried css using @page page-break-inside: auto doesn't create page breaks. help. to solve problem, there 2 approaches aware of -

angularjs - How can i call send and accept Json object from angular to backend on play frmaework? -

i have written front end in angularjs , end in scala on play frmaework. want send json object angular end calling method returns json object also. have written following code in angularjs, scala , on route file` angular.js $scope.show=function(){ var url="localhost:9000" var urltext= { "url":$scope.url }; $http({ method:"get", url:url+"/geturl", params:{ data:urltext } }) .success(function(data){ $scope.url-title.push(data.title) $scope.url-description.push(data.description) $scope.url-img.push(data.img) }) } controllers.scala object application extends controller{ def returnurl(text:jsvalue):jsvalue ={ val str=(text \ "url").as[string] val obj=new urlpreview() obj.returndescription(str) val jsonobj:jsvalue=json.o

rust - Type hinting structs as traits -

i have method ( journal.next_command() ) who's signature returns command trait. in method attempting return instance of jump struct, implements command trait: trait command { fn execute(&self); } struct jump { height: u32, } impl command jump { fn execute(&self) { println!("jumping {} meters!", self.height); } } struct journal; impl journal { fn next_command(&self) -> command { jump { height: 2 } } } fn main() { let journal = journal; let command = journal.next_command(); command.execute(); } this fails compile following error: src/main.rs:19:9: 19:27 error: mismatched types: expected `command`, found `jump` (expected trait command, found struct `jump`) [e0308] src/main.rs:19 jump { height: 2 } ^~~~~~~~~~~~~~~~~~ how inform compiler jump implements command ? you can't return unboxed traits @ moment, need wrapped in sort of container.

php - Unable to update column with appropriate charset -

i'm experiencing huge issue encoding , more entries go in database. when insert data, characters displayed properly. however, when try update column, characters misread 1 of these: авдвадва . in same time, when insert new rows, data looks in phpmyadmin: &#1050;&#1086;&#1085; . <form action="additem.php" method="post"> <p> <label class='title' for="title"> title</label> <input type="text" name="title" id="title" class="input"/> </p> <p> <label class='description' for="description"> description</label> <textarea name="description" id="description" rows="10" cols="35"></textarea> </p> <p> <input type="submit" class='buttono' name="addentry" id="adde

How to make an HTML table that has rows that drop down under category rows? -

Image
hello trying make html table looks 1 in picture. the 2 columns user on left , score on right. simple. don't know how transition between left , right table. in table users fall under team category. team's score users average score. when table first loads want teams collapsed how on in right table, want user able click on team name , have expand , drop down table on left. can 1 please show example code on how this? have looked on , right solution have make table , have separate lists each team. solution not work since user's score not appear in table's score column. please can provide example code? thanks much! instead of thinking if 1 table perhaps think container multiple sub containers , sub containers can opened , closed. can styled 1 likes, table alternating background color rows. might need js reapply alternating background colors if sub containers have odd or amounts of entries. there several plugins available creating accordions. one: http://j

chef plugin cloudify error while uploading blueprint -

i got error while trying validate , upload blueprint created using chef-plugin cloudify. importing chef-plugin. and error looks like: cloudifyclierror: failed validate blueprint my_blueprint.yaml: missing definition relationship cloudify.relationships.connected_to declared derived relationship cloudify.chef.connected_to this how blueprint.yaml looks like: tosca_definitions_version: cloudify_dsl_1_0 imports: - http://getcloudify.org/spec/chef-plugin/1.1/plugin.yaml node_templates: testserver: type: cloudify.chef.nodes.webserver properties: chef_config: version: 11.18.0 chef_server_url: url validation_client_name: chef-validator validation_key: "" node_name_prefix: chef-node- node_name_suffix: testserver.com environment: _default runlist: recipe[cookbook::recipe] any appreciated. you missing import of types.yaml something along lines of imports: - http://www.getclou

logging - Is a mySQL relational database scalable for holding 80 GBs of additional logs per day? -

i deciding on long term architecture solution storing dns logs. amount of data talking numbers 80 gbs of logs per day @ peak. looking @ nosql databases such mongodb, relational - mysql. want structure solution has 3 requirements: storage: long term project, want necessary capability store 80 gbs of logs per day (~30 tb year!). realize pretty ridiculous, i'm willing have retention period (keep 6 months' worth of logs = 15 tb constant). scalability: long term solution, big issue. i've heard mongodb horizontally scalable, while mysql not? elaboration on received. query speed: close instantaneous querying possible. it should noted our logs stored on intermediary server, not need forward logs our dns servers.

r - how to put the first name of each cell as a row name and order a data in a table frame? -

i have csv looks this my expected output should this: channel_count characteristics_ch1 . . . . . gsm1098572 gps 1 gsm1098573 sra 1 gsm1098574 sra 1 rownames(data) = data$varname

web services - In Rest, what does "Treats the addressed member as a collection in its own right and creates a new subordinate of it." mean? -

i reading answer , , says this: when dealing member uri like: http://example.com/resources/7hou57y ... post : treats addressed member collection in own right , creates new subordinate of it. ... i've googled , found lots of results this exact quote , none of them explain means. can elaborate , use examples? bogdan's answer correct on answer refer means, answer little misleading, because rest not crud http . post not synonym create. the semantics of post method action isn't standardized http protocol. post method submits payload processed targeted resource itself, not server. in way, can get, put, patch , delete methods, resource isn't aware of what's happening itself, server whole job, post, server has ask resource something. this means action using post method must documented in way. clients can assume get, put, patch , delete request follow rfc 7231, final result of post depend on target media type. so, if doc

java - Maze Traversal Algorithm Using Recursion -

i'm trying traverse maze using recursion class. provided template , need input the process of traversing maze; not allowed alter code in way besides being plugged in after this: public boolean mazetraversal (char maze2[][], int x, int y) i have been having hard time , don't know missing. still , ultra noob when comes java , programming in general. hints appreciated. // exercise 18.20 solution: maze.java //program traverses maze. import java.util.scanner; package maze; public class maze { public static void main( string args[] ) { } /** * @param args command line arguments */ static final int down = 0; static final int right = 1; static final int = 2; static final int left = 3; static final int x_start = 2; static final int y_start = 0; static final int move = 0; static char maze [][] = { { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#' }, { '#

linux - Bash warning - argument expected -

the bash script bellow takes mac address variable , finds ip address corresponding mac address. #!/bin/bash read address output="$(nmap -sn -n /ip_address_range/ | grep -b 2 "$address" | grep -e ^.*[0-9].[0-9].[0-9].[0-9] | awk '{print substr($0,22)}')" if [ ${output} = ""]; echo "not found" else echo "${output}" arpspoof -i wlan1 -t ${output} /gateway/ fi although works fine , expected warning when execute , want find out how fix it. output after enter mac address: find.sh: 7: [: =: argument expected /ip_address/ **:**:**:**:*:* **:**:**:**:**:** 0806 42: arp reply 192.168.1.1 is-at **:**:**:**:*:* there multiple errors. shellcheck finds obvious ones: first, missing space here: if [ ${output} = "" ] ^--- required second, you're missing required quoting: if [ "${output}" = "" ] ^-- here -^ this should sufficient rid of error

android - which way to implement in app billing? -

after reading android documentation on developer website, i've realized there 2 ways set purchase: create iabhelper instance base64 string , use request purchase... in no way mentions have use serviceconnection bind the iinappbillingservice android. there seems way have create serviceconnection binds iinappbillingservice , have create bundle etc. is possible use way create iabhelper instance , call methods on instance acquired trivialdrive app ? iabhelper internally uses serviceconnection , binds service when startsetup() on iabhelper. docs state ( http://developer.android.com/training/in-app-billing/preparing-iab-app.html ), still have to include .aidl file in project iinappbillingservice. i suggest alternatives iabhelper. many developers (myself included) have found numerous bugs in implementation. example, queryinventoryasync implementation not handle concurrency correctly. lot of crashes due iabhelper if use it. there numerous alternatives on github.

html - How to modify this CSS based Accordion to work with multiple accordions on the same page? -

hello have using accordion off website: http://www.hongkiat.com/blog/css-content-accordion/ created paul underwood. love accordion looks great simple css. issue want few separate ones on same page. ruins functionality since same class. there way besides copying , pasting , renaming class many times needed they'd have own class? again overall goal have few of these work on same page. here code directly off website: html: <div class="accordion vertical"> <section> <h2>about us</h2> <p>lorem ipsum dolor sit amet,</p> </section> <section> <h2>services</h2> <p>lorem ipsum dolor sit amet,</p> </section> <section> <h2>blog</h2> <p>lorem ipsum dolor sit amet</p> </section> <section> <h2>portfolio</h2> <p>lorem ipsum dolor sit amet,</p> </section>

c# - OdbcConnection open() doesn't work -

protected odbcconnection conectarbd() { string stringdeconexion = "data source=pablozn\\sqlexpress;initial catalog=proyecto2;integrated security=true"; try { odbcconnection conexion = new odbcconnection(stringdeconexion); conexion.open(); return conexion; } catch (exception ex) { label3.text = ex.stacktrace.tostring(); return null; } } the problem when browse website, label shows exception on line number 18 : en system.data.odbc.odbcconnection.handleerror(odbchandle hrhandle, retcode retcode) en system.data.odbc.odbcconnectionhandle..ctor(odbcconnection connection, odbcconnectionstring constr, odbcenvironmenthandle environmenthandle) en system.data.odbc.odbcconnectionopen..ctor(odbcconnection outerconnection, odbcconnectionstring connectionoptions) en system.data.odbc.odbcconnectionfactory.createconnection(dbconnectionoptions options, dbconnectionpoolkey poolkey, object poolgroupprov

mysql - Is it yet possible to directly fill the paremeters of a Procedure from a SELECT? -

i know wasn't option before, there has been several versions of mysql since last worked it, , seems should have been resolved. take example: table_justbecause id, turns, thejobid, a, x, y, z and procedure calls with: p_somethingtodo (theid int unsigned , turns smallint , jobid int unsigned , smallint unsigned , x smallint , y smallint , z int ) is there simpler method pulling entire select out variables each value , putting them in through statement? there should way.

java - Finding the interior points of a convex hull without computing the hull first -

im trying compute interior points of convex hull using 4 nested 4 loops. however, gives me right coordinates these duplicated many times. im not sure i'm doing wrong. below method public final list<point> interiorpoints(list<point> testpoints){ int n = points.size(); for(int = 0; < n; i++){ for(int j = 0; j < n; j++){ if(j != i){ for(int k = 0; k < n; k++){ if(k != j && j != && != k){ for(int l = 0; l < n; l++){ if(l != k && k != j && j != && != k && l != && l != j){ if(pointisinsidetriangle(points.get(i), points.get(j), points.get(k), points.get(l)) == true){ insidepoints.add(points.get(l)); } }

embedded - How to create an array in C, writing to a specific memory address? -

i doing development on embedded system. need create array of integers using c. array must put in memory address, example, 0x12345678. integers in array should stored in chunk @ 0x12345678. how can that? regards, peter it possible declare pointer assigned address, index thus: static int* const arr = 0x12345678 ; however, less satisfactory because size of array not defined, , if location in normal ram, nothing stops linker instantiating other objects there. if location refers i/o space or memory not in link map, may suffice. the safe "linker aware" method tool-chain specific; gcc , arm realview example have __attribute__ extensions such purposes.

model view controller - Java Package for MVC -

i'm developing application mvc pattern , have around 20 classes overall including views, models , controllers. create packages models, views , controllers because makes easier me find them when they're in different packages. i'm worried if wrong way of using packages in terms of java conventions. ideas? that infact correct , cleaner approach ideally should used in production code. models should in package, controllers should in different package , view (typically jsp files) go in web/pages folder.

javascript - How to stay on same position after submitting an html form? -

i have simple html form: <form action="addtocart" method="post"><br><br> <input name="productid" value="${product.id}" type="hidden"> <input class="submit" onclick="addedcart()" value="<fmt:message key='addtocart'/>" type="submit"> </form> every time click on "submit", brings me straight top creates poor user experience because user have scroll down browsing products... can without using script? -every time click on "submit", brings me straight top. yes default functionality when submitting forms, repaints dom causes jump , page's top position rendered. -which creates poor user experience because user have scroll down browsing products to make user experience can use ajax functionality, tagged jquery in question can try jquery ajax: $('form').submit(function(e){ e.preventdef

Navigation in Windows Phone 8.1 RT -

i'm working on windows phone 8.1 universal app. far having difficulties navigation between pages. first mainpage. when click on post on mainpage opens page called postpage. postpage has buttons performs various operations. 1 of them opens page called commentspage. expected behavior when press button in commentspage go postpage instead goes mainpage. how done? when press button, goes postpage , not mainpage. i'm using following code handle button press void hardwarebuttons_backpressed(object sender, windows.phone.ui.input.backpressedeventargs e) { if (frame.cangoback) { frame.goback(); //indicate button press handled app not exit e.handled = true; } } update: how navigate page mainpage this.frame.navigate(typeof(postpage)); this problem caused subscribing backpressed event page, not unsubscribing it. means page instance kept alive, , backpressed event gets handled multiple event handlers;

Listview button click issue in android -

i'm using list view , there button called "order" in list item. want show "tick" image when user presses button , hide when user presses button again. my issue when clicked on button on first item, tick image of 4th , 8th item appeared. this onclicklistener in adapter, viewholderitem.btnorder.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { boolean isselected = shoe.isselected(); if(isselected){ viewholderitem.ivtick.setimagedrawable(null); isselected = false; }else{ viewholderitem.ivtick.setimagedrawable(mcontext.getresources().getdrawable(r.drawable.tick)); isselected = true; } shoelist.get(position).setselected(isselected); obj.getadapter().notifydatasetchanged(); } }); what reason issue? update: adapte getview method public view getview(fi

c# - how to use menu from a png file in asp.net -

i have 2 menu called menu1 , menu2 png file similar different background color. want when hold mouse on item1 of menu1, item1 of menu2 replace , on until end. i use following method, did not receive correct answer.... this png file .img{ width: 500px; height: 50px; background-image:url('images/example.png'); background-position:-20px -30px; background-repeat:no-repeat;} .img:hover{ width: 500px; height: 50px; background-image:url('images/example.png'); background-position:-20px -50px; background-repeat:no-repeat;} <div class="img"> </div> so, since want use 1 image full menu, have best "size" each little image block little. you can define shared sprite css class, , each single css item, , define there mouse on counterparts, best make sprites same size, cause @ moment don't seem :) an easier way keep menu text, , swap backgrounds, in lower menu in example snippet .menu-sprite { backgro

java - JNA wrong structure field values -

i'm dancing around jna adapter "twain.h" - did it, still have problems getting scanner capabilities. there original enity: typedef unsigned short tw_uint16, far *ptw_uint16; typedef unsigned long tw_uint32, far *ptw_uint32; typedef struct { tw_uint16 itemtype; tw_uint32 minvalue; /* starting value in range. */ tw_uint32 maxvalue; /* final value in range. */ tw_uint32 stepsize; /* increment minvalue maxvalue. */ tw_uint32 defaultvalue; /* power-up value. */ tw_uint32 currentvalue; /* value in effect. */ } tw_range, far * ptw_range; this mapping (thnx jnaerator) public static class tw_range extends structure { /** c type : tw_uint16 */ public short itemtype; /** c type : tw_uint32 */ public nativelong minvalue; /** c type : tw_uint32 */ public nativelong maxvalue; /** c type : tw_uint32 */ public nativelong stepsize;

java - Installing Mahout with Maven on OS X Eclipse -

i trying play mahout. following simple instructions on apache website. i'm getting weird dependency errors. i've created new project maven. i've added pom.xml suggested: <dependency> <groupid>org.apache.mahout</groupid> <artifactid>mahout-mrlegacy</artifactid> <version>0.9</version> </dependency> now running 'mvn clean install -u' gives me: downloading: https://repo.maven.apache.org/maven2/org/apache/mahout/mahout-mrlegacy/0.9/mahout-mrlegacy-0.9.jar [info] ------------------------------------------------------------------------ [info] build failure [info] ------------------------------------------------------------------------ [info] total time: 1.689 s [info] finished at: 2015-03-21t10:54:37+00:00 [info] final memory: 6m/81m [info] ------------------------------------------------------------------------ [error] failed execute goal on project my-app: not resolve dependencies project com.mycompany.a

c++ - Show camera image with Qt gives HIGHGUI ERROR: V4L/V4L2: VIDIOC_S_CROP -

i trying see camera on qlabel, cannot see opencv window. after start application there small window created opencv there no image. , in log can see errors: highgui error: v4l/v4l2: vidioc_s_crop (<unknown>:7534): gtk-warning **: gtk_disable_setlocale() must called before gtk_init() in capture... corrupt jpeg data: 1 extraneous bytes before marker 0xd9 corrupt jpeg data: 1 extraneous bytes before marker 0xd9 corrupt jpeg data: 1 extraneous bytes before marker 0xd9 here simple code : void mainwindow::on_pushbutton_clicked() { cvcapture* capture = 0; cv::mat frame, framecopy; capture = cvcapturefromcam(cv_cap_any); //0=default, -1=any camera, 1..99=your camera if(!capture) { qdebug() << "no camera detected"; } if( capture ) { qdebug() << "in capture..."; for(;;) { iplimage* iplimg = cvqueryframe( capture ); frame = iplimg; if( frame.em

java - SPOJ solution submission -

i newbie trying submit solution problem on spoj in java. have written code in java class name graph , file name graph.java. on submission, getting compilation error as: main.java:18: error: class graph public, should declared in file named graph.java public class graph { ^ 1 error can point out wrong file name? in spoj java solutions must submitted main.java file contains main method. see " solution test in java " example, states: the main class of program must called main.

sqlite - How to avoid memory error in python when retrieving from database -

when try run code large amount of data, memoryerror in all_rows = [[x[0], x[1]] x in cur] . have 200m rows. how can avoid it? binwidth = 1 latitudes = [] userids = [] info = [] densities = [] lite.connect(databasepath) con: cur = con.execute('select latitude, userid dynamicmessage latitude>45') print "executed" all_rows = [[x[0], x[1]] x in cur] all_rows = sorted(all_rows, key=itemgetter(0)) print "sorted" x in all_rows: latitudes.append(x[0]) userids.append(x[1]) min_lat = -100 max_lat = 100 binwidth = 1 bin_range = np.arange(min_lat,max_lat,binwidth) binned_latitudes = np.digitize(latitudes,bin_range) all_in_bins = zip(binned_latitudes,userids) unique_in_bins = list(set(all_in_bins)) all_in_bins.sort() unique_in_bins.sort() bin_count_all = [] bin, group in groupby(all_in_bins, lambda x: x[0]): bin_count_all += [(bin, len([k k in group]))] bin_count_

visual studio - When loading richTextBox with a plaintext file(.txt) it loses the formatting -

well load text file in project container using richtextbox1->loadfile("filename.txt",system::windows::forms::richtextboxstreamtype::plaintext); but when outputing loses '\n' 's (basically no endlines left in text). i know windows save endlines '\r''\n' or that, think loses '\n' because thinks different formatting or can't figure out how bypass without opening file , converting string ^ first , directly loading richtextbox. edit: example: original text: line1 line2 line3 -after loading file: line1 line2 line3

php - Change the text of a label in a WP ecommerce site to something custom -

i change text (for quantity) showing when select options on variable product in woocommerce site. more specific, have variable products "quantity" appears when choose color, size etc of product. so, want change label quantity , make example "well, how many of them ?" , on. ideally, change permanent , independent future updates. that's label created: <label class="label-quantity">quantity</label> so, have found woocommerce/single-product/add-to-cart/variable.php file used display information variable product. plus, label assigned via jquery, that's obvious there call in line 78 function <?php woocommerce_quantity_input(); ?> , leads me core files. anyway, have been struggling change label quite hours hadn't luck. any advice/help/tip appreciated. thank you

xna - How to move a rectangle in chess game -

i programming chess , wanted know how can change spot of rectangles. if need more informations let me know in answers. happy if answers me. thanks. a rectangle has int x , y component. represent position on screen. x: 0, y: 0 represents upper left corner of screen. they're measured in pixels. example(assumingly in game class) rectangle chesspiece1; // in init function: chesspiece1.x = 100; you'll see chess piece has moved 100 pixels right on screen(if you've drawed of course). // if put in update function, chess piece move 1 pixel right every time update function called! chesspiece.x++; and can in y direction too. more info here . also: assume new stackoverflow, people can little harsh if ask "fix me please". here 's info on how make neat questions.

print letters and number on same field with bash script -

i'm trying create bash script below expected output ..which last digit contains numbers , letters id 1a id 1b id .. id 1z id 11 id 12 id 13 id .. id 2a i try below script doesn't work #!/bin/bash id in {1..9}{a..z 1 2 3 4 5 6 7 8 9} echo "id $id" done just use nested loop. for in {1..9}; j in {a..z} {1..9}; id=$i$j echo "id $id" done done

tdd - How to detect if a mocha test is running in node.js? -

i want make sure in case code running in test mode, not (accidentally) access wrong database. best way detect if code running in test mode? as mentioned in comment bad practice build code aware of tests. can't find mentioned topic on , outside. however, can think of ways detect fact of being launched in test. me mocha doesn't add global scope, adds global.it . check may var isintest = typeof global.it === 'function'; i suggest sure don't false-detect add check global.sinon , global.chai use in node.js tests.

html - AngularJS: How to load javascript files into the partials using ng-include -

my main javascript files (they in index.html) don't want work in partials (page1.html, etc.).for example jquery, hightlight syntax. problem loading them during click on menu. html code: <div data-ng-controller="testctrl"> <ul> <li data-ng-repeat="page in pages"><a href="" data-ng-click="loadpage(page)">{{page.title}}</a></li> </ul> <article data-ng-include="view"></article> js code app.controller('testctrl', ['$scope', function($scope){ $scope.pages = [ { title: 'test', url: 'page1.html' }, { title: 'test2', url: 'page2.html' }, { title: 'test3', url: 'page3.html' } ]; $scope.view = $scope.pages[0].url; $scope.loadpage = function($page){ $page.url ? $scope.view = $page.

c++ - Creating two sdl window using vector emplace creates only one window -

wrapping sdl window in class , creating vector. emplacing 2 window objects creates 1 window, though 2 expected. #include <sdl.h> #include <vector> class window { sdl_window* m_window; sdl_renderer* m_renderer; int m_windowid; public: window( int w, int h, uint32 mode = sdl_window_shown ) { m_window = sdl_createwindow( "", sdl_windowpos_undefined, sdl_windowpos_undefined, w, h, mode ); m_renderer = sdl_createrenderer( m_window , -1, sdl_renderer_presentvsync ); m_windowid = sdl_getwindowid(m_window); } ~window() { sdl_destroyrenderer(m_renderer); sdl_destroywindow( m_window); } void render() { sdl_setrenderdrawcolor(m_renderer, 0xff, 0xff, 0xff, 0xff); sdl_renderclear(m_renderer); sdl_renderpresent(m_renderer); } void settitle(const std::string& title) { sdl_setwindowtitle(m_window, title.c_str()); } }; int main( int

oop - Is it a good idea to build an API over a game engine's API for the sake of portability? -

let me give background first context: i interested in building game intention of being modular. started project in unity3d. coding game closely unity3d's api, wondered, should have built own api game in case wanted/had move off unity3d in future? (to game engine, or better yet, use opengl/directx directly) i interested in moving game on unreal engine 4, tried best abstract game, of explicitly uses unity3d's api own api. example of class still depends on unity3d player class ( github ) //vector , gameobject both unity3d classes private player(playerid id, vector position) { gameobject playerprefab = resources.load<gameobject>("player"); playerobject = gameobject.instantiate(playerprefab, position, quaternion.identity) gameobject; playerobject.addcomponent<unityobjectscript>().bind = this; playerobject.name = "player " + id.tostring(); coreobject = playerobject.transform.findchild(&q

c# - How can I use System.Func? -

i have trouble using system.func. public func<int> oncreated=new func<int>(int asd){ debug.log (asd); }; is proper way use it? want make dynamic function can called. can system.func serialized via xml? maybe you're looking action<> instead? action<int> myaction = myintparam => debug.log(myintparam); myaction(myinteger); if want take input parameter, , return something, should use func<> func<int, int> myfunc = myintparam => { debug.log(myintparam); return 5; }; int 5 = myfunc(myinteger); also, if want serialize/deserialize, need take 1 step further. namely, def func not have meaningful information serialized, should wrap in expression . can started googling "c# serialize expression", eg: https://expressiontree.codeplex.com

java - Transfer file from ftp Server to another ftp server using spring integration ftp support -

i new spring , working on spring integration ftp support. i made transfer local directory server(filzilla). i downloaded file server , fine. but want find how can transfer file ftp server ftp server , if it's possible read file without downloading server. if mean fetch file , send server without writing local file system then, no, that's not possible standard components. however, can use 2 ftpremotefiletemplate s (use execute method) stream data inputstream outputstream .

How to determine the exact coordinates of a Google Street View Image -

i working on script generates random coordinates , gets google street view image via google street view image api $img_url = 'https://maps.googleapis.com/maps/api/streetview?size=640x640&location=[random_latitude],%20[random_longtitude]&sensor=false&key=[api_key]'; this works fine, want go step further: if random coordinates don't happen land directly on street, on building or park example, google street view image api returns image of location random coordinates visible . i determine coordinates of street view car standing when took picture. any or idea appreciated.

c# - Sort integer array in strictly O(n) time -

i asked question in interview . given sorted integer array containing negative , positive numbers , how resort array based on absolute values of elements ? this had done strictly in o(n) time. input {-9,-7,-3,1,6,8,14} output {1,-3,6,-7,8,-9,14} what possible solutions other o(n) time ? basically, we're going have 2 heads, 1 looking @ end of array, 1 @ beginning. v v {-9, -7, -3, 1, 6, 8, 14} we compare absolute value of 2 entries our heads pointing @ , insert larger our new, sorted array. here 14. new array: {14} we move head of whichever item selected closer center. here move our head pointing @ 14 8. v v {-9, -7, -3, 1, 6, 8, 14} we repeat process, inserting larger of 2 absolute values beginning of our new, sorted array. here -9, |-9| > |8| new array: {-9, 14} and after move head again: v v {-9, -7, -3, 1, 6, 8, 14} repeat until both heads meet in