Posts

Showing posts from June, 2012

c++ - pip external headers only for build -

to compile python package use pybind11 , header-only c++ library. i download master (or other branch) in setup.py such can include while compiling. how do that? basically equivalent of git clone https://github.com/wjakob/pybind11.git _ext/pybind11 . here setup.py from setuptools import setup, find_packages, extension cxxpart = extension('mymodule.cxxpart', include_dirs = ['_ext/pybind11/include'], extra_compile_args=['-std=c++11'], sources = ['src/cxxpart.cpp']) setup( name = "mymodule", version = "0.1", packages = find_packages(), ext_modules = [cxxpart], install_requires = ['flask'], ) note master , not version on pypi. not asked perhaps helpful: pybind organization on github has example setup.py creates dependency on pybind11. ensures installing extension first cause pybind11 installed (via pip & pypi).

php - How to display images from mysql table after selection of a dropdown category from database? -

i want show category based shopping items images on web page can found in online shopping sites.i crated two mysql tables: ist id , category_name , 2nd id , categoryid , product , image_path . able display product images @ time on page, don't know how show product images of single category selected dropdown list submit button @ top of page. hope point clear otherwise feel free ask me. below attached code shows product images on php page @ time without dropdown list. ideas , advice on doing welcome. <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>untitled document</title> <style type="text/css"> ul, li { list-style-type:none; } ul.display { width: 500px; } ul.display li { float: left; width: 100px; height: 120px; margin-left: 5px; margin-right: 5px; margin-bottom: 5px; position: relative; vertical-align:middle; text-align:center; } ul.display li img { width:

php - Problems with mutiple array in foreach loops -

this first question here dont know normal style. i have problem multiple arrays. arrays sorted way: array ( [count] => 2 [gebruikerdata] => array ( [gebruiker1] => array ( [merken] => array ( [0] => merk1 [1] => merk10 [2] => merk19 ) [loginnaam] => testfasdfasd [geslacht] => man [persoonlijkheidstype] => test [beschrijving] => fasdfasdfasd [gebruikerid] => 19 [leeftijd] => 21 ) [gebruiker2] => array ( [merken] => array ( [0] => merk1 [1] => merk9

javascript - jQuery mobile listview change select item and highlight it -

in page,there listview,the first item selected: var len = results.rows.length, $list = $("#listaddr"); var $strhtml =" "; (var = 0; < len; i++) { $strhtml += '<li '; if (i == 0) { $strhtml += ' data-theme="b" '; } $strhtml += '> <a href="#" data-ajax="false"'; $strhtml += ' data-id="' + results.rows.item(i).id + '">' + results.rows.item(i).name + '</a></li>'; } $list.html($strhtml); $list.delegate('li a', 'click',function(e){ // $("#listaddr").attr("li").removeclass("lisel"); $(this).addclass("data-theme='b'"); $("#listaddr").listview("refresh"); //$(this).removeclass("data-theme"); clickaddr($(this).data('id')); }); when select third item,i want third item "data-theme='b'" style

xcode - CCLayer to UIImage - Anti-aliasing? -

when grab snapshot of cclayer uiimage of ccrendertexture seems i'm loosing anti-aliasing, resulting in output image looking different screen looks like. is there way of getting output image corresponds more shown on screen? this how i'm getting uiimage: -(uiimage*)layerrepresentation { cclayer *layer1 = self; ccrendertexture *renderer01 = [ccrendertexture rendertexturewithwidth:layer1.contentsize.width height:layer1.contentsize.height]; [renderer01 begin]; [self visit]; [renderer01 end]; uiimage *image = [renderer01 getuiimage]; return image; } when ccrendertexture created, sends setaliastexparameters message texture. try [renderer01.sprite.texture setantialiastexparameters];

c# - Getting location address without display any map -

i doing windows phone 7 application map location service (i using arcgis @ moment). wanted know if possible current location address of user without displaying map. many thanks. the first thing need location of user. have never developed on windows phone, quick google searched yielded this result . once have users location, should proceed call reverse geocode rest api , input users coordinates. the result of reverse geocode operation should yield address of current user without displaying map.

css - div containing 2 floating divs -

need help. created div contains 2 floating divs. first div leftnav. second div contains 2 floating divs too. problem #container div height set auto not seem work. here: jsfiddle i tried clear:both @ end of second div, didn't work. any appreciated. thanks <div id="header">header</div> <div id="container"> <div id="first">first</div> <div id="second"> <div id="scol1"> <div id="scol1a">scol1a</div> <div id="scol1b">scol1b</div> <div id="scol1c">scol1c</div> </div> <div id="scol2"> <div id="scol2a">scol2a</div> <div id="scol2b">scol2b</div> <div id="scol2c">scol2c</div> </div> </div><!--second div-->

java - Unit testing conditional comments -

i'm using xmlunit ( org.custommonkey.xmlunit.diff ) test 2 html strings: 1 produced templating engine, other static file. works fine, ran following problem: there conditional comments in code, this: <!--[if ie6]> <link type="text/css" href="ie6style.css" rel="stylesheet" /> <![endif]--> i error if test against following code (href , type attributes swapped in following snipped): <!--[if ie6]> <link href="ie6style.css" type="text/css" rel="stylesheet" /> <![endif]--> i know xml parser, conditional comment plain text. there way how test conditional comment content html/xml code? in case want ignore comments, there xmlunit.setignorecomments(false)

c++ - SDL Window Not Appearing -

i'm trying sdl window appear, doesn't seem working. program run, , function show window run no errors, nothing shows on screen. have icon in dock says program not responding. here's code: int main(int argc, const char * argv[]) { maincomponent maincomponent; maincomponent.init(); char myvar; cout << "enter key quit..."; cin >> myvar; return 0; } void maincomponent::init() { //initialize sdl sdl_init(sdl_init_everything); window = sdl_createwindow("my game window", 100, 100, 100, 100, sdl_window_shown); cout << screenwidth << " " << screenheight << endl; if(window == nullptr) { cout << "error not create window" << sdl_geterror() << endl; } sdl_delay(5000); } here's screenshot of icon on dock https://www.dropbox.com/s/vc01iqp0z07zs25/screenshot%202016-02-02%2017.26.44.png?dl=0 let me know if there'

java - Wizard Component PrimeFaces Updating other variables -

Image
i have 2 tabs. wizard component, when press 'next' button (from first tab), need populate list(with selectitem objects) , show these selectitems in selectonemenu tag in second tab. have finished entering data on first tab , press 'next' button, selectonemenu tag(on second tab) not have in it. basically, need update next tab along processing of current tab. anyway this? thanks in advance. here code: <p:wizard widgetvar="wiz" shownavbar="true" flowlistener="#{detentionform.onflowprocess}"> <p:tab id="typeofleader" title="leader selection"> <p:panel header="leader selection"> <p:messages showsummary="true" showdetail="false"/> <p:panelgrid columns="2"> #{msgs.typeofleaderpunishment} <p:selectonemenu v

php - Sessions works fine in local mode, but not in server -

i've developped project, uses sessions, in php. works fine in local mode, when upload server, doesn't works. well, works @ 50%, because when send post, can whole session correctly, when header(); index.php, session desapeared. sessions enabled in server. all docs has session_start(); @ top of page. when header(); set die(); below. syntax correct. got no errors. does knows happening? i think, problem arising because of mistake while moving files local server. if session not worked in server, can server problem. said session working. please check codings. if works on localhost should work on server too. try this: on new server, php session not working. server have cpanel installed before, have uninstalled it, there no proper way of uninstalling cpanel, removed related cron jobs , cpanel folders. to fix php session problem checked session.save_path set /tmp, on checking found read only. it may due securetmp service of cpanel disabled during uninstalla

php - DB2 error Improper use of a string column, host variable, constant, or function -

i'm trying search tables , columns value , i'm using php connection ibm db2 database. wondering if error cause because of multiple usage of union. this error message : improper use of string column, host variable, constant, or function "namabarang". sqlstate=42907 sqlcode=-134 and here code : $keyword=$_get['keyword']; $query="select * inventory namabarang '%".$keyword."%'". " union select * inventory arrivaldate '%".$keyword."%'". " union select * inventory papernumber '%".$keyword."%'". " union select * inventory serialnumber '%".$keyword."%'". " union select * inventory condition '%".$keyword."%'". " union select * inventory location '%".$keyword."%'". " union select * inventory confirmationdate '%".$keyword."%'". "

Default method cannot be static in java interface? -

why can't create interface default static method? public interface statictest { default static void display() { system.out.println("display here"); } } static methods cannot overridden or inherited in meaningful sense, , default methods there overridden or inherited. other non-static interface methods, default implies inheritance meaningful method, incompatible static .

ORACLE constraints based on 2+ tables -

i have following 3 tables: create table flights ( route_number int not null primary key, operated_by int not null, airplane_model varchar(30) not null, source varchar(20), destination varchar(20), foreign key (operated_by) references airline(airline_id), foreign key (airplane_model) references airplanes(airplane_id) ); create table outgoing ( route_number int not null primary key, potime date not null, foreign key (route_number) references flights(route_number) ); create table incoming ( route_number int not null primary key, patime date not null, foreign key (route_number) references flights(route_number) ); create table departures( depid int not null primary key, route_number int not null, gate varchar(3) not null, dept date not null, depd date not null, status varchar(10), foreign key (route_number) references flights(route_number) ); create table arrivals( route_number int not null, gate varchar(3)

css - HTML 5 fonts sizes -

i want make website mobile how can make font sizes stretches mobile screen's resolutions <!doctype html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> p{font-size:1em; /* font-size:20px; */ } </style> </head> <body> <p> lorem ipsum dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book. has s urvived not 5 centuries, leap electronic . </p> </body> </html> use em instead of px example: font-size: 1.1em;

sql - How can I stop a mysql insert statement from executing when a select statement returns nothing? -

consider select statement: select course_id courses course_id = ( select course_id courses course_id = 3 , max_size > students_registered); the values inserted not coming select. submitted form user. select tells me if there slot available make insert. currently check on front end 1 ajax call, i'm trying move away front end. suggestions appreciated. the insert statement inserts 8 values table. nothing extraordinary value question. i've researched extensively. option moving stored procedure? i need insert fail when select returns no rows or null can return right view/jsp application. please let me know details provide help. you can use insert ... select judiciously control this. for example, insert mytable (course_id, col2, col3) select a.course_id col1, 'value' col2, 'another_value' col3 courses course_id = 3 , max_size > students_registered limit 1 the trick write select query retu

python - Why is the name of the containing class not recognized as a return value function annotation? -

i going use python function annotations specify type of return value of static factory method. understand one of desired use cases annotations. class trie: @staticmethod def from_mapping(mapping) -> trie: # docstrings , initialization ommitted trie = trie() return trie pep 3107 states that: function annotations nothing more way of associating arbitrary python expressions various parts of function @ compile-time. trie valid expression in python, isn't it? python doesn't agree or rather, can't find name: def from_mapping(mapping) -> trie: nameerror: name 'trie' not defined it's worth noting error not happen if fundamental type (such object or int ) or standard library type (such collections.deque ) specified. what causing error , how can fix it? pep 484 provides official solution in form of forward references . when type hint contains names have not been defined yet, definition

python - Filtering defaultdict on the base of value -

consider following default dict: data = defaultdict(list) data['key1'] = [{'check': '', 'sth1_1':'k1', 'sth1_2':'k2'}] data['key2'] = [{'check': '0', 'sth2_1':'k3'}, {'check': 'asd', 'sth2_2':'k4'}, {'check':'1', 'sth2_3':'k5'}] and on.. i filer out data dictionaries (from data.values()) value 'check' != '1' for given input above i'd expect: defaultdict(<type 'list'>, {'key2': [{'sth2_3': 'k5', 'check': '1'}]) so far i've got: for k, v in data.items(): print "k, v: ", k, v v[:] = [d d in v if d.get('check') == '1'] but gives me output unwanted 'key1': [] : defaultdict(<type 'list'>, {'key2': [{'sth2_3': 'k5', 'check': '1'}], 'key1

How to get key of array when i know this value in php -

this question has answer here: retrieve array key passed on value php 5 answers i have array this: $array = array('name'=>'van pham','age'=>'23','sex'=>'male'); how can key ' age ' value ' 23 '? you looking array_keys http://www.php.net/manual/en/function.array-keys.php print_r(array_keys($array, "23")); // age or hamza dzcyberdev echo array_keys($array, "23")[0]; http://codepad.viper-7.com/bzergt

javascript - jQuery drag and drop, validating draggable id -

i've built simple drag , drop activity. when answer dropped on drop area, id stored in variable called 'answer'. when submit button hit runs function called validate checks if variable answer has id of 'correct' stored inside of it. the problem is, when hit submit button doesn't run validate function because says 'the variable answer not defined'. <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>yay drap , drops!</title> <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <style> div { height: 100px; width: 100px; border: solid 2px #000; margin: 10px; } </style> <script> $(document).ready(function() { $("#correct").draggable(); //i have drag capability now! $("#wrong"

javascript - <option ng-repeat value={{object}}> How can i force angular to push the object into the model? -

i have angular 1.2.x project in need use in order able set title , disable different options. plunker: http://plnkr.co/edit/suxpfoxvsufvmi1itkf1?p=preview <select ng-change="onconceptnameselect()" ng-model="result"> <option value="">select value </option> <option ng-repeat="value in values" value={{value}} title="{{value.title}}" ng-disabled="value.isdisabled">{{value.name}} </option> </select> the problem i'm facing when selection, ng-model initialized stringified object instead of being initialized object itself. how can force angular push object model? thanks you can convert string value object if need object have @ updated plunker $scope.isobject = function() { return $scope.resultobject instanceof object; }; $scope.onconceptnameselect = function () {

javascript - Failing to load JQuery 2.2 from HTMLUnitDriver 2.15 -

i'm trying use htmlunitdriver within play 2.4.4 test 1 of our pages makes heavy use of react.js. before react ever gets load/execute, seeing following errors (one loading jquery, other trying load bootstrap depends on jquery). [error] - com.gargoylesoftware.htmlunit.javascript.stricterrorreporter - runtimeerror: message=[an invalid or illegal selector specified (selector: '*,:x' error: invalid selector: *:x).] sourcename=[http://localhost:19001/assets/lib/jquery/jquery.min.js] line=[2] linesource=[null] lineoffset=[0] [info] - com.gargoylesoftware.htmlunit.javascript.javascriptengine - caught script exception com.gargoylesoftware.htmlunit.scriptexception: typeerror: cannot find function createhtmldocument in object [object domimplementation].(http://localhost:19001/assets/lib/jquery/jquery.min.js#4) @ com.gargoylesoftware.htmlunit.javascript.javascriptengine$htmlunitcontextaction.run(javascriptengine.java:705) [htmlunit-2.15.jar:2.15] @ net.sourceforge.htmlu

java - Re-read configuration without restart -

suppose i've got java application, uses properties files configuration. i'd make application re-read configuration without restart. i'll call such configuration "refreshable". what easiest way that? suppose developing application scratch. how should design make configuration "refreshable"? using commons-configuration easiest way go. here example of usage. there many other features included, hierarchical configuration (with overriding defaults), jdbc sources, etc.

c# - How to check if a game object has a component method in Unity? -

Image
i writing method check if gameobject has component. here is: public static bool hascomponent <t>(this gameobject obj) { return obj.getcomponent<t>() != null; } and i'm using this: void update() { if (input.getkey("w")) { if (gameobject.hascomponent<rigidbody>()) { print("has rigid body."); return; } print("does not have rigid body."); } } the gameobject not have rigid body still printing have. it just... public static bool hascomponent <t>(this gameobject obj) t:component { return obj.getcomponent<t>() != null; } note forgot the where t:component part of first line! with syntax error, extension meaningless: it's finding "some component" (since t sort of "blank") , hence never null. it's syntax error. note. explanation of "what heck extension". for reading not f

zend framework2 - Ajax pagination in ZF2? -

i new in zf2 did projects in zf . didn't used ajax pagination in zf . need ajax pagination in zf2 . how do that? that's how it. first step (routes file): i define route pagination, diferent list one. way have controller functions simple possible. 'customers' => array( 'type' => 'literal', 'options' => array( 'route' => '/customers', 'defaults' => array( 'controller' => 'customers_controller', 'action' => 'list', ), ), 'may_terminate' => true, 'child_routes' =>array( //list 'list' => array( 'type' => 'segment', 'options' => array( 'route' => '/[:page]', 'defaults' => array( 'controller' => &#

PHP REST Client -

i have java rest api server serverresource create hash code on document, don't know, how built php rest client, can ? (some example or tutorial how ?) have no experiences php, i'd appreciate help. how connect local host through php ? how post string hash resource in java ? i have downloaded rest client phphttpclient.com/, choose file, have content of file..now..how can send java rest api (localhost:port/hash)? i think need simple rest client in php send request , receive responses in order communicate rest server. rest clients concentrate on data send instead of care lower level thing how post or data. can use this or others. simpler one, should try httpful on if use framework zend, try this .

arcgis - How to enable multidex(android) in IBM MobileFirst 7.1 Application(Hybrid) -

we developing hybrid application , have added necessary libraries project. have esri arcgis jars (native maps) , pro-guarded version of google play services (to include analytics) in app. mobilefirst features, have jsonstore enabled. this resulting in dex issue in android: conversion dalvik format failed: unable execute dex: method id not in [0, 0xffff]: 65536 arcgis recommends not proguard optimized api, in case have limited options. does know steps enable multi-dex in our hybrid app, spl. because limited using eclipse ide mobilefirst app development. the option can think of migrate project gradle-based, importing mobilefirst studio-generated project android studio , select option migrate. note: mobilefirst platform foundation not support gradle @ time. means after opening project in android studio, if require additional changes in project need build in mobilefirst studio , again import , migrate gradle , on on repeat...

python - How do you load information into a database using flask? -

trying teach myself flask making web app. i'm having trouble posting inputs user database , when load page , try submit info through form 405 error: "get / http/1.1" 200 -, "post / http/1.1" 405 - any insight appreciated, thanks. here python snippet: session = dbsession() app = flask(__name__) @app.route('/') def index(methods=['get','post']): print request.method if request.method == 'post': instances = session.query(vocab) newitem = vocab(id=len(instances), word=request.form['new_word']) session.add(newitem) session.commit() instances = session.query(vocab) return render_template('vocab_template.html', instances = instances) the html template: <!doctype html> <html> <head> <title>vocab</title> </head> <body> <div> <h1>words!</h1> <ul id='words'>

.net - Which VC++ Runtime do I need if I'm using C++/CLI in VS 2010? -

which vc++ runtime need package app installer if i'm using c++/cli in vs 2010? assuming target pc running windows xp/vista/7 , has no other vc++ runtime installed. visual c++ 2005 -- 3 mb visual c++ 2005 sp1 -- 3 mb visual c++ 2008 -- 2 mb visual c++ 2008 sp1 -- 4 mb i'm targeting .net 2.0 although i'm building app toolsversion set "4.0" . your job ll done using one. visual c++ 2008 -- 2 mb i using same.

android - "values-w320dp-land" folder doesn't apply on screen landscape rotation -

Image
i have following 2 values folders under project resources : this dimens.xml portrait display of 320dp width screen : this dimens.xml landscape display of 320dp width screen : what i'm getting correct display @ application start (for landscape display portrait display) : application starts in portrait mode correctly : application starts in landscape mode correctly : now problem when rotate screen during application runtime (say application first started in portrait mode), application doesn't seem retrieve values correct values folders supposed " values-w320dp-land " : and vice-versa, if rotate screen after started application in ladscape mode, application doesn't seem retrieve values correct values folders supposed " values-w320dp-port ", , : update 1 this activity declaration in androidmanifest.xml : <application android:allowbackup="true" android:icon="@mipmap/ic_laun

html - Rails nested list with concat content_tag in Helper -

i'm trying create similar this: using helpers in rails 3 output html here's helper: def section_references_to_html (section) concat content_tag (:ol, :class => 'sources') section.references.each |reference| concat content_tag (:li,content_tag(:a, reference.text, :src => reference.url)) end end end but it's returning sorts of syntax errors: /~/app/helpers/application_helper.rb:21: syntax error, unexpected ',', expecting ')' concat content_tag (:ol, :class => 'sources') ^ /~/app/helpers/application_helper.rb:21: syntax error, unexpected ')', expecting keyword_end concat content_tag (:ol, :class => 'sources') ^ /~/app/helpers/application_helper.rb:22: syntax error, unexpected keyword_do_block, expecting keyword_end section.references.each |reference|

python - Creating a line graph with ggplot library which plots two lines (the high and low of stock prices) on the same graph -

Image
i can plot closing prices using below syntax: gg = ggplot(stock_prices.ix['2013-01-01': '2013-12-31'], aes('date', 'close')) + geom_line() however, don't know how plot "high" , "low" prices on same plot, ideas? the standard practice of plotting "high" , "lows" (together "open" , "close) in finance candlestick plotting. following code should started in charting candlesticks: step 1. imports. import datetime dt import matplotlib.pyplot plt import matplotlib.dates mdates matplotlib.finance import candlestick_ohlc import pandas pd pandas_datareader import data step 2. downloads. start = dt.datetime(2015,1,1) spy = data.datareader('^gspc', 'yahoo', start) you can skip step if have data in ohlc format. step 3. prepare data. at point have data in form: spy.head() open high low close volume adj close date

c++ - How to create a function that reads in multiple files? -

hi im working on application want create functions reads in files ex. readfiles() { f1, f2=null, f3=null; } but i'm having hard time getting multiple files load. make function reads in files , sets them specified variable use in other functions within program. or ideas great. again! ps. not homework assignment. i start writing function can read 1 file. call function function knows files need read. for example, assuming files aren't enormouse (gigabytes large), function reads file single string: std::string readfile(std::string name) { ifstream f(name.c_str()); std::stream tmp; std::stream res; while(getline(f, tmp) { res += tmp; } return res; } void somefunc() { std::string file1 = readfile("file1.txt"); std::string file2 = readfile("file2.txt"); } of course, if file list of integers, may want read data vector of integer instead. if content more complex, reading vector

r - Square root of a number to 100 decimal places -

how can square root number 100 decimal places in r? i've looked gmp , rmpfr packages. can't figure out how use them square roots, (pow.bigz(2,0.5)=1) if did, i'm not sure how accurate be, since i've found after 25 decimal places, digits aren't reliable eg mpfr(1/3,400) # 1 'mpfr' number of precision 400 bits # [1] 0.333333333333333314829616256247390992939472198486328125 and as.bigz(1e50/3) # big integer ('bigz') : # [1] 33333333333333337607355566542238210608487100055552 the question computing 1 third prior mpfr has lost precision time mpfr sees it. way: mpfr(1, 400)/3

CTypes, Python Callback, and FORTRAN -

i new python (and fortran well) happen writing interface fortran solver call python code. using python 3 right , trying use ctypes write interface. since solver subroutine has around 40 parameters, show question using simple example in fortran , python. first, consider main fortran subroutine in ex3_func.f subroutine ex3_func (pp,num,dim,funptrobjfun) implicit none integer, intent(in) :: num, dim real(8), intent(inout) :: pp(num,dim) external funptrobjfun pp = (pp+pp)*3.0 call funptrobjfun(pp,num,dim) return end subroutine compiling using: $> gfortran -c ex3_func.f gives no problem @ all. i have c interface subroutine, module in ex3_cfunc.f module cwrapper_ex3cfunc use iso_c_binding, only: c_int, c_double, c_funptr implicit none contains subroutine ex3_cfunc(pp, num, dim, ptrfunobjfun) bind(c) integer(c_int), intent(in) :: num, dim real(c_double), intent(inout) :