Posts

mysql - SQL Query / find percentile based on rank -

i have created following tables ranks data set: position index indexl indexh amount rank 1 2.5 2 3 2000 1 1 2.5 2 3 3000 2 1 2.5 2 3 4000 3 1 2.5 2 3 5000 4 1 2.5 2 3 6000 5 2 1.5 1 2 2500 1 2 1.5 1 2 4500 2 2 1.5 1 2 6700 3 2 1.5 1 2 8900 4 2 1.5 1 2 9900 5 now want find percentile based on ranks created using indices such following output : position amount 1 3000+(4000-3000)*(2.5-2) 2 2500+(4500-2500)*(1.5-1) can me this. kinda new sql world. thanks, monica i think can want percentile_cont() aggregation function. looks want median: select position, percentile_cont(0.5) within group (order amount) median t group position; you can read more here .

c# - String to dictionary, and back again -

i working string this: norway, true; sweden, false; england, null; denmark, false; i'm trying dictionary<string, bool?> can work it, remove items, compare against other stuff. when i'm done, want convert dictionary similar string , save it. any ideas? you can convert dictionary using split method , linq: var dict = str.split(';') .select(s => s.split(',')) .todictionary( p => p[0].trim() , p => p[1].trim().equals("null") ? null : (bool?)(bool.parse(p[1].trim())) ); converting easier: var res = string.join("; ", dict.select( p => string.format( "{0}, {1}" , p.key , p.value.hasvalue ? p.value.tostring().tolowercase() : "null" ) ));

fft - Matlab: Remove noisy peaks -

i have transformed image of method fft2 want locate noisy peaks , erase them shown in following image link: image noisy peaks kindly suggest matlab functionality achieving this this did far f = fft2(myimage); f = fftshift(f); % center fft f = abs(f); % magnitude f = log(f+1); % use log, perceptual scaling, , +1 since log(0) undefined f = mat2gray(f); % use mat2gray scale image between 0 , 1 imshow(f,[]); % display result you can try create mask of shows/represents points exceed threshold , position. let's create arrays of position. [x y] = meshgrid(1:size(a, 2), 1:size(a, 1)); % x-y coordinate of data ft = 0.5; % try different values case. mask = f > ft && y < 0.4*size(a, 1) && y > 0.6*size(a, 1); f(mask) = 0; you should able check mask see if have located right positions. imagesc(mask) helpful during trial-and-error step. note don't have x rules in example potentially add...

parameters - Powershell - unable to print value of hash -

i writing simple script more familiar powershell. this script reads input parameters hash $states = @($args) $states write-host color $states.color on command-line, set following values $shape = 'circle'; $color = 'pink'; $size = 'large' i invoke program following command .\shapes_n_colors.ps1 $shape $size $color and, following output: circle large pink color i unable figure out why $states.color blank. expecting output "color pink" i following artical, http://technet.microsoft.com/en-us/library/hh847780.aspx where going wrong??? not sure start... first of - don't create hash @ point... @($args) doesn't anything: $args array, , @() useful make sure expression produce array... hash literal @{} . next: script have no clue names you've used variables passed it. see 3 strings. suggest using param() named parameters (that default positional, calling script wouldn't change much): param ( $sh...

websocket - How to implement ReST services with Sails.js? -

i quite new node. came across sails.js . think based on websocket, seems building real-time applications. know whether sails can used implement rest architecture uses websocket? , if yes, how? yes can. sails js allows build restful api, no effort started. also, websockets (through socket.io) integrated default view , api. to create restful app ground up, requires no js. try: sails new testapp cd testapp sails generate model user sails generate controller user cd <main root> sails lift the crud (create, read, update, delete) actions created you. no code! you can create user in browser doing following: http post (using tool postman) http://:1337/user/create { "firstname": "bob", "lastname": "jones" } next, see new user: http http://:1337/user/ fyi - sails js uses default disk based database going done.

javascript - Google Maps Marker double click zooming map -

i have placed several makers on google map, follows - var newmarker = new google.maps.marker({ position: someposition, map: map, title: 'my marker', draggable: true }); and set number of listeners on markers; click, dblclick, dragend & rightclick - google.maps.event.addlistener(newmarker, 'dblclick', function (evt) { dostuffwith(newmarker); }); this works, problem when double click markers, map zooms in. i'd map zoom in when double click map only, if double click marker i'd listener event fire & map not zoom. is possible ? thank you. you can add disabledoubleclickzoom: true to map options.

Codeigniter Nested Database Data -

i google , google , read 100000 tutorials think inposible in codeigniter on model, controller , views. am tring show database records : default category |----- sub category | ----one more category |----- somthing else i try lft , rgt cols realy dont understand concept. i read , try function optimize in codeigniter model work in model. http://www.sitepoint.com/hierarchical-data-database-2/ http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/ i have simple db sheme : categories cols id, parent_id, title any1 can give me 1 simple example... please thanks assuming follow basic table structure: id parent_id name you need nested loop. something like: select * table parent_id = 0; # first level select * table parent_id = ?; # subsequent levels normally build object in model return array children in it. function calls , returns object append previous object. watch out recursive functions though, have te...