Posts

Showing posts from August, 2011

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

Node.js child_process.fork() to run on different CPU cores -

i have application runs long-executing processes. make faster, simple sharding of data , want run them in parallel, .fork() 2 instances of same application. i'm having 2 cores machine there , want make sure 2 cores utilized , first instance running on first core, second on second core. i know cluster module, seems not relevant in case, since don't need http services running , load-balancing between them. workers (mean, dont need communicate each other, send messages or whatever - http requests , store data database). is there possible @ control cpu core node.js process take? how monitor on mac/linux? cluster module need : http://nodejs.org/api/cluster.html

algorithm - Text matching names in java -

i've sports application captain can register team tournament. there can multiple tournaments in year , each tournament requires registration. now, want support below in registration process if player has participated in previous tournament app need reuse existing details rather forcing registration. need make sure player not playing 2 teams. i wondering how can best implement name match feature. it makes difference, of names indian origin. i using neo4j data store. you use db4o , use unickey feature field name in player class. tornament class have (set) field players name (and @ least reference indexed name, date name may indexed). then 2 fields : last tournament , registration next 1 have 1 player 1 tournament. using soda query can select player last referenced tournament, , register others

image processing - Trying to understand implementation of gaussian blurring in matlab -

Image
i trying blur scanned text document point text lines blurred black.. mean text blends each other , see black lines. i'm new matlab , though know basics cannot image blur properly. have read this: gaussian blurr , according blur managed/decided sigma function. not how works in code wrote. while trying learn gaussian blurring in matlab came find out achieved using function: fspecial('gaussian',hsize,sigma); so apparently there 2 variables hsize specifies number of rows or columns in function while sigma standard deviation. can 1 please explain significance of hsize here , why has deeper effect on result more sigma ? why if increase sigma high value blurr not effected image distorted lot increasing hsize here code: img = imread('c:\new.jpg'); h = fspecial('gaussian',hsize,sigma); out = imfilter(img,h); imshow(out); and results attached: why not controlled sigma ? role hsize play? why cant blur text rather distort entire image?

osx - MAXREPEAT issue when running Python 2.7 from MacPorts -

i'm running issues running python2.7 macports. here's list of available python versions: $ sudo port select python available versions python: none python25-apple python26-apple python27 (active) python27-apple when set python27 active (as above), following error when running python : $ sudo port select --set python python27 selecting 'python27' 'python' succeeded. 'python27' active. $ python traceback (most recent call last): file "/opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site.py", line 548, in <module> main() file "/opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site.py", line 530, in main known_paths = addusersitepackages(known_paths) file "/opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site.py", line 266, in addusersitepackages user_site = getusersitepackages() file "/opt/lo

JavaScript Geolocation failing in all Android browsers - working in iOS and PC -

here basic code: if (navigator.geolocation) { // point test `alert()` navigator.geolocation.getcurrentposition( // not ot point in android browser function(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; }, showerror, { enablehighaccuracy: true, timeout : 5000, maximumage: 0 } ); } else { return alert('no geolocation support.'); } }; it works great in ios (safari , chrome); , pc browsers i've tried. on android, i've tried stock htc browser, chrome , dolphin. satellites searching then, stops. don't recall asking permission use geolocation (could have overlooked part) update : work on nexus 10 chrome browser. not htc 1 x. update 2 - appears happening on 1 android device, at&t htc 1 x. other android devices, pc browsers , ios work fine. on 1 x error code: timeout. also, gps works fine on devi

asp.net mvc - Handling concurrency exceptions with external API calls -

i have following post edit action method, perform 2 update actions:- edit object on external system suing api calls. edit object on our system database. [httppost] public actionresult create(rackjoin rj, formcollection formvalues) {string controllername = routedata.values["controller"].tostring(); if (modelstate.isvalid) { var message = ""; var status = ""; long assetid = new long(); xmldocument doc = new xmldocument(); using (var client = new webclient()) { var query = httputility.parsequerystring(string.empty); foreach (string key in formvalues) { query[key] = this.request.form[key]; } query["username"] = system.web.configuration.webconfigurationmanager.appsettings["apiusername"]; query["password"] = system.web.configuration.webco

ios - Core Plot graph bottom axis not visible -

Image
i've got core-plot line graph displaying follows (background view coloured red clarity): i have 0 padding @ bottom, , have x-axis configured, labels. graph squeezed right down against bottom of view though. if increase bottom padding grey bar @ bottom same result. what need change in order move graph bottom of view , display axis? the code quite lengthy, here's excerpts: self->graph = [[cptxygraph alloc] initwithframe:hostview.bounds]; hostview.hostedgraph = graph; self->graph.paddingleft = 0.0f; self->graph.paddingtop = 10.0f; self->graph.paddingright = 0.0f; self->graph.paddingbottom = 0.0f; ... [plotspace scaletofitplots:[nsarray arraywithobjects:p1, p2, p3, nil]]; cptmutableplotrange *xrange = [plotspace.xrange mutablecopy]; [xrange expandrangebyfactor:cptdecimalfromcgfloat(1.1f)]; plotspace.xrange = xrange; cptmutableplotrange *yrange = [cptplotrange plotrangewithlocation:cptdecimalfromfloat(0.0

Icons do not show up in Informatica Mapping Designer -

Image
i new informatica , trying learn bit bit.currently able enable repository services nothing works after connected. in transformation icons not highlighted when open mapping designer. please find attached screen-shot. let me know if questions. thank you. you opened mapping designer , connected folder there no mapping loaded - create new mapping or open existing 1 , transformations toolbar become active.

Ruby Sinatra Cookies -

i having issue setting persistent cookies in sinatra: i have 2 routes set same key: response.set_cookie('user_id', { :value => params[:user_id], :expires => time.now + (60 * 60 * 24 * 30), :path => '/' }) the difference between 2 routes 1 post , other get. in both cases set path of cookies '/'. when try retrieve cookie value in route: user_id = cookies[:user_id] i cookie set via post route, if later overwrite using route. i haven't been able find documentation aspect of sinatra, appreciated. you must use user_id = request.cookies[:user_id]

java - Receiving the content of one arraylist into another and then empty the first one -

i want receive content of arraylist array1 arraylist array2 , empty content of array1: public arraylist array1 = new arraylist(); public arraylist array2 = new arraylist(); /* array1 contains data , array2 empty*/ array2.addall(array1); array1.clear(); system.out.println(array2); the problem have array2 empty [] . when remove line array1.clear(); , works great , array2 shows content [a1, a2, a3] . i thought when array2 receives content of array1 can clear array1 without problem. removed both place since it's still in memory? how can right way? array1.clear() sets objects contained in arraylist null. not ensure objects contained in arraylist garbage collected. objects have references elsewhere not gced till references removed. and array1= null sets reference null , not garbage collected till there references , objects contained in gced explained above. as never know when gc done , hence cannot force gc setting objects nul

mean - MATLAB giving me NAN values, can't figure out why -

i'm sure whatever problem here pretty simple, cannot figure out @ all. i have simple data file. .csv file column of labels, , column of values associated each label. trying simple operations involving vector, matlab keeps giving me nan values. even if mean(vector) nan! i can't figure out why. there no nan values in vector. numeric. typed command isnumeric(vector) , got value of 1. used loop cycle through every value in vector, , of them numeric. i have copied of data new csv file , tried that. still gives me nan. i cannot @ figure out going on here. have no problems doing same other vectors. problem matlab won't tell me or problem is, gives me nan. any theories on going on, here? or idea of way check vector see matlab having trouble reading? i using matlab r2008a, on mac. this return indices of data supposedly nan : find(isnan(vector)) you can use nanmean function in statistics toolbox, ignores nan values in data. there nan- versions of ma

ASP.NET MVC3 Complex Routing Issue -

i have following default route set , works fine: routes.maproute( "default", // route name "{controller}/{action}/{id}", // url parameters new { controller = "home", action = "index", id = urlparameter.optional } // parameter defaults ); here example of successful route me: "/positiondetail/candidates/2" this fine , dandy, issue have want set route goes deeper. i.e. "/positiondetail/candidates/2/getmorecandidates" , "/positiondetail/candidates/2/resume/3" resume action want perform, , 3 id. note: each of these route load new page, , not partial view. how set this, , 'positiondetail' controller like? for example, second task may follows: public actionresult resume(int candidateid, int resumeid) { return view(); } in routing: routes.maproute( "resume", // route name "{controll

c# - How to return out of a function or event in VB 6 -

in c# if wanted return out of function do: if (something == true) { //message box return; } else { // nothing } how 1 vb 6? in vb6, write functionname = returnvalue yes, seriously. to stop execution of function, use exit function (or exit sub )

Hide a Column Using Data Annotations in WPF -

i have grid in wpf, auto-generating columns. how can dynamically hide columns using data annotations? i thought of having property in model specify whether column visible, i'm not sure how it. my model, bound grid: public class template { public string county { get; set; } public string operator { get; set; } public string field { get; set; } } here sample uses attributes hide columns. uses attached property handle autogeneratingcolumn event. hidecolumnifautogenerated.cs - attribute namespace autohidecolumn { public class hidecolumnifautogenerated : system.attribute { public hidecolumnifautogenerated() { } } } datagridextension.cs - attached property using system.componentmodel; using system.windows; using system.windows.controls; namespace autohidecolumn { public static class datagridextension { public static readonly dependencyproperty hideannotatedcolumnsproperty = depend

jquery - get all the dates that fall between two dates -

i have problem user selects range of dates. need find out dates fall between 2 selected dates. they're coming in via jquery simple $('#from').val()+"-"+$('#to').val(); they're coming jqueryui datepicker , like 08/07/2013 - 08/09/2012 but can't figure out how step through dates , determine days in in between. need specific dates, becomes complicated things end of month , different number of days in each month. in specific example, i'd need get 08/07/2013, 08/08/2013, 08/09/2013 you can grab values date pickers using getdate method, since return date object. then, starting @ start date increment "current" date 1 day , add array until current date same end date. note you'll need create new date() when adding between array, or else referencing currentdate object , values same. working demo var start = $("#from").datepicker("getdate"), end = $("#to").datepicker("get

jaxb - Webservices - called using HttpUrlconnection and JAX WS RI -

in project, consume webservices . confusing me there webservices(say a ) called using httpurlconnection , req/response marshalled/unmarshalled using jaxb there web service(say b ) see many classes jax wsri , not called using httpurlconnection . see .wsdl files these webservices. /** * class generated jax-ws ri. * jax-ws ri 2.1.1 in jdk 6 * generated source version: 2.0 * */ @webservice(name = "abporttype", targetnamespace "http://www.ups.com/wsdl/xoltws/dcr/v1.0") @soapbinding(parameterstyle = soapbinding.parameterstyle.bare) public interface abcporttype { @webmethod(operationname = "processab", action = = "http://example.com/webservices/xxbinding/v1.0") @webresult(name = "xxresponse", targetnamespace = "http://xx.com/xmlschema/xxws/ab/v1.0", partname = "body") } my doubts why calling webservice b these bloat (end point, jax ws ri instead of using httpurlconnection ? can httpu

java - SQlite delete function is not deleting entries -

im having trouble getting individual items delete in database application using. know method gets called, nothing in list ever removed. im not getting errors making tough track down. assistance awesome. public class mainactivity extends activity{ //global variables listview lv; intent addm, viewm; public dbadapter moviedatabase; string temptitle, tempyear; int request_code = 1; int request_code2 = 2; simplecursoradapter dataadapter; cursor cursor; button addbutton; long testid; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //creates database moviedatabase = new dbadapter(this); moviedatabase.open(); //moviedatabase.deleteallmovies(); //creates intents start sub activities addm = new intent(this, addmovie.class); viewm = new intent(this, movieview.class); } //handles return of activity addmovie public void onactivityresult(i

php - Have item description and taxes on Paypal -

i working on online store , wanted add paypal checkout method. started using express checkout worked fine until tried add taxes. problem express checkout need calculate taxes amount , send rest on information. problem need know customer can adjust tax amount. tried use adaptive payments when comes description of order show receivers (ex: onlineshop@something.ye) can not add multiple items express checkout since didn't worked out did not try see if tax working method. so know is... how can address of customer can show him taxes in order details express checkout ? if not possible, there way can change order details of adaptive payment ? there suppose way address before doing doexpresscheckout , change tax amount there using maxamt in setexpresscheckout customer see tax amount on website , not in paypal page think kind of odd. edit 1 now i've added callback it's asking me shipping flat rate. here request string... '&method=setexpresscheckout&#

android - Start Activity and don't destroy other activity -

i new android , started activities - b - c - d. activity d, when open activity again how can start activities b , c don't finish , starts again? there should 1 activity a. thanks in advance. use intent flag flag_activity_reorder_to_front in d intent = new intent(activityd.this, activitya.class); i.setflags(flag_activity_reorder_to_front); startactivity(i); this bring activitya front of stack , leave b , c believe want. can call finish() on d if want remove stack. you can find available flags in intent docs

ruby - Rails DateTime Comparison Bug -

i have ticket class has default rails column of updated_at while on ticket page making update polling database see if else has changed @ same time. in view if works <p>updated at: <%= @ticket.updated_at.to_time.strftime('%y-%m-%d %h:%m:%s') %></p> <p>current time: <%= time.now.strftime('%y-%m-%d %h:%m:%s') %></p> <% current_time = time.now %> <% if @ticket.updated_at > time.now %> <p>ticket has been updated</p> <% else %> <p>ticket has not been updated</p> <% end %> so here ajax request (library prototype new to, prefer jquery): <script type="text/javascript"> function checkticketupdate() { var url = '/ticket/check_ticket_update'; var parameters = 'id=<%= @ticket.id %>&current_time=<%= current_time %>' var container = 'ticket_updated_container'; var myajax = new

android - On Item click of listview not responding -

i have custom adapter set listview itemclickevent not working . have included adapter inside main activity.i have tried many suggestions havent got solutions till yet. public class mainactivity extends activity { private listview listview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); model.loadmodel(); listview = (listview) findviewbyid(r.id.list); string[] ids = new string[model.items.size()]; (int i= 0; < ids.length; i++){ ids[i] = integer.tostring(i+1); } graphlistadapter adapter = new graphlistadapter (this,r.layout.list_row, ids); listview.setadapter(adapter); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } public class graphlistadapter extends baseadapter { p

javascript - flask: how to get a POST endpoint to redirect correctly -

have complicated endpoint in flask deployed server: @app.route('/whatever', methods=['get', 'post']) def somefunct: if request.method = 'post': << stuff >> << other stuff >> return render_template('sometemplate.html', **<<variable dict>>) that pushes 1 template. sometemplate.html kind of tricky, contains table pulls data variable dictionary , provides dropdown allows user interact it: {% item in << variable in dict >> %} ... <td> <form name="category-form" id="category-form-{{ item }}" action="/whatever"> <select name="{{ item }}" id="{{ item }}"> <option value="1">option 1</option> <option value="2">option 2</option> <option value="3">option 3</option> </select> <

How can I put kendo sparklines in all rows? -

i put sparklines in column usage, has 1 row, how can put rows in column usage? i put of code relating usage column jsfiddle code columns: [{ { field: "usage", title: "usage", template: '<span id="sparkline"style="line-height: 60px ; padding: 0 5px 0spx ; text-align: center" ></span>' }, { command: ["edit"], title: "&nbsp;" }], editable: "popup", }); thank you the problem use id in template: id must unique. change id class template: '<span class="sparkline"style="line-height: 60px ; padding: 0 5px 0spx ; text-align: center" ></span>' and in initialization use: $(".sparkline").kendosparkline({...}); instead of: $("#sparkline").kendosparkline({}); see here : http://jsfiddle.net/onabai/72kup/embedded/result/

concurrency - Are there any operations/methods in Ruby that are guaranteed/documented to be atomic? -

i did quick google search, , written on atomicity in ruby suggest wrapping mutex around operation. however, suspect approach doesn't satisfy usual definition of atomicity, since signal interrupt synchronized code. example (taken ruby best practices ): lock = mutex.new # xxx example of not inside signal handler: trap(:usr1) lock.synchronize # if second sigusr1 arrives here, block of code # fire again. attempting mutex#synchronize twice # same thread leads deadlock error end end i understand atomicity less important high level languages, sake of research canonical answer on matter implementations gil (e.g. mri 2.0.0 ) , without e.g. jruby 1.7.4, , rubinius 1.2.4 i have limited knowledge on topic. try answer best can. there article jesse storimer wrote concurrency. highly recommend read of 3 parts it. http://www.jstorimer.com/blogs/workingwithcode/8100871-nobody-understands-the-gil-part-2-implementation the conclusion on part 2 gil guaranteed

linux - bash printf backslash then new line -

i trying create bash c header #define xxxxx \ "id title\n" \ "1 developer\n" \ script format=" \"%-4s %-32s\\\n" printf "$format" "id" "title\\n\"" >> $file printf "$format" "1" "developer\\n\"" >> $file the result "id title\n" \n "1 developer\n" \n when change format="%-4s %-32s \\ \n" i get "id title\n" \ "1 developer\n" \ and gcc start complain space after \ it seems \\ interpreted more once if there no space. without using format="%-4s %-32s \\" printf "$format" "id" "title\\n\"" >> $file printf "\n" >> $file ... is there better way handle this? use hexadecimal escape sequences: for

css - How do you determine the correct local font names when preloading webfonts? -

this article: when web-fonts load , can pre-load them? , says use local take advantage of loaded fonts. can't find other way preload webfonts. however, can't figure out names supposed use local references. in macosx multiple variants show same font name. e.g. think local("helvetica neue light") available in font book "helvetica neue"... how refer different variants? @font-face { font-family: 'proximanova'; font-weight: normal; font-style: normal; src: url('/fonts/proximanova/proximanova-reg-webfont.eot'); src: local("proxima nova regular"), url('/fonts/proximanova/proximanova-reg-webfont.eot?#iefix') format('embedded-opentype'), url('/fonts/proximanova/proximanova-reg-webfont.woff') format('woff'), url('/fonts/proximanova/proximanova-reg-webfont.ttf') format('truetype'), url('/fonts/proximanova/proximanova-reg-webfont.svg#webfont') forma

transparency - YouTube Player not working with a Transparent Panel Menu Android -

the youtube player play videos no problem either without transparent panel on form or play them in full screen, transparent panel has images in nothing special. if take out transparent panel, youtube player works desired, embedded in app. if add transparent panel form, when not play in full screen. video starts , stops instantly. assume has transparent panel can not understand happening. or thoughts great. java file not change except initpopup not there. shortened java file version below. xml layout file below: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mlayout" android:layout_width="fill_parent" android:layout_height="fill_parent"> <relativelayout android:layout_width="wrap_content" android:layout_height="wrap_content" > <com.google.android.youtube.player.youtubeplayerview android:id="@+id/youtube_view"

html - Twitter Bootstrap: overflow of btn-group -

i have bunch of button s inside div fixed width , auto height. want contained buttons shift next line once overflow container div. here's code: <div class='btn-group' style='width:100px; height:auto;'> <button class='btn'>hello</button> <button class='btn'>hello</button> <button class='btn'>hello</button> <button class='btn'>hello</button> <button class='btn'>hello</button> <button class='btn'>hello</button> <button class='btn'>hello</button> </div> the buttons out of group. doing <br /> helps i'd prefer if there more direct solution since inserting buttons programatically. thanks. override whitespace property on .btn-group .btn-group{ white-space: normal; } jsfiddle: http://jsfiddle.net/k9xcj/

html - Having issues with viewport tag not working -

i have 2 webservers..one on local laptop: apache2 version 2.2.22 and on machine apache2 version 2.2.17 the page i'm running is. http://www.medfieldmarlins.org/sizetest.html in mobile situations 1 on 2.2.22 on local laptop works expected. on 2.2.17 machine not respect meta tag @ all. i'm confused , frustrated. ok have idiot moment. domain hosted godaddy , in iframe...domain forwarding. meta tag in iframe... turned off masking on forwarding , working.

How do I get a file list for a Google Drive public hosted folder? -

is there way file listing without using authorization publicly hosted goolge drive folder? example folder: https://googledrive.com/host/0b1nmfb7vdm6jnnhjwk9cdu9uehc/ i want use folder host images display in gallery on other sites. there's no way unauthenticated. however, can authenticate user , list drive.children.list()

javascript - nodejs: wait for other methods to finish before executing -

say have 2 methods: function a(callback) { ... } function b(callback) { ... } i want execute: function c(); after both , b finished. put function c in callback like: a(function() { b(function() { c(); }); }); now if both , b takes long time, don't want b execute after has been finished. instead want start them @ same time enhance performance. i'm thinking implement semaphore (not semaphore of course), fires event after both , b finished. can call c within event. what want know is, there library implemented above function already? believe i'm not first 1 wants it. appreciated. to expand on comment... async commonly used asynchronous flow control library node.js. its async.parallel() this: async.parallel([ function(done) { a(function () { done(null); }); }, function(done) { b(function () { done(null); }); } ], function (err) { c(); }); it's poss

c - Makefile.am commands to override library functions -

i have open source project relies on open source project (let's call other project x). both written in c. i've had hack pieces of x multi-threading work. causes issues when trying package code distribution. make things easier, i've included entirety of x within mine along few little hacks i've made. i'd more sophisticated in order keep improved functionality of x (it has frequent releases , mine not) without having repackage whole project (with hacks) within project again each time x has release. there 3 or 4 functions in need override. can follow going on in ibm tutorial , how can modify makefile.am generate makefile changes suggested in article? summarize, article suggests writing own functions same signatures ones want override (in file called libfuncs.c) , add following 'libs' target makefile: all: libs setresgid-tester libs: libfuncs.c gcc -shared -wl,-soname,libfuncs.so.1 -o libfuncs.so.1.0 libfuncs.c ln -s

CSRF verification failed: Django 1.5.0 -

i'm running basic django login app (i thought) based on official docs and...it's still not working no matter i'm doing, , i've been looking through every single question on stackoverflow , not finding answer. i'm running django.version 1.5.0. every single thing add or code, still csrf verification failed error. inside portal/views.py : @cache_page(60 * 15) @csrf_protect def index(request, id=none): return render_to_response('undercovercoders/index.html', context_instance=requestcontext(request)) @cache_page(60 * 15) def login_user(request): if request.post: username = request.post.get['username'] password = request.post.get['password'] user = authenticate(username=username, password=password) if user not none: if user.is_active: login(request, user) state = "you're logged in!" else: state

c# - Paint Draw Image from another Thread? -

i read can increase drawing speed/time drawing paint event, , can draw unscaled. so try on panel. the problem though, image recieved in thread gui, , don´t know how give paint event. i don´t want invoke , stuff (as incredibly slow, @ least when have used it). the code look, this. protected override void panel1_paint(object sender, painteventargs e, image u) { e.graphics.drawimageunscaled(u, point.empty); } though there tried using override add add image in field, ald wanted make static, call thread. sadly t didn´t work. but well, tried. private void panel1_paint(object sender, painteventargs e) { // e.graphics.drawimageunscaled(u, point.empty); } there "working" one, except can´t image it. i tried making image variable, save image in variable, , paint it. paint never see image in it, can´t access image, guess cause it´s written thread. //initialize private image im; //////// thread im = image.fromstream(....); ////////////7

angularjs - firebase logout method has no callback? -

i'm looking @ doc: https://www.firebase.com/docs/security/simple-login-overview.html , based on doesn't logout doesn't accept callback. tried passing 1 , got response accepts 0 arguments. there way confirm logout successful? on same page, there section titled "monitoring user authentication state" mentions callback pass firebasesimplelogin constructor function "invoked time user's authentication state changed." the first parameter ( error ) non-null if there error user logging in; second parameter ( user ) non-null if user logged in; , both null if user not logged in. here's example page: var chatref = new firebase('https://samplechat.firebaseio-demo.com'); var auth = new firebasesimplelogin(chatref, function(error, user) { if (error) { // error occurred while attempting login console.log(error); } else if (user) { // user authenticated firebase console.log('user id: ' + user.id + ', p

ios - set start index for static tableviewcontroller -

i have static tableviewcontroller (it had done way), want set position (index 40) when loads. unfortunately, code below works when not static. there alternative ways accomplish this? [self.tableview scrolltorowatindexpath:[nsindexpath indexpathwithindex:1] atscrollposition:uitableviewscrollpositionnone animated:no]; well, if cells static , they're sizes same, adjust contentoffset property of table view directly set cells on screen, ex: cgpoint offsetofcell40 = cgpointmake(0.0f, 2500.0f); [tableview setcontentoffset:offsetofcell40 animated:no];

java ee - Limiting the size of client requests in Apache Tomcat -

i wondering best way limit size of requests made single client. example string password = request.getparameter("password"); let's client sending password of length 10,000. perform check on length of string , ignore if larger size 10,000 useless bytes have still made way application. way of limiting size of requests @ lower level in network stack? according link can remove post size, assume works both ways , can set limit on post size 4kb in server.xml file. http://tomcat.apache.org/tomcat-5.5-doc/config/http.html

c - warning: return makes pointer from integer without a cast but returns integer as desired -

i'm trying find out proper way return integer void * function call within c. ie .. #include <stdio.h> void *myfunction() { int x = 5; return x; } int main() { printf("%d\n", myfunction()); return 0; } but keep getting: warning: return makes pointer integer without cast is there cast need make work? seems return x without problem, real myfunction returns pointers structs , character strings work expected. it's not obvious you're trying accomplish here, i'll assume you're trying pointer arithmetic x, , x integer arithmetic void pointer on return. without getting why or doesn't make sense, can eliminate warning explicitly casting x void pointer. void *myfunction() { int x = 5; return (void *)x; } this raise warning, depending on how system implements pointers. may need use long instead of int. void *myfunction() { long x = 5; return (void *)x; }

regex - Matching a Pattern in PHP -

i trying validate whether or not string contains , starts ba700 . have tried using preg_match() function in php have not had luck. code below: preg_match('/^[0-9]{3}-[0-9]{4}-[0-9]{4}$/', $search)) this not work unfortunately. ideas? updates code: $needle = 'ba700'; $haystack = 'ba70012345'; if (stripos($haystack, $needle)) { echo 'found!'; } this not work me either here how correctly use stripos if (stripos($haystack, $needle) !== false) { echo 'found!'; }

javascript - Creating a browser Exit popup -

what want detecting browser close event(on browser unload) , open new pop have options (give feedback, go page again , mail me report etc). @ same time want parent window alive till user select option in pop window. tried following , seems not working. $(window).bind('beforeunload', function(event){ event.preventdefault(); }); please give me right direction achieving this. you can alert/dialog $(window).bind('beforeunload', function(event){ return "hold on minute there, conme , answer questions"; });

python - grouping dataframes in pandas efficiently? -

i have following dataframe in pandas there's unique index ( employee ) each row , group label type : df = pandas.dataframe({"employee": ["a", "b", "c", "d"], "type": ["x", "y", "y", "y"], "value": [10,20,30,40]}) df = df.set_index("employee") i want group employees type , calculate statistic each type. how can , final dataframe type x statistic , example type x (mean of types) ? tried using groupby : g = df.groupby(lambda x: df.ix[x]["type"]) result = g.mean() this inefficient since references index ix of df each row - there better way? like @sza says, can use: in [11]: g = df.groupby("type") in [12]: g.mean() out[12]: value type x 10 y 30 see groupby docs more...

ios - Insert the Large Amount of Data in SQLite in iPhone -

i want inset 2000 rows in database table there way insert data fast.currenty using below code insert data in database. code :- +(nsstring* )getdatabasepath{ nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *writabledbpath = [documentsdirectory stringbyappendingpathcomponent:@"crocodilian"]; return writabledbpath; } +(nsmutablearray *)executequery:(nsstring*)str{ sqlite3_stmt *statement= nil; sqlite3 *database; nsstring *strpath = [self getdatabasepath]; nsmutablearray *alldataarray = [[nsmutablearray alloc] init]; if (sqlite3_open([strpath utf8string],&database) == sqlite_ok) { if (sqlite3_prepare_v2(database, [str utf8string], -1, &statement, null) == sqlite_ok) { while (sqlite3_step(statement) == sqlite_row) { nsinteger = 0; nsinteger icolumn

code review - import repository feature in gerrit -

i have switched gitlab gerrit , wondering if there feature of importing existing repositories in gerrit (like in gitlab create new project page). according documentation can ssh repos after creating new project , want provide such senario :- hook new project existing repo such new commit in repo may trigger creation of new patch set code review in gerrit. one way write backhand script,but question , there decent way ? thanks gerrit wants manage repositories. needs own hooks fire, , magical refs/for/foo branches work. you're going have push repositories gerrit, , submit code reviews there. you could create ref-updated hook in original repository looks @ incoming patches , creates gerrit review requests them, going script indicated not wanting write.

math - a way to search between some points and find important points -

i have points, in order, drawn user. i want find important points between these points. important point, define, point have sudden change in direction of points. example, 'z' drawn hand, has has 2 important points. i tried computing angle between adjacent points, not giving me desired result. , computing change in slope same. maybe need optimize angle finding somehow, have no idea. idea? edit: here java code compare angles: int nbreakpoints = 0; double nextangle = 0; double nextr; double r = math.sqrt(math.pow(points[1].x-points[0].x, 2) + math.pow(points[1].y-points[0].y, 2)); double angle = math.asin((points[1].y-points[0].y) / r)*180/math.pi; double cumr = r; int firsti = 0; for(int i=1; i<points.length-2 ;i++) { nextr = (int) math.sqrt(math.pow(points[i].x-points[i+1].x, 2) + math.pow(points[i+1].y-points[i].y, 2)); cumr += nextr; if(cumr < 20 || cumr==0) continue; nextangle = math.asin((points[i].y-points[firsti].y) / cumr

javascript - Displaying dynamic data in JQplot -

hello guys using jqplot display piechart. new jquery why kind hard me manipulate arrays in jquery. this structure of arrays pass jquery , dynamic array (size=8) 0 => array (size=1) 'baseball' => string '12.18' (length=5) 1 => array (size=1) 'basketball' => string '8.12' (length=4) 2 => array (size=1) 'boxing' => string '5.54' (length=4) 3 => array (size=1) 'golf' => string '6.64' (length=4) 4 => array (size=1) 'soccer' => string '36.90' (length=5) 5 => array (size=1) 'tennis' => string '27.31' (length=5) 6 => array (size=1) 'football' => string '2.21' (length=4) 7 => array (size=1) 'hockey' => string '1.11' (length=4) and want data display on pie chart. far code. $(document).ready(function(){

should i use django's many-to-many option? -

django newb here, working off django polls tutorial , trying add model that'll keep track of poll results: # create models here. class poll(models.model): question = models.charfield(max_length=200) pub_date = models.datetimefield('date published') numchoices = models.integerfield(default=0) def __unicode__(self): return self.question class choice(models.model): poll = models.foreignkey(poll) choice_text = models.charfield(max_length=200) votes = models.integerfield(default=0) def __unicode__(self): return self.choice_text class session_results(models.model): sessionkey=models.foreignkey(session) questionasked = models.foreignkey(poll) answerchosen=models.foreignkey(choice) def __unicode__(self): return self.sessionkey the use case have list of questions (poll model), list of choices each choice maps question (choice model), , want keep list of sessions, can keep track of questions user has an