Posts

Showing posts from March, 2012

publish subscribe - Meteor Group Collection by Field -

i trying return collection (postings) grouped field (status). pretty new mongo , meteor. query below gives me collections grouped status # of docs status... want same thing have actual documents in there. also, able publish/subscribe reactivly update. creating admin dashboard groups postings current status. a friend provided following gist, bit on head: https://gist.github.com/ryw/8827179 db.postings.group({ key: {status: 1}, initial: {sum:0}, reduce: function(doc, prev) { prev.sum += 1; } }) thanks! if need of documents on client, publish whole collection , let template code group them. client tracker.autorun(function() { if (meteor.user()) { meteor.subscribe('allpostings'); } }); template.admin.helpers({ postings: function() { if (session.get('currentstatus')) { return postings.find({status: session.get('currentstatus')}); } }, statuses: function() { return _.uniq(_.pluck(postings.find().fetch(), '

jsf - How to save only one item of select many check box? -

when offer create oferta object (offer) saves of items in select many check box (this location per company selected(empresa)), not checked ones: thank can provide. <h:outputlabel value="#{bundle.createofertalabel_empresaidempresa}" for="empresaidempresa" /> <h:selectonemenu id="empresaidempresa" value="#{ofertacontroller.selected.empresaidempresa}" title="#{bundle.createofertatitle_empresaidempresa}" required="true" requiredmessage="#{bundle.createofertarequiredmessage_empresaidempresa}"> <f:ajax event="valuechange" execute="empresaidempresa" render="ubicacioncollection" /> <f:selectitems value="#{empresacontro

mysql - whats wrong. when i call foreign key -

create table applicant ( applicant_id varchar(10) not null, applicant_name nvarchar (25) not null, father_name nvarchar (25), gender nvarchar (15), applicant_dob datetime, qualifaction nvarchar (45), application_id varchar (15), primary key (applicant_id, applicant_name) ); create table application ( application_id varchar (10), application_name nvarchar(25), applicant_id varchar (10), applicant_name nvarchar (25), primary key (application_id) ); create table cell_number ( cell_no varchar (15) not null , applicant_id varchar (10), applicant_name nvarchar (25), primary key (cell_no) ); alter table cell_number add constraint fk_applicant_id foreign key (applicant_id) references applicant (applicant_id); alter table cell_number add constraint fk_applicant_name foreign key (applicant_name) references applicant (applicant_name); show error msg 1776, level 16, state 0, line 34 there no primary or candidate keys in referenced table 'applicant' match referencing co

linux - pipe array of json objects as a map of single post, using curl -

i have 2 nodes having same rest+json api ( not jsonapi.org btw ) one of them has many products in /products other has [] in /products i want pipe products of 1 node ( say: http://localhost:9080/products ) other 1 ( http://localhost:8080/products ) operation must happen on command line this should solved problem ? i think so, not know yet , have not find solution yet... what experimented work , found ugly for f in $( curl http://localhost:9080/products | jq -c '.[]' | sed -e 's/ /\\_/g' ); echo $f | sed -e 's/\\_//g' | curl -i -h content-type:application/json http://localhost:8080/products --data @-; done the above uses jq json parser curl http://localhost:9080/products | jq -c '.[]' emits each products of collection the ugly sed hack meant tackle label fields "label":"what favorite color?" it job on small set of products, , still i'm not happy it what did miss ? what expect of response shou

asp.net - .NET Exception Page Not Human Readable -

this question has answer here: asp.net mvc: weird characters in error page 1 answer i'm running local dev server on windows 7 iis 7.5, .net 4. exceptions on 1 of sites don't come out normal yellow background red font screen, bunch of symbols aren't legible. i've never had happen on other computer, it's difficult describe. �x�o�8����q��5m�x�utc�&����銐����;�n����~�nڦ[v�t��isc����l�����������q���v���#�g76�d�9��̀ ,��3s�4fa<����&4'���la��b�i%l��y'�n)���)��et��smcdz�r�(u.a���3��[a��k���w��1h7shre���3&���l�&�����f���o����Ľ���� a�dl�h��y��q��/��9(!*�����(��lh��0��[^tk#n�{���9e��t�qmp��wb1��ml�"����vp��9;�4�ʴ׮e�r( �f x��� �i"��8�Ʉ�ʔ�f���xu� Ԋ����� �9\ �:d1��~���������hl|!u̢lj����ƭ@fr���4���ʺyb�j���}usj���Ԃk���,�dnϩ�4tk-�/b9(d�8a3f���|x���̞�ea ���mk0h�wɩ,5��17xu���@u�xb�d��"��]t�ĺ=������m?w�݀ޮ �]˷�|��b0r!

Javascript Convert Unicode Embedded strings -

i'm getting passed string api method have no control on returns strings paths like: /toplevel/nextlevel/_x0034_33name/myoutput.log it seems happens directory names start number. in case directory name should '433name'. i'm guessing x0034 represents hex character '4', possibly in unicode. the following javascript returns '4', correct: string.fromcharcode(parseint("0034",16)) is there regex command or conversion utility in javascript readily available remove , replace these characters in string correct equivalents? function unescapeapi(string) { return string.replace(/_x([\da-f]{4})_/gi, function(match, p1) { return string.fromcharcode(parseint(p1, 16)); }); } # example, logs '/433name/myoutput.log' console.log(unescapeapi('/_x0034_33name/myoutput.log'));

html - "Fullscreen" height <textarea> in CSS -

i'm not best @ using css solve these problems, , wondering if give me hand. right now, i'm trying build pastebin project entirely in php. php part working great can't this. anyway, point. i have textarea tag want fill whole of screen except drop down box , submit button, regardless of resolution / zoom. here source code i'm using. index.php: http://pastebin.com/dzjkfg0t style.css: http://pastebin.com/mdhyg7xi massive can help! here css problem: * { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; padding: 0; margin: 0; } body { background-color: #0099cc; color: #ffffff; font-size: 180%; margin: 10px; } .centre { text-align: center; } textarea { /* position inherited */ left: 0; top: 0; right: 0; bottom: 100px; /* height of select , input */ width: 100%; } also, jsfiddle wth full code: http://jsfiddle.net/a3um2/

How to make this query better in SQL for this repeated query in 'from clause' -

is there way make query better removing repeated pattern of select in clause? best efficient way write query? using sqlite. select abs(avg(ravg1) - avg(ravg2)) (select avg(stars) ravg1 movie m join rating r on m.mid = r.mid group r.mid having year < 1980 ), (select avg(stars) ravg2 movie m join rating r on m.mid = r.mid group r.mid having year > 1980 ) if want difference in ratings years before , after 1980, can use conditional aggregation: select abs(avg(case when year < 1980 stars end) - avg(case when year > 1980 stars end) ) movie m join rating r on m.mid = r.mid;

mysql - Update a column based on its value -

to update table use this: update `table` set column = value column = value is there way update column value? example: table 'test' has 2 columns called 'one' , 'two'. i'll set them: 'one' 10, , 'two' 20, , wish update columm have value 10, variable, , can't know wich column is. thanks you'd have query table first: select * mytable col1 = 10 or col2 = 10 then, you'll need server-side code (like php, ruby, python, etc) determine column has needed value, , can build new update query based on that: update mytable set col1 = 20 however, can't think of scenario efficient way of managing data. may want reconsider how database designed.

html - Resizing of an image isn't behaving 'normal' -

i resize arrow (right, gray) resize , behave logo (middle). when adjust browser window left or right, gray arrow resizing fine. when make browser window higher or taller (up/down adjustment), arrow can placed along right side of screen. it nice if arrow have current place fixed , behave / resize (sober) logo in middle of page. the problem located in class: .arrowup. you can find whole website here --> https://dl.dropboxusercontent.com/u/61634717/website.zip #homepagelogo { height: auto; /*120*/ width: auto; /*450*/ text-align:center; padding-top:19%; padding-right:35%; padding-bottom:15%; padding-left:35%; } body { /*background:#000000; -- test achtergrond -- */ /*background-image:url('../pictures/homepage/background_homepage1.jpg');*/ background: #2e2e2e url('../pictures/homepage/background_homepage1.jpg') no-repeat top left; background-size:cover; background-repeat:no-repeat; width:auto; height:0px; } img { max-width:100%; height:auto; } .arrowup {

Compile java file with two jars from command line? -

suppose have 2 jar files (with classes inside) , java file: name1.jar name2.jar code.java as said @ how use classes .jar files? , if wanted import name1.jar, add classpath, , run javac -cp '.:name1.jar' code.java every time wanted import name1.jar. however, how compile java code , import both jar files, not name1.jar? try this javac -cp name1.jar:name2.jar code.java note if in windows path separator should ;

c# - How do I get a distinct list of list types -

this code (copy , paste linqpad if like) var messageusers = new [] { new { msgid = 2, userid = 7 }, new { msgid = 2, userid = 8 }, new { msgid = 3, userid = 7 }, new { msgid = 3, userid = 8 }, new { msgid = 1, userid = 7 }, new { msgid = 1, userid = 8 }, new { msgid = 1, userid = 9 }}; messageusers .groupby (x => x.msgid, x => x.userid) .select (x => x.select (y => y)) .distinct() .dump(); the results {7,8}, {7,8}, {7,8,9} what want {7,8}, {7,8,9}. basically want remove duplicate lists. haven't tried think achieve creating comparer , passing distinct method. use in linq entities query without bringing thousands of rows client isn't option. for clarification...i need return list> contents of each inner list distinct in comparison of other inner list. the problem .distinct() determines what's distinct based on gethashcode() , equals() implementation of underlying objects. in case, underly

php - Retrieve record ID after insert -

admittedly, bit out of league here, attempting project anyway. background: i developing page allow users enter data database. database has multiple tables have data inserted , updated. first action user takes select option drop down , click "create". clicking create button create record in 1 of tables. also, upon clicking "create" larger form displayed. once larger form complete, user can "save" work. planning on using update query allow user save work. question: using ajax post data (see example below), want return record id (primary key) page when visitor saves additional information, database knows record update. //script $(function(){ $('#create').click(function(event) { event.preventdefault(); $.ajax({ type: "post", url: "url", data: {"optimizationtype": $("#optimizationtype").val()}, success: function(results){ $("#mvt-experiment

c++ - Return char * instead of string -

i trying use 'user434507''s unsigned solution here: c++ performance challenge: integer std::string conversion but instead want return char * , not accept in string. i have been playing around awhile , have got, returns nothing/garbage - limited c , pointer knowledge not helping me. think using malloc right, in original code it's if uses internal char* , changed elements of string , returns string. figured if allocated via malloc have same effect : char * itostr(unsigned val) { const char digit_pairs[201] = { "00010203040506070809" "10111213141516171819" "20212223242526272829" "30313233343536373839" "40414243444546474849" "50515253545556575859" "60616263646566676869" "70717273747576777879" "80818283848586878889" "90919293949596979899" }; int size; if(val>=10000) { if(val&g

javascript - Set the default value of a dropdown which is populated dynamically using Java script -

i see lot of dropdowns defined @ multiple locations in jsp. this: (with different ids). <select class="school-names" name="schoolname" id="aaschoolname" > </select> these dropdowns populated below: <c:foreach items="${schools}" var="sc"> var scname = "${sc.schoolname}"; jquery('.school-names').append('<option value="' + scname + '">' + scname + '</option>'); </c:foreach> this dropdown populated on load of jsp page. how set default value of each dropdown onload of jsp page.

Terminate current Rails instance from initializer -

i'm writing sanity-checking initializer should kill rails process in event properties not met. safest way abort production server's startup process in way? suppose extreme case running exit , i'm not sure if it's best approach. running on unicorn if matters. there 3 ways end ruby process: exit end process status 0 (success). exit! end status 1 (which seems appropriate case), , not run blocks defined using kernel#at_exit (which may or may not desirable you). abort end status 1, , will run kernel#at_exit blocks. can give string sent standard out. so abort best bet. unless have particular reason not run kernel#at_exit blocks want run them. since unicorn runs initializers once , forks processes after that, approach should fine. i'll add i'm guessing doing these checks @ "wrong" level -- if possible should check health of environment outside of context of rails. don't know situation, , realize quickness of solution mor

networking - Checking small network in mininet by Opendaylight -

Image
i have question checking small network opendaylight i not sure why can't accress opendaylight menu created mininet i using windows 7 , vmware player run mininet , opendaylight(on ubuntu). first, run ubuntu run opendaylight ( checked 120.0.0.1:8080 working) second, run mininet ip address.( "192.168.139.128") third, based on ip address , run 2 putty run wireshark , building small network i used sudo mn --mac --controller=remote, ip=192.168.139.128, port=6633 . it build small network. because can check node infor command "nodes" , "dump" however, when go ubuntu vm , access opendaylight 192.168.139.128:8080 (it given ip mininet) i sure sure why happen. there possible reasons ? just in case, if facing same issue, change network adapter settings in vmware use bridge mode. from official page important troubleshooting - if running virtualbox on same host/desktop controller running, , trying start virtual network on mi

c - How to center a dialog window on the main window in GTK? -

i want print small warning messages. achieve that, i'm creating new window , want centered on main window. far i've tried setting parent gtk_widget_set_parent , using gtk_window_popup , gtk_window_toplevel nothing worked. how center window on main window? here's code function: static void pop_warning(char *title, char *text) { gtkwidget *warning_window; gtkwidget *box; gtkwidget *label; gtkwidget *button; warning_window = gtk_window_new(gtk_window_toplevel); gtk_window_set_title(gtk_window(warning_window), title); g_signal_connect(gtk_window(warning_window), "destroy", g_callback(gtk_widget_destroy), null); gtk_container_set_border_width(gtk_container(warning_window), 20); gtk_window_set_resizable(gtk_window(warning_window), false); //window main window gtk_widget_set_parent(warning_window, window); gtk_window_set_position(gtk_window(warning_window), gtk_win_pos_center_on_parent); box = gtk_box

c# - System.InvalidCastException in Unit Test with Oracle objects using DbProviderFactory -

when using system.data.common.dbproviderfactory error when run our code in nunit test not when run regular web application. error system.invalidcastexception : [a]oracle.dataaccess.client.oracleparameter cannot cast [b]oracle.dataaccess.client.oracleparameter. type originates 'oracle.dataaccess, version=2.112.1.2, culture=neutral, publickeytoken=89b483f429c47342' in context 'default' @ location 'c:\windows\assembly\gac_32\oracle.dataaccess\2.112.1.2__89b483f429c47342\oracle.dataaccess.dll'. type b originates 'oracle.dataaccess, version=4.112.1.2, culture=neutral, publickeytoken=89b483f429c47342' in context 'default' @ location 'c:\windows\microsoft.net\assembly\gac_32\oracle.dataaccess\v4.0_4.112.1.2__89b483f429c47342\oracle.dataaccess.dll'. we have 2.112.1.2 assembly referenced unit test project , tried 'use specific version' , 'copy local' doesn't see dll continues load newer version i

postgresql - Backend sent unrecognized response type: u Error with Postgres 9.3 and npgsql -

i upgraded server yesterday postgres 9.1 9.3 , since i've been getting error: backend sent unrecognized response type: u i'm using npgsql connect application server. i remember used error while , haven't seen in while. a full line log is: backend sent unrecognized response type: u insert stockcodes_rating (item_code,rating,price_range,user_id,timestamp_of_rating) values ('10245684','5','reasonable','10832',now()) my code procedure is: public function insertrating(byval stockcode string, byval rating integer, byval pricerange string, byval userid string) string dim objdbwrite dlnpgsql objdbwrite = new dlnpgsql("postgreconnectionstringwrite", configurationmanager.appsettings("currentdatabase")) tmpsql = "insert stockcodes_rating (item_code,rating,price_range,user_id,timestamp_of_rating) values " & _ "('" & stockcode.toupper & "','"

math - How to transform any 64-bit integer to a uniformly distributed random number in certain interval -

can transform integers between [long.min_value, long.max_value] [0,1] uniformly , randomly? main purpose can pick fraction, e.g. 0.1 , select uniformly , randomly distributed 10% of longs. if transformation method f(x) , can check f(x)< 0.1 on long see if belongs 10% selected numbers. important requirements: it can controlled seeds, can same results every time (when want), , change seed different result. when increase fraction x y, want selected numbers in x selected in y. example, if 894230 selected when pick 10% of numbers, should selected when pick 20% numbers. i can select seeds won't result in obvious patterns such double f(x) { return (x%1000)/1000.0; } . nice have (but not necessary): i can use dummy seed result in obvious pattern (so looks obvious in unit test). i use java, don't mind answers in language can rewritten in java if job identify whether x belongs set of of chosen integers, believe following achieve of first 3 requirements: (lo

javascript - Breezejs: Return a single entity from a parameterized query -

does breeze have .singleordefault()? i'm getting feet wet breezejs -- cool! have case using parameterized query (so i'm using .withparameters() in breeze query). my query return single entity. in fact, it's defined on webapi controller: public myentity getthisspecialentity(int theparameter) {} (note doesn't return iqueryable or ienumerable, entity. the query executes, data comes breeze appears array of 1, entity in it. now take data[0] , assign it, wondering if that's i'm supposed do, or if breeze has linq's .singleordefault() method? you can return single entity. need return single result when manager executes query below: for example, if have executegetquery function in datacontext service, pass in query object: var executegetquery = function (query, observable) { return manager.executequery(query).then(function (data) { if (observable) { observable(data.results[0]); // here } hope helps.

hierarchy - SQL bubbling or hierarchical pattern for searching higher and higher levels -

we have company, branch, , user tables/levels. each level has nullable id associated configuration in configuration table. if configuration id null, should return configuration @ higher level, , there non nullable id associated higher level. if there no configuration associated @ highest level, should return nothing. 1 additional complication configuration should have isdeleted value of 0. what's sql pattern such hierachy? did search on web, since i'm not sure call it, didn't yield useful results. i tried sql fiddle here: http://sqlfiddle.com/#!3/f1815/10/0 , don't pattern i'm using. schema bunch of tables each 1 element, , company 1 points config. schema: -- ids uniqueidentifiers -- pks , fks primary , foreign keys be. create table all_user ( id int not null, -- pk branchid int not null, -- fk configid int -- fk ); create table branch ( id int not null, -- pk companyid int not null, -- fk configid int -- fk ); create table company ( id

linux - backtrack 5 wont boot -

Image
first off, sorry english, not good. i have toshiba satellite c885d running windows 8.1. have lexar 4 gigabyte usb flashdrive. says on back: ljds50-4gb. used linuxlive usb creator , backtrack 5 r3 gnome 32 bit. downloaded iso backtrack-linux.org. when put usb computer, hold f12, , power on, takes me boot menu, gives me 4 options boot from. after each one, there little bit of text. except after "usb" blank. , @ bottom 2 more options, 1 taking menu can access pressing f2 durring startup. if hit enter when usb selected, takes me black screen says 2 words (something checking usb, forgot. put in edit contain picture , exact text.) after 2 seconds, says failed, , launches windows. please please please me out. tried researching solution problem, none of worked. have run backtrack vm thingy linuxlive has of usb stuff, , works fine, slow, have many windows processes running @ same time. if can diagnose me problem, awesome. if can give me solution, stupendous. e

How do I prevent flyway from creating the schema during init -

i'm trying start using flyway v2.3 on existing oracle 11g schema not contain schema_history table in flyway.properties i've set flyway.user schema owner , i've set flyway.schemas property same value when running init command line expected flyway create schema_history table fails message: $ ./flyway.cmd init flyway (command-line tool) v.2.3 creating schema "myschema" ... error: unable create schema "myschema" error: caused by: java.sql.sqlsyntaxerrorexception: ora-01031: insufficient privileges why flyway attempting create schema? want create schema_history table in schema configured the command correct. please note flyway.schemas case-sensitive , automatically filled default schema of user if left empty. i suspect value put in flyway.schemas in wrong case. leave empty , should ok.

c++ - What's wrong with this screen capture code? -

i found screen capture code on here, when tried build it wouldn't build, fixed code myself , builds don't think works because when debugging vs says can't read hbitmap (no data?). i'm novice programmer have no idea @ point... , didn't fix code properly... i appreciate help. #include <windows.h> int main() { // device context of screen hdc hscreendc = createdc(l"display", null, null, null); // , device context put in hdc hmemorydc = createcompatibledc(hscreendc); int x = getdevicecaps(hscreendc, horzres); int y = getdevicecaps(hscreendc, vertres); // maybe worth checking these positive values hbitmap hbitmap = createcompatiblebitmap(hscreendc, x, y); // new bitmap hbitmap holdbitmap = (hbitmap)selectobject(hmemorydc, hbitmap); bitblt(hmemorydc, 0, 0, 640, 480, hscreendc, 0, 0, srccopy); hbitmap = (hbitmap)selectobject(hmemorydc, holdbitmap); // image held in hbitmap. can save or wha

android - Lazy loading ViewPagers in a ScrollView -

im trying inflate multiple viewpagers scrollview each viewpager using fragmentstatepageradapter. the viewpager consist of fragments 3 imageviews each page. im using universalimageloader async loading of images cant lazy load work. the problem when app inflating lets 10 viewpagers 3 imageviews each trippleposterfragment1 , , 10 viewpagers 3 imageviews trippleposterfragment2 since mpager.setoffscreenpagelimit(1) kicks in. its total of 60 async requests firing during progresslayout visible. my mainfragment following method: private void rendersubcarousels(arraylist<carousel> carousels) { layoutinflater minflater = (layoutinflater)getactivity().getsystemservice(context.layout_inflater_service); int = 1; linearlayout subcarousellayout = (linearlayout) mscrollview.findviewbyid(r.id.index_subcategory_carousel_container); (final carousel carousel : carousels) { relativelayout carouselwrapper = (relativelayout) minflater.inflate(r.

jquery - if condition with css: setting a border and removing when clicked consequently -

i have , dislike objects. 1 clicked wanna display border around it, works perfectly. if clicked again, want border disappear. used if condition .css not worked. .css("border-width") returns empty when print alert function. problem? works other this. $('a[id*="grd_wallposts_lbtn_likedislike_like"]').click(function () { if ($(this).children('#imglikedislike_like').css("border-width") == "1px") { $(this).children('#imglikedislike_like').css("border-width", "0px"); } else { $(this).children('#imglikedislike_like').css("border-width", "1px"); $(this).children('#imglikedislike_like').css("border-style", "solid"); $(this).children('#imglikedislike_like').css("border-color", "#b9b9b9"); var =

ios - UITableView from plist loaded into NSArray of Dictionaries -

i have been reading bunch of how to's on topic, haven't been able figure out. if have plist this: <?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <array> <dict> <key>color</key> <string>brown</string> <key>height</key> <real>40</real> <key>length</key> <real>75</real> <key>level</key> <real>2</real> <key>name</key> <string>bear</string> <key>note</key> <string>ugly, strong</string> <key>width</key> <real>30</real> </dict> <dict> <key>color</key> <st

objective c - AppDelegate logging as NSButton -

i'm trying access instance variables i've declared in appdelegate, class seams think appdelegate nsbutton. i borrowed code referencing appdelegate instance variables appdelegate *appdelegate = (appdelegate *)[[nsapplication sharedapplication] delegate]; nslog(@"appdelegate %@", appdelegate ); nslog returns: appdelegate nsbutton: 0x6000001553a0 because appdelegate seems nsbutton, doesn't take trying ask variables, gives me "unrecognized selector sent instance." i'm missing important, why doesn't appdelegate point appdelegate class? it sounds hooked “file’s owner”’s delegate outlet in mainmenu.xib button accidentally. instantiate appdelegate in xib , point ‘delegate’ outlet that, instead.

How to redirect a domain + port to a simple domain in Amazon EC2? -

i have vpn running on amazon, it's working simple domain, www.domain.com, i'm running custom aplication called openerp in 8069 port, need enter www.domain.com:8069 have acces app. love acceso tipyng www.domain.com so question is... can redirect domain port simple domain?? extra information: server ubuntu 13.10, openerp running on amazon instance. greetings! dns not know "ports", not in dns level. need machine listen port 80 , redirect (or reverse proxy). the simplest solution have openrp listen on port 80. why not doing that? another possible solution have another process on host listen port 80 , either redirect or reverse proxy. there simple apache , nginx configurations that. another trivial solution have /etc/services entry -- simple tcp pass-thru port 80 port 8069. finally, use external host (another host) that, obvious suggestion being ec2 load balancer. configure load balancer fwd traffic port 80 on host.

postgresql - Postgres window function output restriction -

i using postgres 9.1.11 , have created function cumulate variable (ln_ret) on partition, returning desired column (cumret_pf). parameters start_date , end_date determine how wide want relevant partition be. my issue want result returned if there enough rows in partition, e.g. if specify partition starts 2 rows preceding current variable, want first 2 rows in partition null. i have been able achieve code below rows preceding current row unable achieve desired result when consider rows following the current row. can calculate variable such 'inverse' row number, , perform equivalent restriction end_date have below? there better way restrict results? many thanks select allrows.rnum, allrows.permno, allrows.date, allrows.ln_ret, allrows.sum_ln_ret, cast(exp(allrows.sum_ln_ret) - 1 numeric(18,6)) cumret_pf (select cast(row_number() on (partition a.permno order a.date) bigint) rnum, a.permno, a.date, a.ln_ret, sum(a.ln_ret) on (partition a.permno order

android - How to play a button sound while playing a background music? -

i want know how play button's sound while background music playing? , also, want know how continuously play background music other activities. please me. this code of firstactivity.java public class firstactivity extends activity { mediaplayer bgsound,menuselect, settingsselect; bgsound.start();mediaplayer bgsound,menuselect, settingsselect; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.activity_first); bgsound = mediaplayer.create(firstactivity.this, r.raw.theme); bgsound.setlooping(true); bgsound.start(); final imageview btnplay = (imageview) findviewbyid(r.id.imgplay); final imageview btncredits = (imageview) findviewbyid(r.id.btncredits); final imageview btnscores = (imageview) findviewbyid(r.id.btnscores); final imageview btnsettings = (imageview) findviewbyid(r.id.btnsettings); btnplay.

Uploading images to a Google Spreadsheet using Apps Script -

i'm new scripting. have copied code here upload image google spreadsheet the original script allowed user upload 1 image via web app form , image append row in google spreadsheet , google doc. have been able modify web app form allow user upload 2 images, can't figure out how second image spreadsheet , doc. var submissionsskey = 'google spreadsheet key'; var docurl = 'google document url' var listitems = ['select category','portrait','landscape','other','night shots','nature','various'] var panelstyle = {'background':'#dddddd','padding':'40px','borderstyle':'solid','borderwidth':'10px','bordercolor':'#bbbbbb'} function doget() { var app = uiapp.createapplication().settitle('photography contest').setstyleattribute('padding','50px'); var panel = app.createformpanel().setstyleattributes(pane

c++ - how to lock for a variety of threads pthread_mutex_lock -

how create lock lock different threads entering function? thread 1: thread 2: c thread 3: c thread 4: b thread 5: c thread 6: b "a", "b" ,"c" argument passed in thread when created. so when lock 1 lock x, threads of have "a" , "b" passed in cannot continue , thread of type "c" can enter critical section. or have make 6 different locks example? thank you! your requirement's vague, assuming want concurrent readers same "allowed letter", you'd better off using rwlock. (if want "control" thread setting of a, b or c allowed work, rather having a, b , c take on whenever no other "letter" running through controlled code, different (simpler) solution needed....) as first cut (so can "evolve" solution in easier-to-understand way), each thread: 1) acquires reader lock 2) if "allowed letter" variable differs letter, release reader lock , try writer lock

java - setBorderPainted(boolean) not working -

jpanel droppan = new jpanel (); droppan.setlayout (new flowlayout ()); bi1 = new imageicon (""); b1 = new jbutton (bi1); //b1.setborderpainted (false); b1.setborder (borderfactory.createemptyborder (2,3,2,3)); b1.setcontentareafilled (false); b1.setsize (100,38); //b1.setbounds(3,3,100,38); droppan.add(b1); b1.addmouselistener (this); add(droppan); this row of buttons code above snippet of first button. initially, first button has border unless click on button , button has border, if "transfers" if mean. what doing wrong? setborderpainted comment because if it's not in comment border still there this panel inside frame i "think" talking focus border used show button has focus... try using b1.setfocuspainted(false); instead for example... import java.awt.borderlayout; import java.awt.eventqueue; import java.awt.flowlayout; import javax.swing.borderfactory; import javax.swing.imageicon; import javax.swing.jbutton; import j

objective c - Why does ORSSerialPort serialPort:didReceiveData NSData only have single byte? -

from arduino, i'm writing multi-byte data serial serial.print("blah"), in objective-c, -serialport:didreceivedata: (provided orsserialport) gets data 1 byte @ time. occasionally, it'll grab 2 bytes @ once, never 4. expected? if so, how can make receive 4 bytes @ once? arduino: void loop() { serial.print("blah"); delay(1000); } obj-c: - (void)serialport:(orsserialport *)serialport didreceivedata:(nsdata *)data { nsstring *string = [[nsstring alloc] initwithdata:data encoding:nsutf8stringencoding]; nslog(@"%@",string); } setting breakpoint inside method shows data holds 1 byte. this normal, expected behavior. underlying serial hardware , software has no way of knowing how many bytes you're waiting for, or complete packet looks like, delivers data comes in. you'll have buffer data in objective-c code. fundamentally, pretty simple. create nsmutabledata can use buffer: @property (strong) nsmutabledata *i

c# - MenuItem style when ItemsSource is used using setter Property with ResourceDictionaries or MergedDictionaries -

Image
i've got context menu, , styled correctly resourcedictionary loaded xamlreader.load(). style key i'm using dynamicresource i've called stylebanner. in context menu have 1 menu item called skins, styled correctly save above dynamic resource stylebanner. menu-item has it's sub-menu-items data-bound itemssource in data context view model, , working correctly. my trouble child menu items not styled correctly. here working, not getting styled @ all: <window.contextmenu> <contextmenu datacontext="timershostviewmodel" name="timershostcontextmenu" style="{dynamicresource stylebanner}"> <menuitem name="skins" header="skins" itemssource="{binding source={staticresource timershostviewmodel}, path=skins}" style="{dynamicresource stylebanner}"> <menuitem.itemcontainerstyle> <style targettype="menuitem">