Posts

Showing posts from August, 2010

java - The number occurrence of a character is to be counted in a given line string. Can anyone point out where the error is? The code compiles correctly -

the idea count number of occurrence of given character user inputs in line of string imputed user. idea use recursion in java rather sort of loop. code compiles correctly , runs correctly. result not give correct answer (does not count asked character correctly in given line of string.) can point out? import java.util.scanner; public class numberofletters { public static int lettercounter(string line, string x) { if(line.isempty()) { return 0; } else { if(line.charat(0) == 'x') { return 1 + lettercounter(line.substring(1), x); } else { return 0 + lettercounter(line.substring(1), x); } } } public static void main(string[] args) { scanner keyboard = new scanner(system.in); system.out.println("enter line of string >_ "); string inputline = ke...

html - Load <link> tags async with guaranteed order -

after running google pagespeed , recommended use async or defer css content eliminate render-blocking javascript , css in above-the-fold content your page has 6 blocking css resources. causes delay in rendering page. none of above-the-fold content on page rendered without waiting following resources load. try defer or asynchronously load blocking resources, or inline critical portions of resources directly in html. so exploring async attribute on <link> tag <link rel="stylesheet" href="{{asset "css/bootstrap.min.css"}}"> <link rel="stylesheet" href="{{asset "css/font-awesome.min.css"}}"> <link rel="stylesheet" type="text/css" href="{{asset "css/screen.css"}}"> <link rel="stylesheet" type="text/css" href="{{asset "css/highlight_styles/rainbow.css"}}"> now if add async attribute above ...

Does Storm keep sending tick tuples to bolts when a topology is deactivated? -

as part of development of streamparse, have batchingbolt processes tuples in batches. it's intended use things databases more performant when send things in batches. i've proposed switching our batchingbolt implementation on using timer/thread approach using tick tuples; however, 1 of fellow devs pointed out our current approach final batch processed when topology shutdown (and it's in inactive state), whereas isn't explicitly documented anywhere tick tuples. therefore, question this: storm continue sending tick tuples bolts after kill/deactivate has been issued, while in waiting/inactive period? topology lifecycle docs don't make clear. http://mail-archives.apache.org/mod_mbox/storm-user/201506.mbox/%3ccaf5108ijgpdmeax1lakq1mg6mszqf=ym=vo8aacmn0ruinfnkq@mail.gmail.com%3e afaik, "setup-tick!" called start of executor (which schedules tick timer each executor), , tick tuples emitted unless worker going shutdown. in short, fellow cor...

java - Debugging Conway's Game of Life Graphics? -

i trying make simple version of conway's game of life computer generates grid of rectangles , fills in rectangles represent "live" cells. problem having cannot grid clear after first pattern, patterns generated on same grid , looks big blob of colored rectangles. here code: public class gameoflife { static jpanel panel; static jframe frame; public static void main(string[] args) throws interruptedexception{ int [][] array = new int [17][17]; /* * set pattern conway's game of life manipulating array below. */ array[2][4]=1; array[2][5]=1; array[2][6]=1; panel = new jpanel(); dimension dim = new dimension(400,400); panel.setpreferredsize(dim); frame = new jframe(); frame.setsize(1000, 500); container contentpane = frame.getcontentpane(); contentpane.add(panel); frame.setvisible(true); /* * runs game of l...

c# - Showing Database Search results in Datagridview -

i using visual studio 2013 sql server 2012 database in windows forms application c#. i want show query search results in datagridview : public void customersearch(int custid, datagridview datagridview) { try { sqlconnection connection = new sqlconnection(@"connection string"); connection.open(); sqlcommand searchquery = new sqlcommand("select * [customer] custid = @custid", connection); searchquery.parameters.addwithvalue("@custid", custid); //searchquery.executenonquery(); using (sqldatareader reader = searchquery.executereader()) { while (reader.read()) { datagridview.databindings.tostring(); } } } catch (sqlexception exception) { messagebox.show(exception.tostring()); } { connection.close(); ...

r - Rewrite code using %>% operator -

i tried rewrite code (to learn approach), using %>% operator: library(arules) data(adultuci) #https://archive.ics.uci.edu/ml/datasets/census+income adultuci[["capital-gain"]] <- ordered(cut(adultuci[["capital-gain"]], + c(-inf, 0, median(adultuci[["capital-gain"]][adultuci + [["capital-gain"]] > 0]), inf)), + labels = c("none", "low", "high")) is possible do? here attempt: adultuci[["capital-gain"]] <- ordered %>% cut %>% adultuci[["capital-gain"]], + c(-inf, 0, median(adultuci[["capital-gain"]][adultuci[["capital-gain"]] > 0]), + inf),labels = c("none", "low", "high") this should work: library(dplyr) #reproducible data adultuci <- read.csv("https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data",header=false) co...

Checking the Value of a Specific Column in Every Row of a CSV with Python -

using data follows simplicity: name,age,height joe,14,65 sam,18,74 sarah,21,62 i want go through each line of file, compare age column value (for example: 16). if value less fixed value, want delete line. in example, i'd left following data: name,age,height sam,18,74 sarah,21,62 thanks in advance! here's basic example, using csv module. creates new file less criteria data. #!/usr/bin/python import csv infile = 'input.csv' outfile = 'output.csv' wfh = open(outfile, 'w') open(infile, 'r') fh: reader = csv.dictreader(fh, delimiter=',') row in reader: name = row['name'] age = row['age'] height = row['height'] if age >= 16: wfh.write("{},{},{}".format(name, age, height)) wfh.close()

pip - How to install requests module in python 3.4 version on windows? -

what command should use in command prompt install requests module in python 3.4 version ??? pip install requests is not useful install requests module in python 3.4 version. because while running script below error coming importerror : no module named 'requests' python -m pip install requests

boolean - PHP Switch True / False constant values -

is there way switch defined constant values of true / false in php? trying make true = false , false = true. i've tried several attempts not seem allow me change: define("false",1); define(false,1); false = true; the final 1 results in php internal server error, first 2 nothing. none of these seem work. true / false defined somewhere deeper within compiled php cannot re-set? note: educational purposes , understand how these values defined, since appears "untouchable". not trying write blasphemous code checks things in reverse. you can't it, can write true , false. way, work use constant() if defined both constants, e.g. define(false, true); define(true, false); var_dump(constant(true)); output: bool(false)

javascript - How to dynamically grab the first available number in a loop? -

been going @ while, figured i'd post here help. items = { '417': { a: 23, slot_position: 13 }, '419': { a: 28, slot_position: 2 }, '420': { a: 29, slot_position: 12 }, '421': { a: 29, slot_position: 3 }, '424': { a: 31, slot_position: 17 }, '425': { a: 32, slot_position: 7 }, '428': { a: 35, slot_position: 0 }, '429': { a: 36, slot_position: 0 }, '431': { a: 42, slot_position: 0 }, '432': { a: 40, slot_position: 0 }, '433': { a: 43, slot_position: 11 }, '434': { a: 44, slot_position: 0 }, '435': { a: 45, slot_position: 0 }, '436': { a: 47, slot_position: 0 }, '437': { a: 48, slot_position: 15 }, '438': { a: 48, slot_position: 1 }, '439': { a: 48, slot_position: 0 }, '440': { a: 48, slot_position: 14 }, '441': { a: 43, slot_position: 0 }, '442': { a: 44, slot_position: 0 }, '4...

c++ - How to use boost::thread::at_thread_exit or call a function when thread is done -

this minimal code illustrate need. doesn't work, because (as rightly error message says when compiling) at_thread_exit not member of boost::thread. know related namespace this_thread, i've been going through documentation @ boost page, cannot follow how use at_thread_exit. haven't been able find simple example of how use using google. #include <boost/thread.hpp> #include <iostream> class a{ public: void callme(){ int = 1; } void runthread() { boost::thread td(&a::callme,this); td.at_thread_exit(&a::done,this); td.join(); } void done() { std::cout << "i done!!!\n"; } }; int main(int argc, char **argv) { *a = new a(); a->runthread(); delete a; return exit_success; } boost::thread td([this]{ callme(); done(); }); at_thread_exit works within same thread; require sychronization otherwise, , make every thread pay when threads use it. ...

asp.net - Roles.GetRolesForUser() in Layout view not returning roles -

@roles.getrolesforuser() in razor layout view not returning roles. @roles.getrolesforuser().count() 0. while @roles.isuserinrole('name_of_logged_in_role') returns true in same view @ same place. razor view: <p> @user.identity.name //output: myname @roles.getrolesforuser().count() //output: 0 @roles.isuserinrole("radiologist") //output: true </p> update @roles.getrolesforuser(user.identity.name).length //output: 0 @roles.getrolesforuser(user.identity.getusername()).length //output: 0 after extensive research, found problem. able reproduce issue in web application. apparently, cannot combine asp.net identity simple membership , did getrolesforuser method. roles object default setup simple membership using default provider, seems using asp.net identity not simple membership . didn't notice difference until wondering myself why wasnt working. the reason why got string[0] because getrolesforuser execut...

php - Highcharts failing to display data -

Image
i trying create simple program takes weather data database have setup, , display on webpage. way have setup right have enter value in text box in order data pull. my html code: <!doctype html> <html> <head> <title>database</title> </head> <body> name: <input type="text" id="name"> <input type="submit" id="name-submit" value="grab"> <div id="name-data"></div> <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div> <script src="http://code.jquery.com/jquery-1.8.0.min.js"> </script> <script src="js/global.js"></script> <script src="http://code.highcharts.com/highcharts.js"></script> ...

How to efficiently do a limit query on MongoDB GridFS -

i cannot seem find efficient way query against mongodb gridfs contains limit of n files. here have tried. dbcursor filelist = products.getfilelist().limit(10); while(filelist.hasnext()){ dbobject filedef = filelist.next(); file = products.findone((string)filedef.get("filename")); inputstream stream = file.getinputstream(); ... } the problem there 21 query operations occur. first getfilelist() calls dbcollection.find(). then each result findone() occurs ends calling dbcollection.find({"filename":filename}) 10 times. after that, when call read on input stream, calls findone("files_id":id) on chunks collection 10 files. i noticed in gridfs.find() queries files collection, converts each dbobject gridfsdbfile, , sets (fs) variable this (gridfs). (all via injectgridfsinstance(object)) if getfilelist() operation did well, returns standard cursor. can cast dbobject gridfsdbfile when try call read on inputstream complains the...

mysql - How can I query unique columns, conditionally choosing which row based on another column's value? -

i have following setup: date | event | hits jan | | 0 jan | b | 2 jan | c | 0 feb | | 4 feb | b | 0 feb | c | 0 and i'm looking query returns: events unique (only return [jan | b | x] or [feb | b | x] , not both) prioritize hits (so [jan | b | 2] beats [feb | b | 0] ) secondarily prioritize recent date ( [feb | c | 0] beats [jan | c | 0] ) i want query above table return: feb | | 4 jan | b | 2 feb | c | 0 select (select edate stuff sx s.event=sx.`event` order sx.hits desc,sx.edate desc limit 1) date, s.event, (select hits stuff sx s.event=sx.`event` order sx.hits desc,sx.edate desc limit 1) hits stuff s group event order event table stuff edate field defined date. not efficient large tables, works.

java - Random button Android project -

i want make app when click button go random place on screen. want imagebutton when onclick go random place on screen. i've attempted before. no success. here of code i've attempted with. ---> package com.example.e99900004533.candycollector; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.graphics.point; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.view.onclicklistener; import android.view.display; import android.view.viewgroup.marginlayoutparams; import android.animation.objectanimator; import android.widget.relativelayout; import android.widget.edittext; import android.widget.imagebutton; import java.util.random; public class mainactivity extends actionbaractivity { public edittext collectedtextedit; public imagebutton candyedit; public int collected = 0; public int screenwidth = 300; public int screenheight = 300; random random = new random();...

php - Prepared statement - cross table update -

i attempting use prepared statement in combination cross table update. have prepared sample script representative of our larger database. first section want without prepared statement, hoping avoid copy/pasting every column of data. set session group_concat_max_len = 1000000000; drop table if exists update_test; create table update_test( time_index decimal(12,4), varchar(20), b varchar(20), c varchar(20)); insert update_test(time_index) values(20150101.0000),(20150101.0015),(20150101.0030); drop table if exists energy_values; create table energy_values( time_stamp decimal(12,4), site_id varchar(5), energy int); insert energy_values values(20150101.0000,'a',100),(20150101.0000,'b',200),(20150101.0000,'c',300), (20150101.0015,'a',400),(20150101.0015,'b',500),(20150101.0015,'c',600), (20150101.0030,'a',700),(20150101.0030,'b',800),(20150101.0030,'c',900); drop table if exists update_test_sites; cr...

javascript - D3.js network graph using force-directed layout and rectangles for nodes -

i'm trying modify mike's force-directed graph example use rectangles instead of circles nodes. also, want text inside rectangle. i have rectangles showing text correctly, they're not attached links, , not move. here's codepen link: http://codepen.io/anon/pen/gpgwaz var width = 960, height = 500; var color = d3.scale.category20(); var force = d3.layout.force() .charge(-120) .linkdistance(30) .size([width, height]); var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height); force .nodes(graph.nodes) .links(graph.links) .start(); var link = svg.selectall(".link") .data(graph.links) .enter().append("line") .attr("class", "link") .style("stroke-width", function(d) { return math.sqrt(d.value); }); var node = svg.selectall(".node") .data(graph.nodes) .enter() ...

android - How to detect a client that stops listening in firebase? -

let's have 3 clients listening changes on firebase root. each client represents user in list (or map) on root. want remove user loses connection or closes client app (i.e. stops listening). how can detect when happens , handle change? super easy. check out ondisconnect(). can write data out node when user disconnects or update value in node. example, on disconnect change user status (maybe stored in users node) status:disconnected.

r - plotting means, errors, and then raw data in background - simpler code? -

Image
i want plot mean , standard error of continuous variable, grouped categorical 1 in r . want in background have actual raw data points went in generating mean , standard error. resulting plot this: i coded myself, requires multiple custom functions (for generating standard error, group means), adding things data frame generate jitter , around graphics hiccups. code copied here , generate necessary data: ##generate fake data### ctrl<- rnorm(20,1,0.5) treated<- rnorm(20,2,0.5) ctrl.lab<- rep('ctrl',20) treated.lab<- rep('treated',20) #adding 1s , 2s correspond treatment plotting later. niormal distribution allows me jitter points along y-axis ctrl.alt<- rnorm(20,1,0.02) treated.alt<- rnorm(20,2,0.02) alt<-c(ctrl.alt,treated.alt) later lab<-c(ctrl.lab,treated.lab) response<- c(ctrl,treated) data<-data.frame(lab,response,alt) #make function plotting error bars errb <- function (x, y, ebl, ebu = ebl, length = 0.06, ...){ arrows(...

sql server - Updating a column based on first occurance of a text in another column -

i have requirement convert 150 char free form text , map 1 of 2 texts: sibling or spouse in member_type field in sql server database. i came below update statement update: update my_table set member_type = case when (relationship_description 'brother%' or relationship_description 'sister%' or relationship_description 'sibling%' 'sibling' when ( relationship_description 'spouse%' or relationship_description 'husband%' or relationship_description 'wife%' or ) 'spouse' else '' end; but there additional requirement: if there multiple key words relationship_description, convert using first key word. for example: case 1: relationship_description = "mark's brother" : contains "brother" in treated sibling. case2: relationship_description = "walter brother of mark , greg howard. mark husband of j...

jquery - DataTables not initializing, using RequireJS/Backbone -

i've worked require , datatables before first time setting things up. i've stripped away of sensitive files being called in code below think need out. i have seen mixed messages on whether min js path needs added or if need both. because there aren't errors present seems bring called. in addition, i've heard mixed messages needing shim datatables. seem right? have standard table in handlebars file populated json file. let me know if need shown well. first section of code require.config file, last chunk view handlebars file. requirejs.config({ // baseurl: "js", paths: { backbone: "bower_components/backbone/backbone", jquery: "bower_components/jquery/dist/jquery", jquerybridget: "bower_components/jquery-bridget/jquery.bridget", jqueryui: "bower_components/jquery-ui/jquery-ui", modernizr: "bower_components/modernizr/modernizr", datatables: "bower_components/datatables...

how to declare variable in mysql trigger -

this trigger create trigger proximo_pago after insert on pago each row begin declare max_orden integer; declare num_lote =new.lote; begin set max_orden = (select max(orden) pago lote=num_lote); select max_orden : new.orden dual; end end and error error sql query: create trigger proximo_pago after insert on pago each row begin declare max_orden integer; mysql said: documentation #1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 4 declare tempkode varchar(10); declare temp varchar(5); or if want assign can use declare temp int default 6; to assign variable myvariable := tempkode; set myvariable := tempkode; maybe mean : create trigger proximo_pago after insert on pago each row begin declare max_orden int; declare num_lote int; begin set num_lote := new.lote; select max(ordern) max_ordern pago lote ...

c# - NullReferenceException: Object reference not set to an instance of an object in code first entity framework class -

this question has answer here: what nullreferenceexception, , how fix it? 29 answers public decimal total { { return quantity * pricelist.price; } set { total = value; } } you need change logic: public decimal total { { return quantity * (pricelist == null ? 0 : pricelist.price);} set { total = value; } } total 0 if pricelist null. may want change logic, example, if pricelist null total should null too? changr total type decimal? , return null in case. edit: assuming here price property "pricelist" non nullable. if nullable, take note of comments made below.

ios - ScrollView with Tab bar -

Image
i have implement similar chat. so thought add scrollview table view view textfield , send button on top of tableview. i have tabbar on bottom is right approach. wanted bring keyboard , move text box upwards the images not containing scroll view because when ever put scroll view screws me up additionally want know how increase size of rows depending on chat message. crude drawing this have achieved far i not able increase size of label according data, nor able bring textfield when keyboard showing. :( uitableview inherits from, , contains uiscrollview don't need add scroll view yourself, , cause problems, assume case have described. to have cells adjust automatically, check out tutorial https://www.captechconsulting.com/blogs/ios-8-tutorial-series-auto-sizing-table-cells . provides lots of details on how , why works. for message bar on bottom, way i've done in past, add view text field , send button view (i'll call message view) main view...

javascript - HighCharts JS - Getting multiple linear underlays on a scatter plot -

Image
i'm trying make visualisations using highcharts javascript library, i'm hoping make similar these guys have on page: research affiliates - 10yr expected risk & return mainly, i'm trying work out how managed 2 solid linear areas on scatter graph represent different sharpe ratio levels. background image, or have somehow underlayed area chart under scatter chart? has got experience this, or how code it? basically, can combine kind of chart type. see demo of scatter plot regression line . as example of scatter plot combined stacked area chart, see following code , fiddle: var y_max = 6; var x_max = 5; $(function () { $('#container').highcharts({ title: { text: 'scatter plot stacked area ratio chart' }, plotoptions: { area: { stacking: 'normal' } }, xaxis: { min: 0, max: x_max }, yaxis: {...

unit testing - how can I test a method for greater code coverge in Java? -

i seek method written in java tests method greater code coverage possible. meaning, want know how can count number of instructions executed method in java. how do it? please provide practical inputs. if question how work out how of code covered tests, google java code coverage tools. there many out there, both commercial , opensource. i've used clover , emma in past.

c# - Comparing strings of text files -

i have 3 text files: file1 file2 , file3 of contain emails. file1 supposed have emails in there, file2 has emails a-m, , file 3 have emails n-z (this not important figure give little context.) i writing console application program in c# @ these 3 files, , if there email not 1 should be, write masterfile needs added what. for example, lets have email john@example.com . if found in file1 not in file2, output of masterfile needs "this email needs added file2: john@example.com" . if reversed, , email found in file2 not in file1, output should "this email needs added file1: john@example.com" as part of code, answer looking needs in sort of foreach loop , if statements, little lost in need put in. if please me in figuring out have use in statements appreciate it. if has question of please feel free ask! //making list file1 list<string> listfullpack = new list<string>(); string line; streamreader sr = new streamreader("file1"); while ((lin...

excel - Specifying a range within a workbook without specifying the sheet -

if want refer range within active workbook in excel vba, can "with range("myrange")". don't need sheet name. sometimes want refer range in workbook. "with myworkbook.range("myrange")" doesn't work because have specify sheet range in. is there way of referring range in workbook without having sheet range in? if create named range , scope workbook can use following named range in workbook. error if name can't found. wb.names("myrange").referstorange

Android: start animation from state it ends -

so got rotation animation: rotate = new rotateanimation(0f, -270f,200,200); rotate.setduration(2000); rotate.setfillafter(true); and have button start animation on click public void click(view view){ image.startanimation(rotate); } and when click on button animation starts correctly , ends on needed state. when click second time begin state before animation. question: how can start animation state ends? object animator instead objectanimator imageviewobjectanimator = objectanimator.offloat(imageview , "rotation", 0f, -270f); imageviewobjectanimator.setduration(2000); imageviewobjectanimator.start();

java - Support write operation in FUSE filesystem using FUSE-J -

i working on developing file system filter driver type of functionality in linux. trying explore , use http://sourceforge.net/projects/fuse-j/?source=typ_redirect purpose. however,fuse-j not support write,it provides read filesystem.has tried implement write call ? is there other java implementation fuse filesystem built on top of fuse module? you can implement fuse in java jnr-fuse . project uses jnr, achieve full jni performance , ease of implementation. example of hello-world filesystem .

syntax - Scheme several actions if an if-statement proves true -

the way understand scheme if-statement first condition when if-statement true, , second statement when false. if want several conditions when statement proves true? an example: (if (= b) (set! ([a 2])) // shall happen when true (set! ([b 4])) // shall happen when true (set! ([a b])) // shall happen when not true is possible that? you can try use begin in if statement. so: (if (something) (begin (foo) (bar)))

android - Bad notification posted when using custom view in a layout -

when use custom view in notification's layout, crash remoteserviceexception: bad notification posted package ... . here layout: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" > <com.myapp.views.fontedtextview android:id="@+id/idas" android:layout_width="match_parent" android:layout_height="match_parent" android:text="test" /> </linearlayout> if use textview instead of com.myapp.views.fontedtextview , works fine. note, in normal activity, com.myapp.views.fontedtextview works perfectly. public class fontedtextview extends textview { public fontedtextview(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); i...

regex - Unable to create sed substitution to deduplicate file -

i have file many duplicates of form a b b c c which need reduce to a b c so wrote sed command: sed -r 's/^(.*)$\n^(.*)$/\1/mg' filename , file still showing duplicates. i'm sure regex works because tested here . so doing wrong? i suspect may related -r option, i'm not sure (but without invalid reference \1 on s' command's rhs` error). either of 2 simpler approaches should work you. a simple awk command print line first time maintaining array of printed lines: awk '!seen[$0]++' file b c since file sorted can use uniq also: uniq file b c edit: newer gnu-awk versions support in place editing using: awk -i 'inplace' '!seen[$0]++' file

java - Save tables in Docker container -

i need advice best practice, maybe. need start web application web server , database. how link web server database found out. have problem db. if wanna save tables after server down (server containers start). know information of container reset after delete. know verbose folders( -v flag) don't know mysql save it's tables , other information , don't know idea. so, tell me how correctly save created tables in container? you can take @ tutorial: https://github.com/tutumcloud/tutum-docker-mysql basically, have mysql on machine , then, on /var/lib/mysql , can start container: docker run -d -p 3306:3306 -v /var/lib/mysql:/var/lib/mysql tutum/mysql in case, i'm using tutum/mysql image. mounting database file volume host container. when container goes down, still have data on machine.

Spring Security SAML extension ADFS -

i've been working whit saml extension connect adfs server. i've hacked sample application use adfs server , went well, know if there way connect idp without using loging page of idp. mean if there way process in background end-user. thinking doing query adfs or users , authentication sp login page, avoiding need user authenticate in idp login page. thank much. appreciate on that the purpose of federated authentication delegate centralized server in such way relaying parties/service providers not have access user's credentials. enabling authentication directly in application violate principle , reason not supported neither spring saml nor adfs. if want authenticate users directly, use authentication directly against active directory instead of adfs. support use-case.

mysql - Auto increment null fields, leave non null fields as is -

i have table items has field priority . half of elements in field priority have unique value ranging 1 x . want elements field priority null have incremental values of x+1 y . i have tried update items set priority = ifnull(priority, 0) but not want. want non null fields stay is, achieved following: set priority = ifnull(priority, 0) and null fields start being incremented value, following: select max(priority) items; so thing comes mind close to update items set priority = ifnull(priority, 0) + (select max(priority) items) priority null however not sure how go doing so. hints or tips? you can current maximum priority , store in variable. then, bring value query, using cross join . can increment value in set statement: update items cross join (select @x := max(priority) items) maxp set priority = (@x := @x + 1) priority null;

ruby - Query by two column version number in rails -

i have 2 columns called major , minor trying greater , less queries on. represent versions. version 2.1, 2 in major column , 1 minor column. how can these queries? avoid creating new column. the issue if query model.where('major > ? , minor > ?', 3, 4) , won't 4.1 or 5.2 because minor less 4. i using rails 3.2 , ruby 1.9. also, versions don't complicated number.number (ex. 2.9 or 4.3) lets assume in style. i think correct sql query follows: major > :major -- check bigger major or (major = :major , minor > :minor) -- check within same major you can use in activerecord right placeholder conditions, though should remove comments (the parts of line after -- ). example: myproductwithversion.where('major > :major or (major = :major , minor > :minor)', major: 2, minor: 1)

android - Google App Engine: Could not resolve dependencies for configuration: appengineSDK -

error: could not resolve dependencies configuration ':backendcontactdatabase:appenginesdk'. not download artifact 'appengine-java-sdk.zip (com.google.appengine:appengine-java-sdk:1.9.18)' not ' https://jcenter.bintray.com/com/google/appengine/appengine-java-sdk/1.9.18/appengine-java-sdk-1.9.18.zip '. jcenter.bintray.com i have externally downloaded 'appengine-java-sdk-1.9.18.zip' file. me out step-wise changes made (ex: folder paste zip file to, changes made in gradle file etc..) app , running. perhaps download timedout when getting jcenter (it's not small download). if want manually configure appengine sdk -> how manually install app engine in android studio?

php - CakePHP ignore blank fields when trying to update the model -

i have registration form fields not required. user fills fields , saves. data saved normally. however, if update data , leave fields blank, update database record empty values cakephp 1.3 not update in database. put check empty string , delete empty keys array before saving database

swift - NSButton RadioGroup (NSMatrix Alternative) -

i've tried few times set several similar buttons, connected same ibactions, , still can't seem replicate radiobutton behaviour. at moment, have 5 buttons, children of 1 nsview.. nsview - buttonone - nsbutton (square button) - buttontwo - nsbutton (square button) - buttonthree - nsbutton (square button) - buttonfour - nsbutton (square button) - buttonfive - nsbutton (square button) they're connected common ibaction, reads as: @ibaction func activitybuttonpressed(sender: nsbutton) { println("\(sender.title) pressed") } which works point actual mosuedown events caught , sent func (as expected).. how them working in radio button mode? i.e. have nsonstate , nsoffstate toggle when various buttons clicked? when try , change button type radio button, automatically flips "switch".... cheers, a since don't want use nsmatrix... first issue if using square button style , can't use radio type . want use...

jquery - Can I loop through an array to change and elements attributes on hover -

this seems little verbose, there better way of doing this? i'm using jquery change navigations aria attributes hidden=true hidden=false on hover (same expanded). i'm sure can done in far fewer lines of code i'm not quite sure how. can sense thousand eyes rolling, sorry guys i'm noob. var navarray = ['#navitem1', '#navitem2', '#navitem3', '#navitem4', '#navitem5' ] $(navarray[0]).hover(function(){ $( navarray[0] + 'dd').attr('aria-expanded','true'); $( navarray[0] + 'dd').attr('aria-hidden','false'); }, function(){ $(navarray[0] + 'dd').attr('aria-expanded', 'false'); $(navarray[0]+ 'dd').attr('aria-hidden', 'true'); }); $(navarray[1]).hover(function(){ $( navarray[1] + 'dd').attr('aria-expanded','true'); $( navarray[1] + 'dd').attr('aria-hidden','false');...

html5 canvas drawImage from one canvas to another -

Image
i have 2 canvas first canvas original size second canvas twice bigger. @ same time drawing on both canvas, on second canvas draw twice bigger elements it's looks on zoomed first canvas. how like: problem when try redraw big canvas small canvas got paintings little brighter, brighter use pencil: smallctx.clearrect(0, 0, smallcanvas.width, smallcanvas.height); smallctx.drawimage(bigcanvas, 0, 0, paperfullwidth, paperfullheight); full code: $(document).ready(function() { function pencil(smallctx, bigctx, size, color, opacity, moretimes) { this.init(smallctx, bigctx, size, color, opacity, moretimes); } pencil.prototype = { smallctx: null, moretimes: null, prevmousex: null, prevmousey: null, moretimes: 1, color: '0, 0, 0', opacity: 1, init: function(smallctx, bigctx, size, color, opacity, moretimes) { this.smallctx = smallctx; this.bigctx = bigctx; ...

html - How can I put something on the top right corner to make that gap blend in with the header? -

with help, community of stack overflow, created html "sandwich", scrollable table , static header, thing still need "fix" white gap on top right corner ( right above scrolling bar ). make blend in header make 1 thing, without messing table. may me? thanks in advance. $(function(){ $( "#btfirst" ).button({ icons: { primary: "ui-icon-seek-first" }, text: false }); $("#btfirst").css({'height': '1.2em','margin':'1px'}); $( "#btprev" ).button({ icons: { primary: "ui-icon-seek-prev" }, text: false }); $("#btprev").css({'height': '1.2em','margin':'1px'}); $( "#btnext" ).button({ icons: { primary: "ui-icon-seek-next" }, text: false }); $("#btnext").css({'height...