Posts

Showing posts from July, 2013

php - Error when putting Session variable in insert into query -

this question has answer here: syntax error due using reserved word table or column name in mysql 1 answer i'm getting error: error: insert order (username, productname, qty) values ('denieall.joe', 'wrist watch', '1') have error in sql syntax; check manual corresponds mysql server version right syntax use near 'order (username, productname, qty) values ('denieall.joe', 'wrist watch', '1' @ line 1 <?php session_start(); include("includes/constants.php"); include("includes/functions.php"); if (!isset($_session['username'])) { redirect_to_home(); } //conection , select database: $conn = mysqli_connect(db_server,db_user,db_pass,db_name) or die("error !!!" ); foreach ($_session["cart_products"] $cart_itm) { $...

c# - Converting FPS ground camera to FPS free flying camera -

i have implemented camera in opengl(opentk) project //move(0f, 0.1f, 0f); } forward //move(-0.1f, 0f, 0f); } left //move(0f, -0.1f, 0f); } //move(0.1f, 0f, 0f); } right //move(0f, 0f, 0.1f); } //move(0f, 0f, -0.1f); } down public static void move(float x, float y, float z) { vector3 offset = new vector3(); vector3 forward = new vector3((float)math.sin((float)orientation.x), 0, (float)math.cos((float)orientation.x)); vector3 right = new vector3(-forward.z,0,forward.x); offset += x * right; offset += y * forward; offset.y += z; offset.normalizefast(); offset = vector3.multiply(offset, movespeed); position += offset; } where "orientation" x,y of direction camera facing. "position" position of camera in world, , "movespeed" float. this camera works great. ground based. mean x value of camera orientation affects m...

python - How to write setup.py to include a git repo as a dependency -

i trying write setup.py package. package needs specify dependency on git repo. this have far: from setuptools import setup, find_packages setup( name='abc', packages=find_packages(), url='https://github.abc.com/abc/myabc', description='this description abc', long_description=open('readme.md').read(), install_requires=[ "requests==2.7.0", "someprivatelib>=0.1.0", ], dependency_links = [ "git+git://github.abc.com/abc/someprivatelib.git#egg=someprivatelib", ], include_package_data=true, ) when run: pip install -e https://github.abc.com/abc/myabc.git#egg=analyse i get could not find version satisfies requirement someprivatelib>=0.1.0 (from analyse) (from versions: ) no matching distribution found someprivatelib>=0.1.0 (from analyse) what doing wrong ? you can find right way here . dependency_links=['http://github.com/user/...

c# - Cannot generate sql in entity framework for oracle database -

i trying generate oracle sql entity framework model. i can generate sqlserver sql fine, error occurs oracle generation. i've installed oracle developer tools vs fine. have selected "generate oracle via t4 (tpt).xaml (vs)" database generation workflow, , "ssdltooracle.tt (vs)" ddl generation template. when attempt generate sql right click menu, following error repeated on , on again: the ssdl generated activity called 'csdltossdlandmslactivity' not valid , has following errors: default value (false) not compatible facets specified decimal. value must decimal number scale less or equal 38 , precision less or equal 38. ... [snip] my model not contain decimals. tried setting default value of int32's , double's other (none) , did not fix it. can me resolve issue? can add xml definition project's app/web.config file (inside of "configuration" section), , try again. <oracle.dataaccess.client> ...

Disable ssl check globally in python 2.7.10 - Pycontrol -

please suggest way disable certificate verification check globally in scenario don't know how pass ssl context. import pycontrol.pycontrol pc b = pc.bigip( hostname = "xx.xx.xx.xx", username = "xxxxxxx", password = "xxxxxxx", fromurl = true, wsdls = ['globallb.wideip','globallb.pool'] ) <urlopen error [ssl: certificate_verify_failed] certificate verify failed (_ssl.c:590)> with version below 2.7.6 works fine, know how make work in 2.7.10. i have faced problem introduced 2.7.9, , in situation of scripting against intranet sites (which have zero chance of getting full certs installed into) have taken simplistic approach of staying 2.7.8.

Can a web application perform tasks when Chrome is minimized on Android? -

i developing web application works timer+logger. tracks how time has passed between user starting timer , stopping (just example). my question - if user starts timer , opens app/moved chrome backgrounds - timer still log time? by default time logged on client-side, if wouldn't work - maybe moving logging server-side it? finally, if nothing mentioned works, functionality achievable using cordova? i think chrome unloads tabs you're not using - according an answer last year music can play in background arbitrary javascript doesn't. native , cordova android apps can around tab restriction using background service .

android - horizontal recyclerView with wrap_content in vertical recyclerView -

in app have situation in have create horizontal recyclerview in vertical recyclerview. rows show casual details , in show horizontal recyclerview. i have set height of horizontal recyclerview wrap_content not visible. when have added hardcoded height it, recyclerview visible. have searched lot regarding problem didn't got working or convincing solution. here adapter class public class homervadapter extends recyclerview.adapter<homervadapter.homeviewholder> { private arraylist<linkedhashmap<string, object>> data; private context ctx; private int selectedindex; public homervadapter(context ctx, arraylist<linkedhashmap<string, object>> val) { data = val; this.ctx = ctx; selectedindex = -1; } @override public homeviewholder oncreateviewholder(viewgroup parent, int viewtype) { layoutinflater inflater = ((activity) ctx).getlayoutinflater(); view view = inflater.inflate(r.layout.custom_home_recycler, null); return new hom...

c# - Public Main() method is required in a public class -

i getting: public main() method required in public class error when running script: using system; using system.io; using system.security.cryptography; using system.text; public class program { public static void main(string[] args) { //shared 256 bit key , iv here const string sky = "lkirwf897+22#bbtrm8814z5qq=498j5"; //32 chr shared ascii string (32 * 8 = 256 bit) const string siv = "741952hheeyy66#cs!9hjv887mxx7@8y"; //32 chr shared ascii string (32 * 8 = 256 bit) var stextval = "here data encrypt!!!"; var etext = encryptrj256(sky, siv, stextval); var dtext = decryptrj256(sky, siv, etext); console.writeline("key: " + sky); console.writeline(); console.writeline(" iv: " + siv); console.writeline("txt: " + stextval); console.writeline("encrypted: " + etext); console.writeline("decrypted: " + dtext); console.writeline("press key exi...

java - Pass data to JSP page using spring -

i using spring(not mvc), servlet, jsp web app, wanted display list of users on jsp page, how can done? here code loginservice.java @service public class loginservice { @persistencecontext entitymanager em; public user getuserbyusername(string username, string password) { user user = null; try { user = em.createquery("from user u u.username = :username , u.password = :password", user.class) .setparameter("username", username) .setparameter("password", password) .getsingleresult(); } catch (exception e) { e.printstacktrace(); } return user; } public list<user> getlistofusers() { return em.createquery("from user u", user.class).getresultlist(); } } loginservlet.java @component public class loginservlet extends httpservlet { @autowired loginservice loginservice;...

c - When will eventfd_read() block? -

i wonder under situation eventfd_read() block? i read manpage doesn't mention anything. i created file descriptor through eventfd(0,0) . thanks in advance. from eventfd(2) man page read() call: if eventfd counter 0 @ time of call read(2), call either blocks until counter becomes nonzero (at time, read(2) proceeds described above) or fails error eagain if file descriptor has been made nonblocking. and eventfd_read() , eventfd_write() functions: the functions perform read , write operations on eventfd file descriptor, returning 0 if correct number of bytes transferred, or -1 otherwise. so eventfd_read() wrapper read() , blocks when read() blocks, i.e. when eventfd counter 0 , o_nonblock not set descriptor (using fcntl(2) or efd_nonblock ). you can verify in glibc sources : int eventfd_read (int fd, eventfd_t *value) { return __read (fd, va...

java - How to avoid internal Nashorn classes in implementations of JSObject -

i want provide own implementation of jsobject described here: https://wiki.openjdk.java.net/display/nashorn/nashorn+extensions jsobject within jdk.nashorn.api package. unfortunately classes of objects in api-methods not. nativearray , jo4, both part of internal package. question is, how should handle such objects? recommended use internal functions? or possible cast objects in api-package? here simple example: import javax.script.invocable; import javax.script.scriptengine; import javax.script.scriptenginemanager; import javax.script.scriptexception; import jdk.nashorn.api.scripting.abstractjsobject; public class jacksontojsobject extends abstractjsobject { final static scriptengine engine = new scriptenginemanager().getenginebyname("nashorn"); public static void main(string[] args) throws scriptexception, nosuchmethodexception { string script = "var fun = function(obj) {obj.arrayfield = [1,2]; obj.objfield = {\"field\":\"test\...

bash - Add all arguments except first to a string -

trying parse arguments 1 string code giving me errors can't find i : test: line 3: =: command not found test: line 7: [i: command not found test: line 7: [i: command not found test: line 7: [i: command not found test: line 7: [i: command not found test: line 7: [i: command not found code bellow #!/bin/sh $msg="" in $@ if [i -gt 1]; msg="$msg $i" fi done edit: thx help, got work. final solution if anyones interested: #!/bin/sh args="" in "${@:2}" args="$args $i" done your specific error messages showing because: assigning variable not done $ character in $msg="" , instead should using msg="" ; and [ command, 1 should separated other words white space, shell doesn't think you're trying execute mythical [i command. however, have couple of other problems. first value of i needs obtained $i , not i . using i on own give error along lines of: -bash: [: i: integ...

PHP if else with database -

i'm having trouble php file. i've done connection database can check it. i've got if-else statement in case return of database wanted. thing everytime reload url, echo in else statement, instead of nothing. dont want if-else execute until submit html form i've got. here simple example: if($somethingtocheck){ echo 'hey!'; }else{ echo 'bad!'; } the var $somethingtocheck declared , know right. so explained, if reload url, string bad! in screen, if have not submited form. there's way not execute if-else statement until submit html form? edit: more details problem. you should enclose in block runned when answering post: if ($_server['request_method'] === 'post') { if($somethingtocheck){ echo 'hey!'; }else{ echo 'bad!'; } }

ruby - Why is a `catch` block called if there is no `throw`? -

the following: catch :something print true end will print true console. thought point of catch was called corresponding throw . less importantly, there 1 liner syntax? surprised catch :something { print true } raises syntaxerror . why catch block called if there no throw ? perhaps there throw before, , programmer forgot delete catch when throw deleted, or doesn't know how use catch . but more in case failed ask "why catch block executed if there no throw ?" answer question catch block executed point throw raised. if throw not raised, catch block executed. is there 1 liner syntax? yes. don't omit parentheses. catch(:something){print true}

google spreadsheet - Dimensions of a merged cell (as in number of cells merged vertically and horizontally) -

Image
i trying make schedule in google spreadsheets. 1 of features want here have current activity highlighted based on time of day. in formula below, understand a column contains times (first column on picture), , b column contains activities. =and(b$1=upper(text(today(), "dddd")), (today()+$a2)<now(), (today()+$a2+(0.5/24))>now()) b$1=upper(text(today(), "dddd")) checks day indicated @ top of column today (today()+$a2)<now() checks time more what's in a column on same line (today()+$a2+(0.5/24))>now() checks time isn't more half hour past what's in a column on same line using conditional formatting formula, obtain decent result (see picture), when reaches merged cell, it'll work first half hour (in picture, lunch highlighted 12:00pm 12:29pm). to correct that, idea multiply 0.5/24 in last part of formula height (as in number of cells in height) of merged cell is there way in google spreadsheets?

javascript - Fading flashing button with AngularJS -

i need please angularjs/bootstrap enable me have smooth fade based flashing button (don't want simple "on/off") ... need highlight user need press submit. i've done lots of searching , there's examples of fading 1 panel out , 1 in... there doesn't seem simple version "flash" text. my apologies know information in question bit thin on "content" new angular (i know basic constructs) , have no real clue start. tyia you can achieve using ng-animate . check this documentation ng-animate . css animations. if need in creating such css animation classes, refer this css animation generator .

javascript - Change image with jQuery and see image getting loaded -

i dynamically changing images jquery using $('img').attr('src','newurl'); doing so, image displayed when entirely loaded. my connection slow, image directly display , see getting progressively loaded, same way images “appear” when arrive on page on web (whether top bottom, or blurry sharp depending on compression algorithm of image). i want javascript, jquery, or simpler alternative. (i know how display progress bar, or "loading…" text while image loads, that's not i'm looking for) here's fiddle if want update. i've found way that, want. don't use attr("src",) jquery, remove , add hole img element html() , trigger browser load image source , browser displays image while loading (tested in chrome). html: <p><button>change image source</button></p> <div> <img src="http://xxxxx"> </div> script: var newimg = '<img src="http://...

javascript - Google charts not showing at first request, but on second only -

i'm using google charts visualise company performance data. javascript looks follows: <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart","line","geochart"], "callback": drawallcompanycharts}); function drawallcompanycharts() { drawchart(); drawlinechart(); drawdonutchart(); drawstackedchart(); drawmarkersmap(); drawchart(); } </script> when user clicks button show charts page, nothing shown , a uncaught referenceerror: google not defined error appears. when clicking button again, charts appear requierd, no errors. i tried use google.setonloadcallback(drawallcompanycharts); shown here , drawallcompanycharts() never gets called. putting in $(document).ready(function () { didn...

How to drop the table with DBAccess iOS ORM -

we planning use dbaccess our ios app. couldn't figure out way drop table while app running. our actual use case figure out when db got updated , drop or alter tables. dbaccess doesn't seems give version number db. that question convoluted answer, here goes: how can drop table dbaccess? the short answer is, can't directly. explain little bit further, used remove tables not derived dbobject class. caused outrage , hatred amongst our users found out, using dbaccess existing databases or pre-populated files, of tables not used classes used subqueries , like. removed feature, seem @ least 50/50 split of opinion. you can issue sql commands drop unused tables directly if wish, add category , fill boots, pass nil database name. @interface dbaccess (execsql) +(void)executesql:(nsstring*)sql indatabase:(nsstring*)dbname; @end however both points 1&2 kind of dealt next "feature". have revision system built dbaccess enable migration , up...

ios - How to declare generic type in Xcode 7 for blocks -

i did simple test generic type support in xcode 7 follow: @interface mtbaselistviewcontroller <t> : uiviewcontroller - (void )requestwithblock1:(void (^)(t data ))block; - (void )requestwithblock2:(void (^)(mtlistpagingmodel<t> *data ))block; @end; the interface compile without problem. then in class use it @interface mttestviewcontroller : mtbaselistviewcontroller <mttestmodel *> @end @implementation mttestviewcontroller - (void )requestwithblock1:(void (^)(mttestmodel *data ))block { } - (void )requestwithblock2:(void (^)(mtlistpagingmodel<mttestmodel *> *data ))block { } @end both methods complaint "conflicting parameter types in implementation ...." i see enumerateobjectsusingblock method in nsarray<objecttype> (nsextendedarray ) support type infer inside block. think should problem didn't declare type in right way?

ios - Atlas inside image.xcassets with different devices -

let's suppose want atlas each of devices: iphone 4s, iphone 5 , iphone 6. if create following schema inside image.xcassets? tutorial tutorial-480h. atlas background button tutorial-568h. atlas background button tutorial-667h. atlas background button and mainmenu mainmenu-480h. atlas background mainmenu-568h. atlas background mainmenu-667h. atlas background and put images inside @2x box? work? mean, have suggestion or better alternatives?

c++ - Template Matching for Coins with OpenCV -

Image
i undertaking project automatically count values of coins input image. far have segmented coins using pre-processing edge detection , using hough-transform. my question how proceed here? need template matching on segmented images based on stored features. how can go doing this. i have read called k-nearest neighbours , feel should using. not sure how go using it. research articles have followed: coin detector coin recognition one way of doing pattern matching using cv::matchtemplate. this takes input image , smaller image acts template. compares template against overlapped image regions computing similarity of template overlapped region. several methods computing comparision available. methods not directly support scale or orientation invariance. possible overcome scaling candidates reference size , testing against several rotated templates. a detailed example of technique shown detect pressence , location of 50c coins. same procedure can applied other c...

python - random.choice() returns same value at the same second, how does one avoid it? -

i have been looking @ similar questions regarding how generate random numbers in python. example: similar question - not have problem randomfunction returns same values every time. my random generator works fine, problem returns same value when calling function at, think, same second undesireable. my code looks this def getrandomid(): token = '' letters = "abcdefghiklmnopqrstuvwwxyzabcdefghijklmnopqrstuvwxyz1234567890" in range(1,36): token = token + random.choice(letters) return token as mentioned function returns different values when being called @ on different times returns same value when calling function @ same time. how avoid problem? i use function in back-end-server generate unique ids users in front-end insert in database cannot control time intervals when happens. must have random tokens map users in database able insert them correctly queuenumbers in database. you possibly improve matters using random.systemr...

How to turn on (back) Fiddler to show HTTP protocol errors? -

few hours ago turned off showing http protocol errors checking checkbox (do not show) in modal error dialog. not find turn on. i must missing something, i've reviewed options dialog tabs, still not found... if navigate tools -> fiddler options -> general , change value in if protocol violations observed other do nothing .

xml - Use variable ouside of scope in xslt -

here have small snippet has variable num_cpu under if condition, not able access outside if condition tag. how solve this? how make num_cpu global can use multiple times outside loop? <xsl:for-each select="t:container"> <xsl:if test="@name = 'cpu'"> <xsl:variable name="num_cpu" select="t:leaf/t:value/@value"/> </xsl:if> <xsl:value-of select="$num_cpu"/> </xsl:for-each> to define global variable, place <xsl:variable> element child of root stylesheet element. in addition answer question in comment. how change value in if condition: xslt not imperative programming language can change value of variable. if want pass value 1 template can use parameter e.g. code snippet <xsl:template match="foo"> <xsl:apply-templates select="bar"> <xsl:with-param name="pos" select="100...

php - Retrieving result from combination of data in an array -

i'm hoping point me in right direction this. i need use array find out if there following combination possible: customer searches 2 rooms , 4 guests. in example array should possible. if customer searches 2 rooms , 5 guests should return false. <? $array[0]=>array( 'room_type'=>'single a', 'number_of_rooms'=>1, 'number_of_beds'=>1, ); $array[1]=>array( 'room_type'=>'twin a', 'number_of_rooms'=>1, 'number_of_beds'=>2, ); $array[2]=>array( 'room_type'=>'twin b', 'number_of_rooms'=>1, 'number_of_beds'=>2, ); ?> right direction "greedy algorithm". the generic algorithm case be: 1. take `$rooms` amount items max number of beds array (array_walk or presorting key) 2. if total amount of `number_of_beds` greater or equals ...

java - limited number of texts in textview -

Image
first of @ image i want text near "google" image fill empty area under google image, area under google image (in above pic) empty , text arent filling there. how can that? xml file ::: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@drawable/allbg"> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageview8" android:layout_gravity="center_horizontal" android:background="@drawable/newstop" /> <scrollview android:layout_width="wrap_content" android:layout_height="match_parent">...

html - how to make content to be fixed inside scroll div using only css? -

Image
as per shown in below image , want blue div fixed @ place after scroll "hello world" div. have tried http://jsfiddle.net/9v6xwkk2/3/ unable it. please me , in advance. <div class="container"> <div class="inner"> <div class="full-height"> fix unscrollable content </div> <div style="width:400px;height:400px;background:black:color:white">hello world</div> </div> </div> you can try - * { box-sizing: border-box; } .container { position: relative; height: 256px; width: 256px; } .inner { float: left; margin-right: 16px; border: solid 1px red; overflow: auto; height: 256px; width: 100%; } .full-height { background: blue; bottom: 17px; color: white; left: 1px; position: absolute; width: 238px;; } <div class="container"> <div class="inner"> ...

javascript - Photoshop Script: Get color of Rectangle Shape and Solid Fill layers -

in project have rectangle shape layers , 1 solid fill layer. need print out colors of layers. this code enumerates layers , prints names of visible: #target photoshop (var = (app.activedocument.artlayers.length - 1); >= 0; i--) { var layer = app.activedocument.artlayers[i] if (layer.visible) { $.writeln(layer) } } how can colors? layers may transparent.

python 3.x - Regex: Match a malformed date -

i'm trying grab date (without time) following ocr'd strings: 04.10.2015, in usd 04.10.20 15, in eur 04,1 0.2015, in xyz 1 1. 10.2 01 5, in xyz 0 1.11.201 5 12:30 1 1,0 3, 2 0 1 5 1 2:3 0 with following expression can catch dates, can't skip "12" hours: ([\d\s]{2,}(?:\.|,)[\d\s]{2,}(?:\.|,)[\d\s]{4,}) how can make work? in plain english, how can make last part stop once has found 4 digits in mix of digits , spaces/tabs? by catching first 8 digits on line, date. \d non-digit charater \d digit character (?:...) group ignored ^\d* used ignore beginning of line until digit we match 8 times digits followed non-numerics characters, starting first digit found. import re p = re.compile(ur'^\d*((?:\d\d*?){8})', re.multiline) test_str = u"""04.10.2015, in usd 04.10.20 15, in eur 04,1 0.2015, in xyz 1 1. 10.2 01 5, in xyz 0 1.11.201 5 12:30 1 1,0 3, 2 0 1 5 1 2:3 0 """ print re.fin...

ios - Swift: Cannot find protocol declaration -

i've got strange bug swift 2. using eventkitui , able display view controller. when try add support delegate though 2 build errors: cannot find protocol declaration 'ekeventeditviewdelegate' expected type the errors showing in projects -swift.h (the project mixes swift , objective-c). any idea why happening? unless i'm missing can't see basic mistakes (typo etc.) cause this. strange fix importing #import <eventkitui/eventkitui.h> in bridging header issue resolved.

Concurrent execution in SQL Server -

Image
table schemas (sql server 2012) create table interestbuffer ( accountno char(17) primary key, calculatedinterest money, provisionedinterest money, accomodatedinterest money, ) create table #tempinterestcalc ( accountno char(17) primary key, calculatedinterest money ) i doing upsert. update rows existed , insert others. update set a.calculatedinterest = a.calculatedinterest + b.calculatedinterest interestbuffer inner join #tempinterestcalc b on a.accountno = b.accountno insert interestbuffer select a.accountno, a.calculatedinterest, 0, 0 #tempinterestcalc left join interestbuffer b on a.accountno = b.accountno b.accountno null all working fine. problem occurs during concurrent executions. inserting data #tempinterestcalc joining other various tables including left join interestbuffer table , different set of data inserted #tempinterestcalc each concurrent execution. my problem executions become locked execution until commit them in serial. my...

c# - ERROR: Failed to convert parameter value from a String to a DateTime -

i have faced error: failed convert parameter value string datetime when trying pass multiple selected dates checkboxlist parameter used in sql. i have tried other datatypes such nvarchar , works when pass multiple selected values 1 stored procedure parameter , return select statement using dynamic sql populate gridview. ps. in webserver i'm displaying in checkboxlist e.g 31-aug-2013 , using date.datatextformatstring = "{0:dd-mmm-yyyy}"; . in sql database, displayed e.g 2013-08-31 . aspx.cs protected void page_load(object sender, eventargs e) { date.datatextformatstring = "{0:dd-mmm-yyyy}"; using (sqlconnection conn = new sqlconnection(dbconn)) { try //call stored procedure { sqlcommand cmd = new sqlcommand(spddl, conn); sqldataadapter da = new sqldataadapter(cmd); dataset ds = new dataset(); da.fill(ds); if (!is...