Posts

Showing posts from July, 2014

javascript - What are best practices for detecting pixel ratio/density? -

i using javascript mobile device detection on website, allows me serve different content mobile or desktop users. currently use window.devicepixelratio , screen.width work out if user if on mobile device or not, so: var ismobilescreenwidth = ((screen.width / window.devicepixelratio) < 768) 768px point @ define mobile or desktop 767 , below mobile , 768 , above desktop. this works perfectly, have come across issue firefox, when firefox zoomed in , out changes window.devicepixelratio , so: zoom = 30%, window.devicepixelratio = 0.3 zoom = 100%, window.devicepixelratio = 1.0 zoom = 300%, window.devicepixelratio = 3.0 this causes me problem because users have browser zoomed in on firefox mobile version of site. i wondering if knew of different or better way of getting pixel density separate desktop browsers. i use small amount of user agent detection because massive job keep changing list of mobile user agents not possible me depend on both screen resolution , user

java - cache control on subdomain in Tomcat 7 -

i can handle cache on core domain (www.domain.com) using below filter public class cachecontrol implements filter{ filterconfig filterconfig; public cachecontrol() { filterconfig = null; } @override public void init(filterconfig filterconfig) throws servletexception { this.filterconfig = filterconfig; } @override public void dofilter(servletrequest request, servletresponse response, filterchain chain) throws ioexception, servletexception { string scache = filterconfig.getinitparameter("cache"); if (scache != null) { date _currentdate = new date(); ((httpservletresponse) response).setheader("cache-control", scache); ((httpservletresponse) response).setheader("expires", new date(_currentdate.getyear(), _currentdate.getmonth(), _currentdate.getdate() + 10).tostring()); ((httpservletresponse) response).setheader("x-content-type-optio

android - Cannot display a alert inside onNewIntent() -

i have problem displaying alert inside onnewintent(intent intent) function. pending intent retrieved correctly , it's value logged expected, alert isn't displayed. @override protected void onnewintent(intent intent) { super.onnewintent(intent); bundle extras = getintent().getextras(); if(extras !=null) { string value = extras.getstring("message"); log.v("alert", value); // <--- line works fine. alertdialog alertdialog = new alertdialog.builder(this).create(); alertdialog.settitle("title"); alertdialog.setmessage(value); alertdialog.setbutton(alertdialog.button_positive, "ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { } }); alertdialog.show(); } } try this: alertdialog alertdialog = new alertdialog.builder(youractivity.this).create();

html - hide HTML5 video using media query -

i've got landing page fullscreen width & height video background. works fine. however, when try hide video on mobile resolution using media queries, doesn't hide @ all. i've tried enclosing video in div, , setting div display none. didn't work either. does have idea how hide background video mobile devices? here's main code. html: <div id="video_bg">     <video id="video_background" autoplay loop>            <source src="backgroundmovie.webm" type="video/webm" /> <source src="backgroundmovie.mp4" type="video/mp4" />       </video> </div> css: #video_background { position: absolute; bottom: 0px; right: 0px; min-width: 100%; min-height: 100%; width: auto; height: auto; z-index: -1000; overflow: hidden; } @media screen , (max-width: 960px) { #video_bg { display:none; } #video_background { display:none; } }

jQuery plugin to apply also on dynamically created elements -

i'm writing jquery plugin should handle information on links specify open behavior. for example, want supports markup : <a href="somewhere" data-openmode="newwindow" class="openmode" /> <a href="somewhere" data-openmode="modal" class="openmode" /> <a href="somewhere" class="openmode" /> <!-- not specified --> the first should open in new window, second in modal dialog, third should open native behavior (whatever target has been set on tag). i create plugin behavior generic possible. i've written now: (function ($) { $.fn.myopenmode = function () { return this.mousedown(function () { var $this = $(this); var mode = $this.data("openmode"); var href = this.href; var handled = true; if (mode) { switch (mode) { case "newwindow":

ms access 2007 - Join query VB.net datareader -

my query on 2 different tables user table , zone table creating problem: cmd.commandtext = "select zone_name, zone_difference user_master inner join zones on user_master.zone_id = zones.id user_master.uname " & """" & usr_gl & """" dim reader_q oledbdatareader reader_q = cmd.executereader() here, zone name , difference zones table , zone_id (from customer) , id (zones) in relation, user name (uname) coming outside usr_gl variable e.g. "admin" it saying no value given 1 or 2 parameters. checked table columns , data. same query running independently access database. is there wrong executing here? yes, trying concatenate strings , no-no in code cmd.commandtext = "select zone_name, zone_difference " & _ "user_master inner join zones on user_master.zone_id = zones.id " & _ "where user_master.uname ?" cmd.parameters.addw

asp.net - when i see my website inside a VWD designer it works fine but on debugging or running the website it gives me only text -

question:- please me out of problem i have question , unable find answer. used google long answer answer less. can 1 answer question. using dotnet 2010 (rtmrel full version) , have created website sample using of pictures , text in it. when see website inside vwd designer works fine on debugging or running website gives me text. images used not shown on web page. website created inside dotnet 2008 (full version) on importing gives same error. please can 1 answer simple question. as far have noticed, vs 2010 rtmrel has of compatibility issue vs 2008 (+ sp1), please don't install both on same system. prefare uninstall of previous versions system , install rtmrel on system (what tried self). solve problem.

java - custom-domain https requests aborted on appengine app -

i have enabled https on custom domain appengine app. worked fine couple of days. after while, on machines requests started getting aborted. i observed on machines prone strange behavior, issue reproducible when following conditions met: - access application using https custom domain - many requests fired 1 after (like adding dom 30+ images, not ajax requests) also observed on machine having problem, if traffic go through fiddler, issue disappear. now: though firing 30 requests 1 after (like adding dom 30 images) might not best of practices, normal firefox , chrome abort 80% of requests when using https on custom domain? if why requests don't aborted when using https , appspot.com url of app? thanks, cristian

Python - matplotlib axes limits approximate ticker location -

Image
when no axes limits specified, matplotlib chooses default values nice, round numbers below , above minimum , maximum values in list plotted. sometimes have outliers in data , don't want them included when axes selected. can detect outliers, don't want delete them, have them beyond area of plot. have tried setting axes minimum , maximum value in list not including outliers, means values lie on axes, , bounds of plot not line ticker points. is there way specify axes limits should in range, let matplotlib choose appropriate point? for example, following code produces nice plot y-axis limits automatically set (0.140,0.165): from matplotlib import pyplot plt plt.plot([0.144490353418, 0.142921640661, 0.144511781706, 0.143587888773, 0.146009766101, 0.147241517391, 0.147224266382, 0.151530932135, 0.158778411784, 0.160337332636]) plt.show() after introducing outlier in data , setting limits manually, y-axis limits set below 0.145 , above 0.160 - not neat , tidy. from m

c - What exactly does "const int *ptr=&i" mean?Why is it accepting addresses of non-constants? -

your answers sought clear major lacuna in understanding const realized today. in program have used statement const int *ptr=&i; haven't used const qualifier variable i .two things confusing me: 1) when try modify value of i using ptr ,where have used const int *ptr=&i; ,i error assignment of read-only location '*ptr'| ,even though haven't declared variable i const qualifier.so exactly statement const int *ptr=&i; mean , how differ int * const ptr=&i; ? i had drilled head const int *ptr=&i; means pointer stores address of constant,while int * const ptr=&i; means pointer constant , can't change.but today 1 user told me in discussion( link ) const int *ptr means memory pointed must treated nonmodifiable _through pointer_ .i find new kinda means "some select pointer can't alter value(while others can)".i wasn't aware of such selective declarations!!but 180k veteran attested that user correct!!.so can stat

mysql - Using an if else if after a where in an sql statement -

how can use if, else if in sql statement after where? i'm trying achieve using php , mysql: //pseudocode $i = 3 select count(id) products parent = $foo , type = (if $i = 2 type = 1, else if = 3 type = 2 or 1, else if = 10 type = 3) how can this? use case statement or that where ordernumber case when isnumeric(@ordernumber) = 1 @ordernumber else '%' + @ordernumber end or can use if statement @n. j. reed

Jquery codes dont work in Joomla, tried everything found on google -

i want wrap img span , set image span's background image can css trick image. found code <script type="text/javascript"> $(document).ready(function(){ $("img").load(function() { $(this).wrap(function(){ return '<span class="image-wrap ' + $(this).attr('class') + '"'+'style="position:relative; display:inline-block; background:url(' + $(this).attr('src') + ') no-repeat center center; width: ' + $(this).width() + 'px; height: ' + $(this).height() + 'px;" />'; }); $(this).css("opacity","0"); }); }); </script> and worked perfect in single html file. however, when added code ~/template/index.php, didn't work , browser reported: uncaught typeerror: object # has no method 'ready' it seemed jquery wasn't loaded, tried add following code index.php: <script type="text/ja

angularjs - Angular Control not working after minified JS file? -

i new angularjs. have create new application in vs2012 using angularjs. have apply minification javascript file, after minification binding in not working me. because $scope keyword angular understand convert a . please let me know how apply minification angularjs file ? from http://docs.angularjs.org/tutorial/step_05 : since angular infers controller's dependencies names of arguments controller's constructor function, if minify javascript code phonelistctrl controller, of function arguments minified well, , dependency injector not able identify services correctly. to overcome issues caused minification, assign array service identifier strings $inject property of controller function, last line in snippet (commented out) suggests: phonelistctrl.$inject = ['$scope', '$http']; there 1 more way specify dependency list , avoid minification issues — using bracket notation wraps function injected array of strings (representing dependency names)

c# - Web.config changing file default location -

i've have tricky question you: in visual c# ide , how change location of file within seperate folder? so example the inital path of folder webproject/folder1/default.aspx in vs 2008, converted 2010 , needed rename default.aspx folder1default.aspx make work in 2010, because couldnt have more 1 default.aspx. when attempt navigate folder, can't open default page. how can set page default location specific folder? if path webproject/folder1/folder1default.aspx, how change location using web.config file? thanks. you did this, there should 1 default or index file defined in iis or config file. <location path="folder1"> <system.webserver> <defaultdocument enabled="true"> <files> <add value="folder1default.aspx"/> </files> </defaultdocument> </system.webserver> </location> i have done in config file <system.we

ruby - How to simplify my Rails money converter module? -

just out of curiosity: is there way simplify file this: module converter def hourly_rate hourly_rate_in_cents.to_d / 100 if hourly_rate_in_cents end def hourly_rate=(number) self.hourly_rate_in_cents = number.to_d * 100 if number.present? end def price price_in_cents.to_d / 100 if price_in_cents end def price=(number) self.price_in_cents = number.to_d * 100 if number.present? end def amount amount_in_cents.to_d / 100 if amount_in_cents end def amount=(number) self.amount_in_cents = number.to_d * 100 if number.present? end end i using these function because need store money related values integers in database, don't repitition in code. you this module converter def self.def_converter(name) define_method(name) value_in_cents = send("#{name}_in_cents") value_in_cents.to_d / 100 if value_in_cents.present? end define_method("#{name}=") |number| send("

r - Easy way to combine mean and sd in one table using tapply? -

in r's tapply function, there easy way output multiple functions combined (e.g. mean , sd ) in list form? that is, output of: tapply(x, factor, mean) tapply(x, factor, sd) to appear combined in 1 data frame. here 2 approaches , few variations of each: in first approach use function returns both mean , sd . in second approach repeatedly call tapply , once mean , once sd . we have used iris data set comes r code runs: 1) first solution # input data x <- iris$sepal.length factor <- iris$species ### solution 1 mean.sd <- function(x) c(mean = mean(x), sd = sd(x)) simplify2array(tapply(x, factor, mean.sd)) here 2 variations of above solution. use same tapply construct simplify using do.call . first gives similar result solution above , second transpose: # solution 1a - use same mean.sd do.call("rbind", tapply(x, factor, mean.sd)) # solution 1b - use same mean.sd - result transposed relative last 2 do.call("cbind",

javascript - SyntaxError: missing : after property id - after obfuscation -

Image
obfuscated code raising error "syntaxerror: missing : after property id". code checked on lint , passing without errors or warnings. this original code (which first line in js document): var pgetcolor = { 'ab': '#cad17d', 'bc': '#7dd1ae', 'cl': '#919aff', 'ci': '#ffe291', 'hb': '#84dbd5', 'on': '#aa84db', 'pm': '#db848a', 'sr': '#b5db84', 'ts': '#c96b9b', 'is': '#ffc926', 'free': '#5fcf68' }; this error report: what i'm doing wrong? it's bug in the obfuscator you're using . code var pgetcolor = { 'ab': '#cad17d', 'bc': '#7dd1ae', 'cl': '#919aff', 'ci': '#ffe291', 'hb': '#84dbd5', 'on': '#aa84db', 'pm': '#db848a', 'sr': '#b5db84', 'ts&

loops - Efficient implementation of summed area table/integral image in R -

Image
i trying construct summed area table or integral image given image matrix. of dont know is, wikipedia: a summed area table (also known integral image) data structure , algorithm , efficiently generating sum of values in rectangular subset of grid in other words, used sum values of rectangular region in image/matrix in constant time. i trying implement in r. however, code seems take long run. here pseudo code this link . in input matrix or image , intimg whats returned i=0 w sum←0 j=0 h sum ← sum + in[i, j] if = 0 intimg[i, j] ← sum else intimg[i, j] ← intimg[i − 1, j] + sum end if end end and here implementation w = ncol(im) h = nrow(im) intimg = c(na) length(intimg) = w*h for(i in 1:w){ #x sum = 0; for(j in 1:h){ #y ind = ((j-1)*w)+ (i-1) + 1 #index sum = sum + im[ind] if(i == 1){ intimg[ind] = sum }else{ intimg[ind] = intimg[ind-1]+sum } } } intimg = matrix(intimg,

Is there an alternative to pickle - save a dictionary (python) -

i need save dictionary file, in dictionary there strings, integers, , dictionarys. i did own , it's not pretty , nice user. i know pickle know not safe use it, because if replace file , (or else) run file uses replaced file , running , might things. it's not safe. is there function or imported thing it. pickle not safe when transfered untrusted 3rd party . local files fine, , if can replace files on filesystem have different problem. that said, if dictionary contains nothing string keys , values nothing python lists, numbers, strings or other dictionaries, use json, via json module .

datetime - What date format is this API returning? -

i'm getting api - date relates 30th june 1983: [dateofbirth] => /date(425775600000+0100)/ so data type this? api doc says it's datetime i've not come across looking before. need able decode , re-encode whatever format is. thanks. that unix time in milli -seconds. unix time given in seconds since 1st january 1970, 425775600 maps 30.06.1983 01:00:00 (with offset due timezone). use tool verify: http://www.gaijin.at/olsutc.php

asp.net - Ext JS with C# Backend -

im starting new webproject. plan generate entire frontend via extjs , communicate c# .net backend (via extdirect !? )... my problem dont know visualstudio project type should use.. backend should handle requests ext js (and communicate other entityframework projekt though thats not problem)... there tutorials around? didnt find that. not sure if have use asp web form project because didnt planned use asp controls or that. said want frontend generated ext js only. please help. im glad input :) i've built project asp.net mvc , extjs front end. use wcf service handle server side calls asp.net mvc framework works fine well. i used ajax proxy in stores call asp.net controllers call database , return result json. i used project traxplorer = extjs 4 mvc + asp.net mvc 3 + crud + rest me started. you may want check out ext.net it's wrapper extjs library .net apps.

Drupal Export of Site Not Working For Subdirectory Levels Beyond Root Directory -

i have move existing drupal site 1 server another. i've done doing mysql database export/import , copying on files new server. on new system, root page comes fine if try go deeper directory levels 404 not found error. so drupal.newserver.com -> works fine drupal.newserver.com/user -> gives me 404 , happens,same subdirectories is there i'm missing part of drupal export? related structure of /sites directory under webserver's docroot?- has folder named after old server (ie drupal.oldserver.com not drupal.newserver.com? also, noticed there _htaccess files , .hta files not .htaccess files in site files i've copied over. sorry if i'm asking bleedingly obvious question - i'm new drupal. thank you! check whether clean url enabled in web server. check try this: drupal.newserver.com/?q=user.

java - PHP connect using JDBC -

i have dbms called bbj dbms. , installed jdbc , connecting via java no problems. thing need connect using php code. , dbmc has odbc windows. have no choice other jdbc. what efficient solution case ? thanks in advance. jdbc java (hence name, java database connectivity)... check out mysqli , pdo connecting database php.

c# - Implement Dispose to my method -

i have winform application uses pcapdot.net dlls , plays pcap files. when playing file in loop can see application memory raised until crash occurs , in stack trace can see happens in method plays file. thinking add dispose method , see if can solve crash. so added class variable private bool _disposed; and methods: public void dispose() { dispose(true); } private virtual void dispose(bool disposing) { if (!_disposed) { if (disposing) { } _disposed = true; } } my play method: public bool sendbuffer(packetdevice packetdevice) { int count = 0; bool bcontinueplay = true; packetdevice selectedoutputdevice = packetdevice; _shouldcontinue = true; _isstop = true; _stopbutton = true; offlinepacketdevice selectedinputdevice = new offlinepacketdevice(_filepath.fullname); //open capture file datetime time = datetime.now;

objective c - NSAttributedString drop shadow is cropping on descenders -

i using nsmutableattributedstring in ios6 apply kerning , drop shadows within uilabel subclass. attributes being applied properly, drop shadow cropping @ at left edge of first character , bottom of descenders ( lowercase p example ). label has clipstobounds disabled. the code... nsmutableattributedstring *attributedstring = [[nsmutableattributedstring alloc] initwithstring:[self text]]; nsrange range = nsmakerange(0, [attributedstring length]); nsnumber *kern = [nsnumber numberwithfloat:0.75f]; [attributedstring addattribute:nskernattributename value:kern range:range]; nsshadow *shadow = [[nsshadow alloc] init]; [shadow setshadowblurradius:3.0f]; [shadow setshadowcolor:[uicolor darkgraycolor]]; [shadow setshadowoffset:cgsizemake(0, 2.0f)]; [attributedstring addattribute:nsshadowattributename value:shadow range:range]; [self setattributedtext:attributedstring]; its barely noticeable, once see it, it's obvious. have others encountered bug , there work-around?

apache - URL rewrite doesn't work in a Symfony2 -

i have web site under symfony 2 , want have basic url rewrite. apache mod rewrite enabled. apache has been restarted multiple times. # a2enmod rewrite module rewrite enabled virtual host seems ok <virtualhost *:80> servername mydomain.com serveralias www.mydomain.com documentroot /home/www/mydomain/web <directory /> options followsymlinks allowoverride none </directory> <directory /home/www/mydomain/web> options indexes followsymlinks multiviews allowoverride none order allow,deny allow </directory> errorlog ${apache_log_dir}/error.log # possible values include: debug, info, notice, warn, error, crit, # alert, emerg. loglevel warn customlog ${apache_log_dir}/access.log combined </virtualhost> and here's .htacess <ifmodule mod_rewrite.c> rewriteengine on #<ifmodule mod_vhost_alias.c> # rewritebase / #&

php - Copying inherited directories containing symlinks -

this similar questions have been asked before, promise different. i have site involves inheritance parent child site. part of media. make media serve faster, creating symlink-ed copy of parent directory in child, override files child defines. allows apache serve statically media (which may come parent) while inheriting html form parent. example after build inheritance common->maps->cars : /some/directory/common/ images/ cats.png muffins.png css/ styles.css /some/directory/maps/ images/ cats.png -> /some/directory/common/images/cats.png muffins.png (overridden child) css/ styles.css -> /some/directory/common/css/styles.css mapsstyles.css (child only) /some/directory/cars/ images/ cats.png -> /some/directory/common/images/cats.png muffins.png -> /some/directory/maps/images/muffins.png css/ styles.css -> /some/directory/common/css/styles.css carsstyles.css (child only) so

compiler construction - SASS inserts code comments periodically into my compiled CSS -

just wondering why sass , how prevent - i'm using scout manage sass / compass projects. inside "sass" folder have main.scss file imports partials/reset.scss file. these compile ../css/main.css , ../css/partials/reset.css respectively. in both of compiled css files, there periodic comments this: /* line 13, ../../sass/partials/reset.scss */ /* line 24, ../../sass/partials/reset.scss */ how prevent adding these comments? they're not in scss files. those line comments indicate code generates styles comes from. can disable uncommenting out line in config.rb: # line_comments = false

python - check if numpy array is subset of another array -

similar questions have been asked on so, have more specific constraints , answers don't apply question. generally speaking, pythonic way determine if arbitrary numpy array subset of array? more specifically, have 20000x3 array , need know indices of 1x3 elements entirely contained within set. more generally, there more pythonic way of writing following: master=[12,155,179,234,670,981,1054,1209,1526,1667,1853] #some indices of interest triangles=np.random.randint(2000,size=(20000,3)) #some data i,x in enumerate(triangles): if x[0] in master , x[1] in master , x[2] in master: print for use case, can safely assume len(master) << 20000. (consequently, safe assume master sorted because cheap). you can via iterating on array in list comprehension. toy example follows: import numpy np x = np.arange(30).reshape(10,3) searchkey = [4,5,8] x[[0,3,7],:] = searchkey x gives array([[ 4, 5, 8], [ 3, 4, 5], [ 6, 7, 8], [ 4, 5,

cordova - PhoneGap PushPlugin installation - Android -

while trying install pushplugin push notifications on phonegap https://github.com/phonegap-build/pushplugin the manual installation process android required adding few lines androidmanifest.xml file not present in case of html5 phonegap mobile application. should add in directory? found it: apparently instructions manual installation. can install adding following <gap:plugin name="genericpush" /> phonegap's config.xml file. i noticed when comparing installation instructions , plugin.xml file in source code. each installation step found in plugin.xml file.

javascript - Jquery, error when using two scripts -

im using 2 scripts on website. sliding function between pages. $(document).ready(function() { $('#wrapper').scrollto('#item2', 0); $('a.panel').click(function () { $('a.panel').removeclass('selected'); $(this).addclass('selected'); current = $(this); $('#wrapper').scrollto($(this).attr('href'), 800); return false; }); $(window).resize(function () { resizepanel(); }); }); function resizepanel() { width = $(window).width(); height = $(window).height(); mask_width = width * $('.item').length; $('#debug').html(width + ' ' + height + ' ' + mask_width); $('#wrapper, .item').css({width: width, height: height}); $('#mask').css({width: mask_width, height: height}); $('#wrapper').scrollto($('a.selected').attr('href'), 0); } and 1 image sli

asp.net mvc - MVC 4.0 String was not recognized as a valid Boolean -

i have razor 2.0 form works locally. i've verified dll's on prod mvc, razor, , helpers latest version. i'm getting exception on every page uses @html.beginform varying parameters. mvc pages seem work fine long no form helpers used: exception: [formatexception: string not recognized valid boolean.] system.boolean.parse(string value) +13981920 system.convert.changetype(object value, type conversiontype, iformatprovider provider) +811 system.web.mvc.viewcontext.scopeget(idictionary`2 scope, string name, tvalue defaultvalue) +89 system.web.mvc.scopecache..ctor(idictionary`2 scope) +75 system.web.mvc.scopecache.get(idictionary`2 scope, httpcontextbase httpcontext) +299 system.web.mvc.viewcontext.getclientvalidationenabled(idictionary`2 scope, httpcontextbase httpcontext) +9 system.web.mvc.html.formextensions.formhelper(html

c - Array of struct pointers - overrides struct -

i'm learning c , encountered problem structs. let's assume have following struct: typedef struct { int x; } structure; int main (void) { structure *structs[2]; for(int = 0; < 2; i++) { structure s = {i}; structs[i] = &s; } for(int = 0; < 2; i++) { printf("%d\n", structs[i]->x); } return 1; } the output is: 1 1 i don't understand why new struct overring old one. it might stupid problem. don't it. thanks! solved: typedef struct { int x; } structure; int main (void) { structure *structs[2]; for(int = 0; < 2; i++) { structure *s = (structure *)malloc(sizeof(structure)); s->x = i; structs[i] = s; } for(int = 0; < 2; i++) { printf("%d\n", structs[i]->x); free(structs[i]); } return 1; } the object s doesn't live beyond scope of first for loop. storing address pointless, , dereferencing undefined behaviour .

r - Panel Data from Long to wide reshape or cast -

hi have panel data , reshape or cast indicator name column long wide format. columns in long format, year(1960-2011), country name (all countries in world), indicator name (varying different indicators) , value(individual values corresponding year, indicator name , country name). how can can please. various indicators in wide format corresponding value below , on other columns year , country name. please help indicator.name year country gdp 1960 usa gdp 1960 uk country name year gdp ppp hhh usa 1960 7 9 10 uk 1960 9 10 na world 1960 7 5 3 africa 1960 3 7 na try using dcast reshape2 below: library(reshape2) indicator <- c('ppp','ppp','gdp','gdp') country.name <- c('usa','uk','usa','uk') year <- c(1960,1961,1960,1961) value <- c(5,7,8,9) d <- data

rails dynamically generate a form -

i'm pretty new whole rails mvc concept, , i've been tasked creating form following: takes test number shows how many sections there per test (this constant, 4) allows region user enter in responses each question in section. number of questions in each section changes depending on test number get. i have view looks this: = form_for [@answer_sheet] |f| =f.collection_select(:test_prep_number, exam.find(:all),:test_prep_number, :test_prep_number, {:include_blank => 'select test prep number'}) =f.fields_for :answer_sections |section_form| =section_form.label :section .form-inline =f.label :a =radio_button_tag 'answer', 'a' =f.label :b =radio_button_tag 'answer', 'b' =f.label :c =radio_button_tag 'answer', 'c' =f.label :d =radio_button_tag 'answer', 'd'

python - Matplotlib.pyplot.contourf: lines, or gaps between polygons? -

Image
i'm trying plot filled contour plot, edge of each polygon white. i've tried turning them of linewidth=0 , linewidths=0 , edgecolor=none , few others. i'm beginning think rounding-error type gap between polygons, don't know. appreciated. here's mean: bottom left , top right, made plt.contourf(x,y,s,20,cmap=get_cmap('piyg'),linewidths=0,edgecolor=none) i upgraded matplotlib 1.1.1rc (which comes ubuntu 12.04) it looks (same function call) - can see white edges have gone. difference more apparent in vector graphics versions.

vsto - Access Categories from shared calendar? -

i can access category collection using following: globals.thisaddin.application.session.categories but if have delegate access calendar, how can list of categories calendar? categories stored in hidden message message class of "ipm.configuration.categorylist" in store's calendar folder. can see in outlookspy if go shared calendar folder , click imapifolder button, go "associated contents" tab. that hidden message can accessed using mapifolder.getstorage in outlook object model. you can access categories collection in redemption using rdocategories collection. redemption exposes categories both on session level ( rdosession .categories default store) , on store level ( rdostore2 .categories). shared mailbox can opened using rdosession.getsharedmailbox.

php - Trouble designing ERD for monthly reports containing several zip codes -

Image
this erd food bank system. i'm unsure how handle zip codes @ moment. i'm not sure on necro policy here, here's old question in case: need designing erd food bank ok food bank gives food out agencies. each month agency fills out report one: http://communityfoodbank.net/agencyaccess/submitareport.aspx need know how many people fed each zip code. now, part counted outside of system. serve food 4+ times month, tally it, , submit report. want save stats in system. how should go this? suggested in original question make zipcode part of pk on monthlyreport table. agencies , zip codes serve imagine rough on database. still recommended new information in mind? how store monthly report , log number served each zip code, keeping in mind more zip codes added agents grow. update with current setup, monthlyreport table generate on 9000 rows month. 30 rows per month per agency. if write reports excel file create 600 files monthly. can't figure out best way this.

html5 - Let Url point to static file -

i have mvc4 application serving html 5 code client. using html 5 video tag show video. put video file application root directory access it, want implement scenario. root directory app i.e. c:\myapp while video file in directory c:\videodir . now want use video tag , pass url source looks http://myurl/myapp/media/video/test.mp4 i need find way redirect url actual videofile inside of videodir without expose videodir via http public. reason approach is, want check permissions before serving video. if expose videodir public via http , knows baseurl able watch video s/he wants to. i tested bit filecontentresult , filepathresult , filestreamresult . chrome can handle result, not possible seek , worst video tag of ios's safari cannot consume these results, while consume original .mp4 file. any idea or suggestions? in iis, add virtual directories inside app folder name of following medias now can access video file below http://myurl/myapp/media/video/te

c# - About Async Tasks and Disposal -

in mainwindow have button can used open process (native openprocess call) , perform checks on it's memory, method called on click asynchronous: <button content="attach" click="onclickattach"/> private async void onclickattach(object sender, routedeventargs e) { attachmentresult result = await m_viewmodel.attach(); switch (result) // different messagebox depending on result. } now, let's see viewmodel portion of code... // memoryprocess class wrapper process' handle , memory regions. private memoryprocess m_memoryprocess; public async task<attachmentresult> attach() { attachmentresult result = attachmentresult.success; memoryprocess memoryprocess = nativemethods.openprocess(m_selectedbrowserinstance.process); if (memoryprocess == null) result = attachmentresult.failprocessnotopened; else { boolean check1 = false; boolean check2 = false; foreach (memoryregio

android - ListView bug and acting different each phone -

the problem having quite unusual. using custon arrayadapter class listview. list items fit screen area appears normal while items require scrolling appeared, either in wrong order or repetition of items in top of list. moreover, scrolling , down, order of items changes. although when debug glitching items clicking them data correct. tasklist.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> adapter, view view, int position, long arg3) { taskentity temp = (taskentity) adapter.getitematposition(position); toast.maketext(screenmain.this, "test : " + temp.tostring(),toast.length_long).show(); } }); this error happening in htc wildfire platform 2.3.5 api level 10 phone. but when test app on samsung galaxy s3 4.1.2 platform api level 16 phone , fine. why getting error? custom adapter problem? public class mytasklistadapter extends arr

java - org.springframework.beans.factory.BeanCreationException:Invalid bean definition -

i beandefinitionstoreexception when try run server. org.springframework.beans.factory.beandefinitionstoreexception: invalid bean definition name 'defaultproductspecificationhandler' defined in servletcontext resource [/web-inf/spring-ws-servlet.xml]: not resolve placeholder 'xsdgenerator.defaultproductspecificationhandler.supportedtypes.7' in string value [${xsdgenerator.defaultproductspecificationhandler.supportedtypes.7}] well, if read error message carefully, you'll see part of config failing: "could not resolve placeholder 'xsdgenerator.defaultproductspecificationhandler.supportedtypes.7'"... it looks placeholder not defined.

javascript - How to prevent IE10 from crashing when it tries to use the DomObject.filters property? -

i have old javascript code can't change crashing on ie10 (i can change other script files). here crashing code: if(isinternetexplorer && this.domelement.filters[0]) this.domelement.filters[0].play() that code not crash in ie8/9 because dom element has non standard property "filters". here documentation filters property . the solution can think of change htmlelement's prototype don't feel possible or thing do. so how can prevent ie10 crashing when tries use domobject.filters property? [edit] found 'solution'. @jam's solution. : if (!htmldivelement.filters) { htmldivelement.prototype.filters = []; } but still feel bad modifying browser native object's prototype. as said, overriding prototype of object 1 way of doing it; so if there no other alternative try this: object.prototype.filters = object.prototype.filters || [] or better (as suggested self): htmldivelement.prototype.filters = htmldivelement

C# CheckBox to Button -

i making program, has 2 checkboxes in windows form. first checkbox clearing file, other printing out. final selection, starting of method button. wanna make if-statement "if checkbox1 clicked , this". should fired button. you can in button's event: if (checkbox1.checked) { //do }

excel - how to search 1 cell in range of cells -

i need formula search if "a4" in range of cells (d column ~ 400 values) , write yes or no b4. need test on 1000 cells in column dragging formula down colum manually. this simple request, seem missing something. put in b4 , drag / drop need: =if(countif($d$1:$d$400,a4)>0,"yes","no") obviously, change range d cells necessary. hope trick

ruby - Rails: Calling Common Method to Edit Various Model Field -

i want create simple method initializing different counter fields users. however, i'm not sure how set value of field referred variable. def self.initialize(user, field) counter = "#{field}".to_sym user.send(counter, nil) user.save end i tried: user.counter instead of user.send(counter) , comes undefined method error user.send(counter) = nil , that's not correct syntax ruby's accessors work using name= method attribute called name . you can access way through model attributes interface: user[counter] = nil user.save alternatively, more generic way should work on ruby object exposes attr_writer , attr_accessor , or equivalent: user.send("#{counter}=", nil) user.save you'd use send version when dealing arbitrary method names, have here. converting to_sym not strictly necessary. always careful white-list kinds of method calls you're accepting. shouldn't let counter arbitrary user parameter wi

wordpress - Passing Form Variables Between If Statement -

i'm working on front end submission page wordpress works in number of steps. so i've got form on page , it's gathering data on few stages , posting after each stage. i can fine using get, don't want variables viewable in url because easy people edit other posts on blog did not write. how go passing post id stage stage using method? there better method out there multiple page forms? as can see below, need pass post id between setup step , step 1 somehow dont want in url get. update: okay, seems step confirm the stage completed in if else statement loosing post , session variables, have changed displays form hidden inputs instead of continue link request. updated pastebin - http://pastebin.com/lphrhwre here code using: http://pastebin.com/8b4qmnrm php <?php if(isset($_get['step'])){ $step = $_get['step']; if ($step == "setup"){ $setup = ""; $step_one =""; if(isset($_post['submi