Posts

Showing posts from February, 2013

c# - OOP interaction with database -

if object oriented programming focused on objects, consist of methods , data, best oop-focused approach working databases, using c#? for example, want log using c# classes, , record logs in sql table. other factors being neutral, more "proper," object-oriented speaking, do: create class what's being logged, , include methods database access (the methods tied closely data) public class activity { public string activityproperty { get; set; } public void sqlmethod1() {} public void sqlmethod2() {} } ...or, create class what's being logged, , create class database access (methods not closely tied data, way data accessed treated object, i.e. referencing ef or orm) public class activity { public string activityproperty { get; set; } } public class sqlmethods { public string sqlproperty { get; set; } public void sqlmethod1(activity activityparam) { } public void sqlmethod2(activity activityparam) { } } ...or, perhaps

objective c - Pivot Cell in UITableView -

Image
i'm new ios programming , i'm trying create pivot row ( or cell ) in uitableview ( know same pivot rows in ms excell ) , have main row sticks header or footer of table when scrole table , down . i've tried search solution online not find ( perhaps i'm using wrong terminology ) . know if uitableview supports such things out of box or have create custom table view . thank in advance. this not built in functionality in sense of you're thinking. there might work around depending on how many rows want. if want 1 row, override method: - (uiview *)tableview:(uitableview *)tableview viewforheaderinsection:(nsinteger)section edit: table view must have uitableview style of uitableviewstyleplain method work. then make 1 view following down scroll table view. otherwise have implement (which yield better results, , proper customization needs).

c# - Not possible load assembly due to version -

this question has answer here: could not load file or assembly or 1 of dependencies 33 answers i have package, microsoft.aspnet.web.optimization , uses antlr3 . once installed it, antlr3 came in version 3.4.1.9004 . after checking installed packages updates and, mistake, updated antlr3 3.5.0.2 . now, if remove of it, packages , reinstall microsoft.aspnet.web.optimization still error screen because it's referring newer version of antlr3 instead of old one. i tried several other things nothings seems solve problem. where can remove reference ? my main error one: could not load file or assembly 'antlr3.runtime' or 1 of dependencies. assembly's manifest definition not match located assembly reference. (exception hresult: 0x80131040) i managed fix binding on web.config, changing version 1 wanted. after tried removing project, clo

comparing histograms with matlab through pdist2 -

i'm trying compare histogram of image (hsv) cell array contains histograms of other images in order find out closest matches. have far: image compare database: im=imread(name); resizedimage = imresize(im,[75 75]); image = rgb2hsv(resizedimage); h = image(:,:,1); [hist, colorbins]= imhist(h); hist_testing=hist'; images compare: im=imread(filename); resizedimage = imresize(im,[75 75]); image = rgb2hsv(resizedimage); h = image(:,:,1); data {i,1}= histogram(h); the histogram class represented this: function [hist] = histogram(h) [hist, colorbins]= imhist(h); hist=hist'; end through pdist2 method usage: comphist= pdist2(hist_testing, hist, 'euclidean'); the error gives me "not enough arguments input". can please me?

bigdata - Data scheme Cassandra using various data types -

currently developing solution in field of time-series data. within these data have: id, value , timestamp. here comes: value might of type boolean, float or string. consider 3 approaches: a) every data type distinct table, sensor values of type boolean table, sensor values of type string another. obvious disadvantage have know sensor. b) meta-column describing data type plus values of type string. obvious disadvantage data conversion e.g. calculating max, avg , on. c) having 3 columns of different type 1 value per record. disadvantage 500000 sensors firing every 100ms ... plenty of unused space. as knowledge limited appreciated. 500000 sensors firing every 100ms first thing, make sure partition properly, make sure don't exceed limit of 2 billion columns per partition. create table sensordata ( stationid uuid, datebucket text, recorded timeuuid, intvalue bigint, strvalue text, blnvalue boolean, primary key ((stationid,datebucket),recorded)

php - Class 'SendEmail' not found while doing Amazon SQS queue -

i followed this official guide in order implement amazon sqs mailing system laravel 5 project i've done executing both essential commands doc: php artisan queue:table php artisan make:command sendemail --queued the second line has created file app/commands/sendemail.php me expected, contains: <?php namespace app\commands; use app\commands\command; use illuminate\queue\serializesmodels; use illuminate\queue\interactswithqueue; use illuminate\contracts\bus\selfhandling; use illuminate\contracts\queue\shouldbequeued; class sendemail extends command implements selfhandling, shouldbequeued { use interactswithqueue, serializesmodels; /** * create new command instance. * * @return void */ public function __construct() { // } /** * execute command. * * @return void */ public function handle() { // } } now, try run simple laravel queue command: queue::push(new sendemail($me

android - What does bearingTo(Location dest) exactly calculate? -

what bearingto(location dest) calculate? can please explain this?? thanks in advance. protected void oncreate(bundle savedinstancestate) { destinationloc.setlatitude(39.543394); destinationloc.setlongitude(-119.816010); locationmanager lm =(locationmanager)getsystemservice(location_service); string provider = lm.getbestprovider(new criteria(), true); loc=lm.getlastknownlocation(provider) } public void onsensorchanged(sensorevent event) { // todo auto-generated method stub startloc.setlatitude(loc.getlatitude()); startloc.setlongitude(loc.getlongitude()); if ( startloc == null ) return; float azimuth = event.values[0]; float baseazimuth = azimuth; minitialposition.settext("initial latlong: " + startloc.getlatitude() + " " + startloc.getlongitude()); geomagneticfield geofield = new geomagneticfield( double .valueof( startloc.getlatitude() ).floatvalue(), double .valueof

Activity with "android.intent.action.SEND" intent filter is not showing up in list when sharing photo from stock Google Photos app -

i have android app activity intent filter set receive photos , videos. declared in androidmanifest.xml so: <activity android:name="com.foo.gallery.app.activity.recievephotosactivity" android:label="@string/photoapp_gallery_common_app_name" android:exported="true" android:configchanges="orientation|keyboardhidden|screensize" > <intent-filter > <action android:name="android.intent.action.send" /> <action android:name="android.intent.action.send_multiple" /> <category android:name="android.intent.category.default" /> <data android:mimetype="image/*" /> <data android:mimetype="video/*" /> </intent-filter> </activity> however, when going stock lollipop photos app , sharing photo, app not appear in list. my app appear in share list when sharing other apps, onedrive, dropbox,

ruby on rails - Regular expressions with validations in RoR 4 -

there following code: class product < activerecord::base validates :title, :description, :image_url, presence: true validates :price, numericality: {greater_than_or_equal_to: 0.01} validates :title, uniqueness: true validates :image_url, allow_blank: true, format: { with: %r{\.(gif|jpg|png)$}i, message: 'url must point git/jpg/png pictures' } end it works, when try test using "rake test" i'll catch message: rake aborted! provided regular expression using multiline anchors (^ or $), may present security risk. did mean use \a , \z, or forgot add :multiline => true option? what mean? how can fix it? ^ , $ start of line , end of line anchors. while \a , \z permanent start of string , end of string anchors. see difference: string = "abcde\nzzzz" # => "abcde\nzzzz" /^abcde$/ === string # => true /\aabcde\z/ === string # => false so rails telling you, "are sure want use ^ ,

Xamarin.iOS - Exception stack trace lines are zero when buidling for AppStore (using TestFlight for internal users) -

Image
when building appstore in xamarin studio , deploying in testflight internal testers, intentionally throw exception , send stack trace server, lines zero: @ ios.settingsscreen.<settingsscreen>m__6 () [0x00000] in <filename unknown>:0 @ monotouch.dialog.stringelement.selected (monotouch.dialog.dialogviewcontroller dvc, uikit.uitableview tableview, foundation.nsindexpath indexpath) [0x00000] in <filename unknown>:0 @ monotouch.dialog.dialogviewcontroller.selected (foundation.nsindexpath indexpath) [0x00000] in <filename unknown>:0 @ monotouch.dialog.dialogviewcontroller+source.rowselected (uikit.uitableview tableview, foundation.nsindexpath indexpath) [0x00000] in <filename unknown>:0 @ (wrapper managed-to-native) uikit.uiapplication:uiapplicationmain (int,string[],intptr,intptr) @ uikit.uiapplication.main (system.string[] args, intptr principal, intptr delegate) [0x00000] in <filename unknown>:0 @ uikit.uiapplication.main (syst

How to debug apis in PHP (without using var_dump();die();) -

so i'm writing api in php, , i'd use full-service debugging tool. i.e., set breakpoints, view stack traces, inspect variables, etc. kind of thing common in compiled languages. i've checked out xdebug, , after configuring work phpstorm (my ide), disappointed find works when run within phpstorm, not when service real api requests. to add additional complexity this, api dbs hosted on vagrant instance, although write , edit code on local machine, code being run in virtual machine vagrant environment. any other way of doing this? or should used along lines of print_r();exit; , rerun request? use xdebug, , configure properly. can configure work without running code phpstorm quite easily. xdebug.remote_enable = on xdebug.remote_connect_back = on xdebug.idekey = "vagrant" make sure set. then, in phpstorm, there looks phone icon in top right (along rest of debugging , running stuff in toolbar). make sure green (i.e. listening connections). you ca

sql - "Incorrect syntax near the keyword 'where'." -

stored procedure throws error: error sql (error 156) [sqlstate 4200] "incorrect syntax near keyword 'where'." the stored procedure populate table using insert statement, keep getting error when runs. i'm not sure how fix error. here proc: alter procedure [dbo].[buildtable] declare @querytxt varchar(max) declare @queryname varchar(50) declare @columnval int declare @countval varchar(50) declare @isfirst char(1) declare @currentdt varchar(20) declare @savdate datetime begin set @isfirst = 'y'; set @currentdt = convert(varchar(20),current_timestamp,110); declare c1 cursor select queryname, querytext subsqueries open c1 fetch next c1 @queryname, @querytxt while @@fetch_status = 0 begin --call stored proc exec informixquery @querytxt, @columnval output set @countval = ltrim(str(@columnval)) if @isfirst = 'y' begin exec ('insert tblhist

Boost 1.58 address-model has no effect -

this has happened me on multiple platforms far (mac os 10.10, solaris sparc 10, debian 7). when try compile boost using b2, chooses default architecture. if want switch architecture, nothing happens. here commands i've tried. on windows, works fine. osx : ./b2 architecture=combined address-model=32_64 install --prefix=./osx/clang/universal ./b2 architecture=combined address-model=32_64 ./b2 --architecture=combined --address-model=32_64 install --prefix=./osx/clang/universal in case trying build 64 bit. solaris/linux : ./b2 install --prefix=./<plaform>/<compiler>/<bitness> address-model=64 ./b2 install address-model=64 --prefix=./<plaform>/<compiler>/<bitness> ./b2 address-model=64 install --prefix=./<plaform>/<compiler>/<bitness> ./b2 install --prefix=./<plaform>/<compiler>/<bitness> architecture=x86 address-model=64 in case building 32 bit. i did delete , rebuild b2 using bootstrap.sh each co

Where to specify "MaxRetry" and "Timeout" variables in the Elasticsearch / Nest Bulk API? -

question: specify bulk operation "maxretry" or "timeout" variables used in nest bulk api? when following bulk operation, program stops after inserting 60k records. got maxretryexception in elasticsearch.net.connection.requesthandlers.requesthandlerbase.cs. so, thinking increase maxretry number or timeout seconds overcome problem, on right path? var counter = 0; var indexname = "someindexname"; var indextype = "sometype"; var routingstring = "somerouting"; var bulkdescriptor = new bulkdescriptor(); while (await result.readasync()) { counter++; var document = getdocumentobject<t>(result); var idstring = getid(result); bulkdescriptor.index<t>(op => op .routing(routingstring) .index(indexname) .type(indextype) .id(idstring) .document(document)); if (counter % 1000 == 0) { var bulkresponse = await client.bulkasync(bulkdescr

json - Invalid Control Character Error in Python 2.7.9 -

i receiving following error when running below python script. valueerror: invalid control character at: line 7591 column 220620 (char 385678) i did research on , appeared resolved passing 'strict=false' within json.dumps(), i'm still receiving same error. rest service have attempted query returns error. import arcgis import json arcgis import arcgis service = arcgis("http://mapping.dekalbcountyga.gov/arcgis/rest/services/landuse/mapserver") query = service.get(0, count_only=false) json_query = json.dumps(query, strict=false) f = open("dekalb_parcels.geojson", "w") f.write(json_query) f.close() any can provided appreciated. thank you. update - full error receiving. traceback (most recent call last): file "g:\python\scripts\dekalb_parcel_query.py", line 8, in <module> query = service.get(0, count_only=false) file "c:\python27\lib\site-packages\arcgis\arcgis.py", line 146, in jsobj = self.get_

vb.net - I want to create a package check on vb, but my codes aren't working any suggestion? -

i can't think of other way make work, suggestions? codes: public class frmpackagecheck private sub btncheck_click(sender object, e eventargs) handles btncheck.click if txtweight.text <= 27 me.lblanswer.text = "accepted" elseif txtweight.text >= 27 me.lblanswer.text = "rejected: heavy" end if if txtlength.text <= 100 me.lblanswer.text = "accepted" elseif txtlength.text >= 100 me.lblanswer.text = "rejected: large" end if if lblwidth.text <= 100 me.lblanswer.text = "accepted" elseif txtwidth.text >= 100 me.lblanswer.text = "rejected: large" end if if txtheight.text <= 100 me.lblanswer.text = "accepted" elseif txtheight.text >= 100 me.lblanswer.text = "rejected: large" end if end sub your problem me.lblanswer.text keeps getting changed. example, if weight

ASP.Net : Send email with Images embedded in Rich Text HTML body -

sending mail along embedded image & html text using asp.net. i have tried this: public actionresult contact(tblcredential data) { string emailaddress = data.username; string password = data.password; if (!string.isnullorempty(emailaddress)) { //send email consultancy string htmltext = "<img src='r:/mvc@2/emailwithhtmlbody/emailwithhtmlbody/images/message.jpg'></img> <h1>thank you</h1>"; string = "******@gmail.com"; // mail-id here emailaddress string @touser = emailaddress; // mail-id mailmessage mail = new mailmessage(from, touser); { mail.subject = emailaddress + " sent message"; mail.body = htmltext; mail.isbodyhtml = true;

functional programming - Elm function with the type: Signal (List a) -> List (Signal a) -

i new elm , functional programming in general. using elm , need function has signal (list string) input , returns list (signal string). i know shouldn't have problem better architectural design in program having function solve big problem me. the combine function opposite: combine : list (signal a) -> signal (list a) combine = list.foldr (map2 (::)) (constant []) i've tried similar combine function have been unsuccessful far. ideas on how create such function? this not possible in general the inverse of combine not (in general) possible. when have list of static size of signals, can combine them signal of lists of static size. when go other way, there no guarantee lists in signal static size. therefore cannot "just" construct list out of it. (if normal value of type list have changing size without showing signal around type, , dynamically creating , destroying signals in list. 2 things elm disallows. ) but restrictions... of course

php - assort merge two assorted arrays -

i trying merge 2 assorted arrays assorting result in php code have managed come with: <?php function assotassortedarrays($a, $b){ if (empty($a)){ return $b; } if (empty($b)){ return $a; } if ($a[0] < $b[0]){ return array_merge($a[0], array_merge(array_slice($a, 1, count($a)-1), $b)); } else { return array_merge($b[0], array_merge(array_slice($b, 1, count($b)-1), $a)); } } $a = array(1,2,3,4,5); $b = array(3,4,5,6,7); var_dump(assotassortedarrays($a, $b)); the code not work, error getting: warning: array_merge(): argument #1 not array in d:\web\a\sortarrays.php on line 14 basically interpreter saying argument 1 here array_merge(array_slice($b, 1, count($b)-1), $a)); not , array, have done print_r on elements , says arrays. doing wrong? edit , sam correct code: function mergearrays($a, $b){ if (empty($a)){ return $b; } if (empty($b)){ return $a; } if ($a[0] < $b

sql server - How do I find out if a column is required or nullable using a SQL statement? -

i need know if it's possible know if column "required" or "nullable". can't find information this. there stored procedure let's me know if column required field ? oracle select nullable user_tab_columns table_name = 'tablename' , column_name = 'columnname'; sql-server select is_nullable sys.columns object_id = object_id('tablename') , name = 'columnname'; mysql select is_nullable information_schema.columns table_name = 'tablename' , column_name = 'columnname';

php - Wkhtmltopdf unable to use the relative path for save() in Laravel 4 -

i using pdf snappy generate pdf files views in laravel 4. i can use code using download() without problem , file generated , can save it: $pdf = pdfsnappy::loadview($pdfview, $dataforpdf); return $pdf->download( 'invoice.pdf' ); however, when try use save() code: $pathtofile = "invoices/2015/full/invoice.pdf"; $pdf = pdfsnappy::loadview($pdfview, $dataforpdf); return $pdf->save( $pathtofile ); i error message: object of class barryvdh\\snappy\\pdfwrapper not converted string if try this: $pathtofile = url() . '/' . "invoices/2015/full/invoice.pdf"; $pdf = pdfsnappy::loadview($pdfview, $dataforpdf); return $pdf->save( $pathtofile ); i error message: the output file's directory http://laravel.dev/invoices/2015/full/ not created. i on windows using wamp, problem? how can save file /public folder in laravel inside invoices/2015/full/ ? ok, seems solution remove return this: return $pdf->save( $

linux - Load image files from a folder bash script Ubuntu -

i new ubuntu , learning bash script googling around. want know how load image files folder , save in array in bash script. probably not doing smart search, if knows how already, can please help? i planning path command line argument, $1 have path, far have read. thus, have code #!/bin/bash f in "$1" echo "$f" done but output prints 1 file instead of 36 files. can please me here? note : input giving of format /path/*.png that glob ( /path/*.png ) has been expanded shell when script called. you have filenames in $@ (the array of positional parameters script/function). try echo "$@" to see them or for file in "$@"; echo "$file" done the default list in $@ can use for file; do in place of for file in "$@"; do if want.

PHP: creating HTML table from nested array (json) but getting results AND "invalid argument supplied for foreach()" -

i trying create html table array obtained through api/json. it's nested array (the actual data nested within session) array ( [sessid] => -hnkgi-k1rgwhnymkcscr0bom-rrkurn2s1pgmzobx4 [status] => 0 [players] => array ( [0] => array ( [first_name] => chris [last_name] => clausing [pdga_number] => 31635 [rating] => 930 [year] => 2014 [class] => [gender] => m [bracket] => open [country] => nl [state_prov] => [tournaments] => 11 [rating_rounds_used] => 36 [points] => 998 [prize] => 0.00 ) [1] => array ( [first_name] => uwe walter [last_name] => schlueter [pdga_number] => 37788

npm choose global install directory -

i want install npm dependencies package.json in current directory, want install them different directory. can make setting (install directory of node_modules) project specific, not interfere other projects? you can try --prefix . npm install --prefix new/path/node_modules https://docs.npmjs.com/misc/config#prefix note: important, there node_modules folder

Error with facebook connections in android -

i have problem facebook. in connection have: url url = new url("https://www.googleapis.com/oauth2/v1/userinfo?access_token="+ token); httpurlconnection con = (httpurlconnection) url.openconnection(); int sc = con.getresponsecode(); and get: java.net.unknownhostexception: unable resolve host "www.googleapis.com": no address associated hostname i have permissions in manifest like:access_network , internet. i resolve problem: httpurlconnection con = (httpurlconnection) url.openconnection(); con.setreadtimeout(10000 /* milliseconds */); con.setconnecttimeout(15000 /* milliseconds */); con.setrequestmethod("get"); con.setdoinput(true); // starts query con.connect(); int sc = con.getresponsecode();

java - Is there a danger in having a high number (20+) of simple threads? -

i writing game in java. have in-game tutorials. each tutorial 5-10 frame animation changes every second. for each tutorial, have simple thread running: int sleeptimemillis = 1000; public static void run() { while ( true ) { try { tutorialframe = ( tutorialframe + 1 ) % numberofframes; thread.sleep ( sleeptimemillis ); catch ( interruptedexception e ) {} } } i have 10 of these running. time finish of them, imagine i'll have 50. otherwise, game uses handful of threads: 1 windowing environment, 1 game logic, 1 rendering engine, , handful of other small ones here , there. unsurprisingly, haven't noticed speed issues in game adding these threads. being said, i'm not knowledgeable on behind-the-scenes overhead having many threads within process. i restructure program in different way if desirable reduce number of these tutorial threads. so i'm asking whether it's worth time re-structure tutorials little sha

javascript - Why does it skips 5th alert box? -

i tried submit without selecting radio button numbers. should alert me 7 times. however, got 6! seems skips 5th alert box. , don't know reason why. can me? thanks! <html> <head> <style type="text/css"> h1{ width:100%; background-color:maroon; color:white; } fieldset{ width:500px; margin:auto; } </style> <script> function checkanswers(){ var inputs = document.queryselectorall('input[type="radio"]'); var check = 0; var score = 0,i=0; for(i;i<inputs.length;i++){ var inputname = inputs[i].getattribute("name"); var checker = document.getelementsbyname(inputname); var counter = false; for(j=0;j<checker.length;j++){ if(checker[j].checked == true){ counter = true; += 4; break; } } if(counter == false){

bash - Propagate ENV variables to ZSH -

i'm calling script using: zsh -c 'myscript' -- $args where myscript exists in folder added path .zshrc . when run command zsh can't find myscript, since path reset default. when run similar command using bash: bash -c 'myscript' -- $args the myscript found, i'm assuming since path passed through bash. is there way enforce path, , other env vars, propagate down zsh?

html - How to apply custom style to <a> tag? -

i'm attempting style href using custom style, named mystyle : <a href="http://www.google.com">red hover</a> <a class="mystyle" href="http://www.google.com">blue hover</a> .mystyle { a:hover { color: blue; } } /* unvisited link */ a:link { color: green; } /* visited link */ a:visited { color: green; } /* mouse on link */ a:hover { color: red; } /* selected link */ a:active { color: yellow; } http://jsfiddle.net/uzag9/863/ so red hover should changed red on hover - works 'blue hover' not change on hover. i'm using style in attempt change hover : .mystyle { a:hover { color: blue; } } but don't think format correct ? how can apply custom style <a> tag ? try: a.mystyle:hover { /* css here */ }

javascript - How can I automatically find out which jQuery selectors are slow on my site ? Is there a plugin for this? -

i automatically detect whenever jquery selector slow (> some_millis) want console log line number. my first idea override core jquery selector code insert such test there, there existing plugins achieve this, has attempted similar ? browser tool (maybe filter method calls in profiler) ? note not want put perf monitoring js code around each selector call ! a quick google search yields: http://seesparkbox.com/foundry/jquery_selector_performance_testing https://learn.jquery.com/performance/optimize-selectors/ the reference js profiler dead, here preferable way via chrome: https://developer.chrome.com/devtools/docs/cpu-profiling now open chrome devtools, navigate profiles panel, , verify "collect javascript cpu profile" selected. now, click start button or press cmd + e start recording javascript cpu profile.

css - Bootstrap Caret collapsing -

Image
i have been working on bootstrap reskinning project, , ran odd bug buttons. the caret in dropdown seem collapsing when used btn-lg class (as shown in 2 images below). i've did comparison on compiled css on btn , dropdown-toggle , caret , , nothing significant (other margin, padding, colors etc) seem different. any appreciated! thanks!

Clustering Node.js on Bluemix -

will node.js app on bluemix automatically scaled run on multiple processors, or need implement myself using node's clustering api? , if use clustering, there more 1 cpu available? short answer: need use node cluster module take full advantage of cores in each instance. or, can increase number of instances. long answer: each instance of application push bluemix runs in warden container. resource control managed linux cgroups. number of cores per instance not can control. running quick test on bluemix, os.cpus() showed 4 cores. if want take advantage of 4 cores, in 1 bluemix instance (warden container) of node.js application, should use nodes cluster module. keep in mind, can increase number of instances (horizontal scaling), achieve near linear results depending on bottleneck on use of external services. if have 3 instances, each of instances has 4 cores, , built-in load balancer distributes traffic among 3 instances.

git - Is there a diff & patch for large cut & pastes -

is there tool/workflow making diff+patch operation "commute" large cut & pastes operation between text files? we've 3 files source.old , source.new , , destination . copied several text hunks source.old destination , otherwise these files have shared history. we've since edited source.old produce source.new , suspect changes appearing in copied hunks relevant destination . we first automatically identify copy & pastes either using copy & paste detecting tool or specifying specific git commits representing paste operations on destination . copy & paste edited copy, should describe copy & paste operations using diff-like context both source.old , destination , , provide diff each copied hunks. we next create patch file representing changes source.old source.new occur within copied hunks, necessary replace context source.old context destination , , reorder hunks match destination . apply patch interactively picking relevant chan

MySQL find duplicates in multiple columns -

i have table user ids split 2 columns. (to explain little more, capture ids of participants scanning barcodes. barcode scanner function doesn't work whatever reason, allow manual entry of id, if barcode scanner doesn't work.) results in data following: +------+-----------+ | id | id_manual | +------+-----------+ | | null | | null | | | b | null | | b | null | | null | c | | c | null | | null | d | | null | d | +------+-----------+ i want find of duplicate ids, taking both columns account. it's easy find duplicates in 1 column ("b" , "d"). how find duplicates "a" , "c"? ideally, query find , return duplicates (a,b,c, , d). thanks! an advice: field named id m,ust unique , not null. if have structure, can try this: select id yourtable t id not null , (select count(*) yourtable t2 t2.id = t.id) + (select count(*)

python - django filer no module named fields.image error -

i have problem. have installed filer , when import filer fine import filer importing when from filer.fields.image import filerimagefield it not importing , gives error no module named fields.image what problem? have gone through documentation , gives same way of importing. you have python file called filer.py or python module (folder containing __init__.py file) called filer in current directory (or somewhere in python_path ) shadows filer package installed. you need remove or rename file/module in order able use filer package.

web services - Jquery $.getJSON adds script tag to head -

i debugging , noticed whenever call webservice $.getjson plugin webservice url gets added script tag in head of html split seconds , dissappears again. script tag has async property. is normal behaviour ? $.getjson(options.url, function(data) { self.address = data; self.addresswscallback(); }); according jquery cookbook cody lindley if request cross-domain, jquery automatically treat request jsonp , fill in appropriate callback function name. means jquery initiate request inserting tag document instead of using xmlhttprequest object. cross-domain requests in javascript jsonp relies on fact tags can have sources coming different origins. when browser parses tag, script content (residing on origin) , execute in current page’s context. normally, service return html or data represented in data format xml or json. when request made jsonp-enabled server however, returns script block executes callback function calling page h

java - How to get onFocus() to fire with Selenium -

i'm trying test html form using selenium. page authenticates input data using javascript's onfocus() event on each text field (which input tag in html ). such, code needs make sure onfocus() fired whenever interact text field, if real user filling out form. i expect following code fire event: this.textfield.clear(); if (value != null) { this.textfield.sendkeys(value); } however, onfocus() event doesn't fire. i've tried manually clicking element this.textfield.click() but doesn't work. i've tried using actions class this.textfield.clear(); actions action = new actions(driver); action.movetoelement(this.textfield).click().sendkeys(value.tostring()).perform(); but hasn't given me luck. is there way in selenium ensure onfocus() event executed? you can execute javascript in browser session explicitly fire onfocus(). code in c#, there must similar in java bindings too. ((ijavascriptexecutor)driver).executescript(string.forma

java - Register remote Weblogic to Netbeans -

i know can register remote weblogic server jdeveloper , eclipse can't figure out how netbeans . i have searched through internet , can't clear answer. functionality supported or not? i browsing @ netbeans roadmap , accidentally found: remote_weblogic which means development support remote weblogic server available when netbeans 8.1 comes out.

php - Checking keywords in post and find matches -

i can not write code check keywords in news if exist 2 matches 5 keywords. script insert post in new database. here code check 1 keyword , if exist insert news in database. $sq = 'select keyword keyword'; $receivekey = mysqli_query($conn,$sq); if(! $receivekey ) { die('could not load data: ' . mysql_error()); } while($row = mysqli_fetch_array($receivekey)){ $itemkey[] = $row['keyword']; } //echo '<br>'.$itemkey[1]; foreach( $itemkey $newkey => $value){ echo '<br>'.$value; //print_r($value); } mysqli_close($conn); //select correct xml social media //read xml , check preference //$content = simeplexml_load_file('facebook.xml'); $xml = simplexml_load_file('facebook.xml'); foreach($xml->tue14apr2015 $entry); foreach($entry->post $new){ $new = strtolower($new); if (is_array($itemkey)) { foreach($itemkey $e => $ne){ $pos = strpos($new, $ne);

d3.js - Change width of ellipse when zooming -

i trying create heatmap in d3js zoom , pan feature. far, pan function works should, have minor problem zoom feature. the zoom feature should scale (stretch/squeeze) in direction of x-axis, @ moment. right now, initial view of heatmap—when load script—shows me entire dataset squeezed dots, want. problem squeezed dots stay squeezed when zoom in, leads huge gaps between them. scale dotwidth of svg ellipses (the dots) avoid this. however, not sure how implement it. below code samples script. to more specific: if initial height , width of ellipse 1 , 3, respectively, width scale between 1 , 3, becomes circle under max zoom. create heatmap: var dotwidth = 1 var dotheight = 3 // heatmap ellipes svg.selectall("ellipse") .data(dataset) .enter() .append("ellipse") .attr("cx", function(d) { return xscale(d.day) + paddingleft; }) .attr("cy", function(d) { return yscale(d.hour); }) .attr("rx", dotwidth) .att

Why do I get a 'permission denied' error when I try to access a serial device when executing python script on Jenkins? -

if execute following script user 'build' in command line works: #!/usr/bin/python import serial import pwd import os import grp user = pwd.getpwuid(os.getuid()).pw_name print user groups = [g.gr_name g in grp.getgrall() if user in g.gr_mem] gid = pwd.getpwnam(user).pw_gid groups.append(grp.getgrgid(gid).gr_name) print groups print oct(os.stat("/dev/ttyusb0").st_mode & 0777) ser = serial.serial('/dev/ttyusb0', 115200, timeout=1) print ser.portstr # check port used ser.write("hello") # write string ser.close() the output is $ python test-serial.py build ['dialout', 'build'] 0660 /dev/ttyusb0 if execute script in jenkins job get [envinject] - loading node environment variables. building remotely on build-node in workspace /home/build/workspace/test-serial-python [test-serial-python] $ /bin/sh -xe /tmp/hudson7262474284926512955.sh + /usr/bin/python /home/build/test-serial.py build ['dialout', '

javascript - Pass in an array of Deferreds to $.when() -

here's contrived example of what's going on: http://jsfiddle.net/adamjford/yngcm/20/ html: <a href="#">click me!</a> <div></div> javascript: function getsomedeferredstuff() { var deferreds = []; var = 1; (i = 1; <= 10; i++) { var count = i; deferreds.push( $.post('/echo/html/', { html: "<p>task #" + count + " complete.", delay: count }).success(function(data) { $("div").append(data); })); } return deferreds; } $(function() { $("a").click(function() { var deferreds = getsomedeferredstuff(); $.when(deferreds).done(function() { $("div").append("<p>all done!</p>"); }); }); }); i want "all done!" appear after of deferred tasks have completed, $.when() doesn't appear know how handle array of

regex - Java string how to replace " with \" to escape JSON? -

this question has answer here: regex: how escape backslashes , special characters? 1 answer i trying replace " \" in java, slashes getting confusing. proper way replace " \" in java? string.replaceall("\"","\\""); if going replace literals don't use replaceall replace . reason replaceall uses regex syntax means characters treated specially + * \ ( ) , make them literals need escape them. replace adds escaping mechanism automatically, instead of replaceall("\"", "\\\\\"") you can write replace("\"", "\\\""); which little less confusing.

android - ListView in Fragment not showing up -

i'm using library in fragment, when run app swipemenulistview not showing contents, here on stack found guys using listview inside oncreateview method, tried didn't work public class autorizadasfragment extends fragment { private swipemenulistview listview; private customarrayadapter adapter; private list<string> data; public autorizadasfragment() { } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.fragment_autorizadas, container, false); return rootview; } @override public void onactivitycreated(bundle savedinstancestate) { // todo auto-generated method stub super.onactivitycreated(savedinstancestate); data = new arraylist<string>(); data.add("teste 1"); data.add("teste 2"); data.add("teste

python - looping through dictionary of inconsistent lists -

i parsing xml , converting dictionary. there dictionary 'directories': {'dirname': 'd:\\directory\\subdir'}, or 'directories': { 'dirname': [ 'd:\\directory1\\subdir1', 'd:\\directory2\\subdir2']}, how loop through dictionary. doing works if has multiple elements. should check if dirname list of elements or element , there looping through ? or there pythonic way achieve this rules = [] v in args["directories"]["dirname"]: rules.append(os.path.join(v, "*", "*")) output: input 'directories': { 'dirname': [ 'd:\\directory1\\subdir1', 'd:\\directory2\\subdir2']}, rules[] = ['d:\\directory1\\subdir1\\*\\*', 'd:\\directory1\\subdir1\\*\\*'] for input 'directories': {'dirname': 'd:\\directory\\subdir'}, ['d\\*\\*

php - combine two foreach statements( image& text) -

i'm using "foreach" statement fetch images folder print on webpage. i need give 'links' these images. links saved in database table called 'advertisement'. i fetched images , displayed correctly. but can't make these images links. i used "foreach" statement fetch 'link' rows table 'advertisement' table. but how combine these two. here example of how it: $files = array('1.jpg','2.jpg'); $stm = $pdo->query('select * advertisement'); $linkinfo = $stm->fetchall(pdo::fetch_assoc); $outputarray = array(); foreach( $linkinfo $row ) { if( in_array($row['file'], $files) ) { $outputarray['file'] = $row['link']; } } foreach( $outputarray $file => $link ) { echo "<a href='".$link."'><img src='". $file ."'></a>"; } not sure how structure is, have table this: -----

c++ - MSVC - Suppress template being compiled with messages -

i have application uses numerous templates , template specializations, , during msvc compilation many messages output showing how templates being compiled. makes incredibly difficult time finding actual compilation error. these messages not output when application compiled on linux using g++. c:\program files (x86)\microsoft visual studio 12.0\vc\include\map(382) : see reference function template instantiation 'std::pair<std::_tree_iterator<std::_tree_val<std::_tree_simple_types<std::pair<const _kty,_ty>>>>,bool> std: :_tree<std::_tmap_traits<_kty,_ty,_pr,_alloc,true>>::insert<std::pair<std::string,uint64_t>>(_valty &&)' being compiled [ _kty=std::string , _ty=size_t , _pr=std::less<std::string> , _alloc=std::allocator<std::pair<const std::string,size_t>> , _valty=std::pair<std::string,uint64_t> ] is there way can supp

javascript - How do I create an HTML message for a mouseConstraint on this cradle? -

this i'm trying work on right now, matter.js library. want use 2 events trigger 2 html messages grabbing ball on left side of cradle "hey grabbed cradle" , when let go, "wow, @ that!". // matter.js - http://brm.io/matter-js/ // matter module aliases var engine = matter.engine, world = matter.world, body = matter.body, composites = matter.composites, mouseconstraint = matter.mouseconstraint; // create matter.js engine var engine = engine.create(document.body, { render: { options: { showangleindicator: true, showvelocity: true, wireframes: false } } }); // add mouse controlled constraint var mouseconstraint = mouseconstraint.create(engine); world.add(engine.world, mouseconstraint); // add newton's cradle (using composites factory method!) var cradle = composites.newtonscradle(280, 150, 5, 30, 200); world.add(engine.world, cradle); // offset first body in cradle swing body.translate(cradle.bodies[0], { x:

java - Add MultiLine smiley in EditText -

<edittext android:id="@+id/edtinput" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="2" android:background="@android:color/white" android:gravity="top|left" android:padding="4dp" android:textcolor="@android:color/black" /> hi, read many questions similar question still not find solution. making 1 chat application in want add smileys in edittext . facing 1 problem when m adding smiley add in edittext continue end of line when next line come first line not shown. please me solve . code snippet adding smiley edittext. addspannable(bitmap bitmap, context context,string filepath) { drawable d = null; if (mainactivity.edtinput != null) { spannablestring ss = new spannablestring(mainactivity.edtinput .geteditabletext().append(" ")); imagespan span = new imagespan(dec

jquery - Kendo contextMenu select function for specific items -

i'm trying create contextmenu usig kendocontextmenu widget. works using following code. $("#contextmenu").kendocontextmenu({ target: "#tree", filter: ".k-item", select: function(e) { alert("selected"); }, datasource: [ { text: "item1"}, { text: "submenu1", items: [ { text: "item1" } ] }, { text: "submenu2", items: [ { text: "item1" } ] } ] }); but want specify function each item execute when item clicked. don't want determine execute based on text contents. i've tried add click item in datasource doesn't seem work. kendo contextmenu doesn't have feature, have 2 options: first, configure context menu using html onclick events: <ul id="menu"> <li> option 1 <ul> <li onclick="alert('test')

javascript - Example with .queue() & .dequeue() to do with $.queue() & $.dequeue() -

i have done animation using animate() , queue() , , dequeue() . have read jquery has - jquery.queue() or $.queue() , jquery.dequeue() or $.dequeue() . can me these new terms of example, making changes , using - $.queue() , $.dequeue() ? ... <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> </head> <body> <button id=but1>click</button> <div id=div1 style="width:50px;height:50px;position:relative;background:pink;">hi</div> <script> $(document).ready(function() { $('#but1').click(function() { $('#div1') .animate({ left: "+=300px" }, 3000) .queue(function() { $(this).html("hello") .css('background', 'red&

python - django - unique_together change - any danger in prod db? -

i have model: class mymodel(models.model): name = models.charfield(max_length=10) nickname = models.charfield(max_length=10) title = models.charfield(max_length=10) score = models.charfield(max_length=10) class meta: unique_together = ['name', 'nickname'] what impact of changing unique_together unique_together = ['name', 'title'] should careful before deploying update? there more 150.000 users online @ same time, happen in worst case? yes, careful deploying change affects database. the documentation : this tuple of tuples must unique when considered together. it’s used in django admin , enforced @ database level (i.e., appropriate unique statements included in create table statement). so need migrate database change unique constraint. python manage.py makemigrations myapp python manage.py migrate myapp you need check there aren't existing instances of model sharing pairing of unique constrain

axapta - How to use container or generic variable in a query? -

it's possible use string value in query? i have code in form init method: container con; select mytable mytable.myfield == conpeek(con, 1); //i fill stringeditcontrol stringedit.text(strfmt('%1', mytable.myfield)); i have error this: "the fields of type string container , unconstrained not allowed in expression." how can use value string or container (in case) in query? thanks time, enjoy! extract string container prior using select statement: mytable mytable; container con; str 50 strvalue; strvalue = conpeek(con, 1); select mytable mytable.myfield == strvalue; stringedit.text(strfmt('%1', mytable.myfield));

html5 - AngularJS SPA What's the best way to make a login service with a large app? -

i working on project 100+ pages , using angularjs ui-route , php rest backend. authentification want use json web token. i trying find best way make login page, didn't found way still, after lot of googling. my app allows logged in users access it, else should go login page. my main problem how should organize index.html because login page has totally other template rest of app. in index.html have lot of elements header , footer loaded on pages, except on login page. in order achieve used ng-if={{user.isloggedin}}, it's not right thing do, think, because 1 page must have condition on pages. another idea use 2 apps, if user not logged in redirected login app (actually redirection, not change of state, because uses master template). is there way in keep login page in spa, have 1 app? thanks in advance valid answer , hope i've been clear possible. look nested views ui-route. able have $state.login , $state.dashboard state while logged in follow $stat

ruby - Rails Error - Uninitialized Constant -

upon setting new rails project have come across following issues on rails s command john-macbook-pro:coffee john$ rails s /users/john/development/coffee/config/application.rb:10:in `<module:coffee>': uninitialized constant coffee::rails::application (nameerror) /users/john/development/coffee/config/application.rb:9:in `<top (required)>' /users/john/.rvm/gems/ruby-2.1.2/gems/railties-4.0.3/lib/rails/commands.rb:74:in `require' /users/john/.rvm/gems/ruby-2.1.2/gems/railties-4.0.3/lib/rails/commands.rb:74:in `block in <top (required)>' /users/john/.rvm/gems/ruby-2.1.2/gems/railties-4.0.3/lib/rails/commands.rb:71:in `tap' /users/john/.rvm/gems/ruby-2.1.2/gems/railties-4.0.3/lib/rails/commands.rb:71:in `<top (required)>' bin/rails:4:in `require' bin/rails:4:in `<main>' what causing , how fix it? thanks looking. application.rb file: require file.expand_path('../boot', __file__) r

spring - SpringXD limitations? -

i'm evaluating springxd , wondering if there limitations current functionality provides. couldn't find documentation on , i'm sure answer falls under "it depends" category, thought ask anyways. examples of mean are: is there max limit on number of streams can created? (i'm guessing not these seem backed database answer may depend on streams doing) is there max limit on number of named channels can created? (i'm guessing may depend on underlying mom used message passing) is there max limit on number of nodes (xd-node or xd-admin) can running in system? (i'm guessing depends on zookeeper , on how many connections underlying mom allows) etc. so speaking, there limitations of potential use cases people should aware of before picking springxd? thank you, aaron edit answer @dturanski the situation i'm thinking of having potentially large number of streams (technically unbounded). i'm talking minimum of maybe couple thousand in be