Posts

python - Skip/pass over view function so the next can execute in Flask -

i have flask app has following: @app.route('/') def home(): return "homepage" @app.route('/<slug>') def feature(slug): return "feature: " + slug @app.route('/<path:url>') def catch(url): return "catch: " + url this works in in following true: get / => "homepage" get /test1 => "feature: test1" get /test/2 => "catch: test/2" eventually, database driven. features, retrieved , displayed based on slug. catch , they'll loaded database , may result in behaviour such redirect, or return 404. none of problem. my question this: in /test1 example, i'd achieve following behaviour: attempt load database slug matches test1 if exists, fine. display. if not exist, i'd "fall through" catch view function. point 3 part don't know how achieve. seems ought exist, can't find kind of "fall through next matching view function...

expression - bash variable evaluating with quote for special character -

below simple bash script test few password in rar file. when password contains special character (!), see option (-p) parsed quote ('). #!/bin/bash -x pwd=`echo sei{0..9}{0..9}b{0..9}axq!zx` #pwd=sei03b4axq!zx file="test.rar" eachpwd in $pwd eval unrar x "$file" -p"$eachpwd" id 2>/dev/null 1>/dev/null c=$? if [ $c = 0 ] echo "success" exit fi echo $eachpwd $c done output + eachpwd in '$pwd' + eval unrar x test.rar '-psei49b4axq!zx' id + c=10 + '[' 10 = 0 ']' + echo 'sei49b4axq!zx' 10 question how code such that, during eval not unrar x test.rar '-psei49b4axq!zx' id instead unrar x test.rar -psei49b4axq!zx id evaluated expression update 1 tried below code, still quote(!) on -p option refuses budge. passwords=( sei{0..9}{0..9}b{0..9}axq!zx ) file=test.rar password in "${passwords[@]}"; if unrar x "$file" -...

c# - Connection String Trouble MetaDataException -

i got 2 models in project. when added second models got error in account page: system.data.metadataexception: specified schema not valid. errors: (8.6): error 0040: nclob type not qualified namespace or alias. primitive types can used without qualification. @ line 34 of `initializesimplemembershipattribute.cs` : using (var context = new userscontext()) ligne 33 : { ligne 34 : if (!context.database.exists()) ligne 35 : { ligne 36 : // create simplemembership database without entity framework migration schema and connection string : <connectionstrings> <add name="defaultconnection" connectionstring="user id=devart;password=1234;data source=localhost:1521" providername="devart.data.oracle" /> <add name="entities" connectionstring="metadata=res://*/models.modelmae.csdl|res://*/models.modelmae.ssdl|res://*/models...

html - jQuery appending multiple line string -

i'm trying append string html element. works fine when it's 1 line string, when try break apart stops working. <div><h4 >list do:</h4><span id="added"></span></div> this doesn't work: var addtext = "<ol> <li>item1</li> <li>item2</li> </ol>" $("span#added").html(addtext); can make work. want add lot of html code, , i'd readable? try : var addtext = "<ol>\ <li>item1</li>\ <li>item2</li>\ </ol>";

ruby - How does Domino deal with a dashed class name -

i'm attempting create , use domino abstract login page describe :index, :type => :request before visit '/' blah_email_login('user1') end ... def blah_email_login(user) dom::email_link.find_by_name 'mail'.click .... end module dom class email_link < domino selector 'a' attribute :tab-label end here html <a class="tab-label fz-xs accent " href="https://mail.blah.com/..." id="blah"><span class="tab-icon img-sprite"></span><em class="strong tab-link-txt y-link-1 " title="mail">mail</em></a> the process cannot take dash indicated error pre run c:\blah.rb:93:in `<class:email_link>': undefined local variable or method `label' dom::email_link:class (nameerror) when attempted alter attribute to attribute :'tab-label' i got ... c:/railsinstaller/ruby1.9.3/lib/ruby/gems/1.9.1/gems/domino-0.5.0/lib/...

c++ - auto vectorization - array reduction -

i'm trying vectorize simple reduction loop: #ifndef poissonsolverjacobi_hpp #define poissonsolverjacobi_hpp #include <stdlib.h> class p{ public: p(); void iterate(); protected: float* m_func; unsigned int m_maxit; }; p::p(){ m_func=(float*)calloc(5000,sizeof(float)); m_maxit=5000; } void p::iterate(){ float err(0.); for(unsigned int i(0);i< m_maxit;i++){ err+=m_func[i]; } } #endif using following compiling command gcc 4.6.3 -march=x86_64: g++ -c -o3 -msse2 -ftree-vectorizer-verbose=2 -fassociative-math -funsafe-math-optimizations could me point out why fails?

openssl - SSL convert url to .crt -

how can convert url .crt file? https://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1 please not perl. have openssl & jvakeyutil want create truststore.jks http://curl.haxx.se/docs/caextract.html has want. contains data converted in format want. if want convert data @ source code of mk-ca-bundle perl program used create converted data.

flash - Actionscript 3.0: Cannot get key input -

guys. created little game. nothing happening thought, because im not getting keyboard input. spend time trying create own taht didnt work. copy/pasted code official actionscript 3.0 reference page, tweaked game (but didnt touch related keyboard stuff). thing game returns in cosnole false import flash.ui.keyboard; import flash.events.event; import flash.events.keyboardevent; stop(); var left = false; var right = false; var speed = 0.3; player.addeventlistener(keyboardevent.key_down, keydf); player.addeventlistener(keyboardevent.key_up, keyuf); player.addeventlistener(event.enter_frame, updf); function keydf(event:keyboardevent):void { trace("test0"); if(event.keycode == keyboard.d) { trace("test1"); left = true; } if(event.keycode == keyboard.a) { right = true; } } function keyuf(event:keyboardevent):void { trace("test2"); if(event.keycode == keyboard.d) { left = false; } if(ev...

html - Debugging CSS with multiple CSS files -

in our application use bootstrap , there multiple css files used. recently, had issue there border created around input box. border css input types over-ridden in particular css file. i tried use chrome dev tools identify css file input box picking (for color) reason not identifying correct css files. borders, shape , size mentioning inheriting parent never mentioning parent css file. is there better tool correctly points css component using? is there better tool correctly points css component using? firebug great & developed. works in firefox, should not big deal basic css debugging purposes. in general there no 1 tool debug things this. jumping around tool tool things right. it’s nature of front-end web development. but in general, might not have touch parent css deal issue. target element in css—if not being targeted—and use !important force new setting override others parent styles. however, balance, "!important" declaration (the de...

node.js - Breaking up node module code (for a library/api client) -

i'm writing node module consume rest api service. intents , purposes might it's twitter (though it's not). the api not small. on dozen endpoints. given want offer convenience methods each of endpoints need split code on multiple files. 1 file far large. right testing pattern outline below, appreciate advice other means might break code. goal extend prototype of single object, using multiple files. here's "model" i'm using far, don't think idea: twitterclient.js function twitterclient(){ this.foo = "bar"; } require("fs").readdirsync("./endpoints").foreach(function(file) { require("./endpoints/" + file)(twitterclient); }); var exports = module.exports = twitterclient; endpoints/endpointa.js etc module.exports = function(twitterclient){ twitterclient.prototype.somemethod = function(){ //do things here } } the basic idea file in endpoints folder automatically loaded , twitterclient p...

Using a Java EE Bean to Save a List of Form Data and print out data in a JSF XHTML DataTable -

here how application works. 1.user fills out "voter registration" xhtml form. 2.when user clicks submit, values saved through using sessionscoped cdi java-ee file. here contents of file: import java.io.serializable; import javax.enterprise.context.sessionscoped; import javax.inject.named; @named @sessionscoped public class voterbean implements serializable{ private string firstname; private string lastname; private string address; private string city; private string state; private string zip; private string phone; private string affil; public voterbean(){ } public string getfirstname(){ return firstname; } public string getlastname(){ return lastname; } public string getaddress(){ return address; } public string getcity(){ return city; } public string getstate(){ return state; } public string getzip(){ return zip; } public string get...

heatmap - Plotting z as a color with R on a rGoogleMap -

Image
i have function , want plot x , y . z should represented color. there package work me ? f = function(a,b){ dnorm(a^2+b^2) } x = seq(-2, 2, 0.1) y = seq(-2, 2, 0.1) z = outer(x, y, f) persp(x, y, z) i want plot function on map generated rgooglemaps . maybe there more specific package use? something this? library(ggmap) # loads ggplot2 library(rgooglemaps) # getgeocode london.center <- getgeocode("london") london <- get_map("london", zoom=12) x <- seq(-2,2,0.1) df <- expand.grid(x=x,y=x) df$z <- with(df,f(x,y)) df$x <- london.center[2]+df$x/20 df$y <- london.center[1]+df$y/20 ggp <- ggmap(london)+ geom_tile(data=df,aes(x=x,y=y,fill=z), alpha=0.2)+ scale_fill_gradientn(guide="none",colours=rev(heat.colors(10)))+ stat_contour(data=df, aes(x=x, y=y, z=z, color=..level..), geom="path", size=1)+ scale_color_gradientn(colours=rev(heat.colors(10))) plot(ggp) this solution uses g...

How do I completely hide the chart title in a HighCharts chart? -

i notice that: title: { text: title, } can customise content of title if need chart without title? should do? try remove code above , got "chart title" instead of having nothing - expected. thanks, title: { text: '' } or title: { text: null }

ios7 - Does CGGlyph depend on the font size? -

cgglyph typedef unsigned short. every font can (or @ least could) specify different cgglyph value same character. within same font, value of cgglyph depend on font size? basically want show same character different font sizes. can set font size cgcontextsetfontsize() , reuse cgglyph value? cgglyph holds index of glyph inside font. because inside font, order of glyphs (individual character designs) can -- in particular, unrelated character code represents. that is, order of characters in fonts unrelated encoding. character code of "a" 65 (in ascii) not mean "the 65th character in font glyph "a". unicode it's impossible make work way: unicode of curly left double quote, example, u+201c, or 8220 in decimal. so there 1 or more tables inside each font translate between logical index of glyph (simply counting characters appear in file itself) , 1 or more encodings . (where encoding predefined set, such "unicode", "macroman...

lua - How to change image based on number of taps in Corona? -

i'm using corona sdk , have this. when tap on image number increases. wonder how change image once reached amount of clicks? display.setstatusbar(display.hiddenstatusbar) local newbutton = display.newimage ("button.png",0,0) newbutton.x = display.contentwidth - 60 newbutton.y = display.contentheight - 62.5 local number = 0 local textfield = display.newtext(number, 30, 30, native.systemfont, 25) local function movebuttonrandom(event) number = number + 1 textfield:removeself() textfield = display.newtext(number, 30, 30, native.systemfont, 25) end newbutton:addeventlistener("tap", movebuttonrandom) the best practice use sprite , when increment point, tell sprite play next frame. there multiple tutorial on working imagesheets , sprites here: http://coronalabs.com/resources/tutorials/images-audio-video-animation/ rob

matplotlib - python pyplot.quiver: Scaling of two superimposed vector fields -

i want plot 2 vector fields in 1 quiver plot. working: each point, there 2 vectors in different colors. problem is, scaling not same: e.g. vector (1,0) first field ( sol ) displayed length (1,0) field 2 ( res ). how can make quiver plot both fields same scale, (1,0) res has same physical length on plot (1,0) sol ? my code: import numpy np matplotlib import pyplot plt #res , sol 2 vector fields dimension (ny, nx ,2) step=3 #not vectors should plotted. every third 1 (in x , y direction) x,y = np.meshgrid(np.arange(0,nx,step), np.arange(0,ny,step)) q=plt.quiver(x,y,sol[::step,::step,0], sol[::step,::step,1], color='r') w=plt.quiver(x,y,res[::step,::step,0], res[::step,::step,1], color='b') plt.quiverkey(q, 0.4, 0.15, 1, r'text1', labelpos='s') plt.quiverkey(w, 0.6, 0.15, 1, r'text2', labelpos='s') plt.show() you have 2 solutions: normalize input data , scale it tell quiver how scale data soluti...

php - mod_rewrite redirect to clean URLs -

i'm using mod_rewrite in .htaccess create following clean urls. .htaccess rewriteengine on rewriterule ^home$ /index.php [l] rewriterule ^groups$ /groups.php [l] rewriterule ^contact$ /contact.php [l] rewriterule ^personalise$ /personalise.php [l] rewriterule ^terms$ /terms.php [l] all works i've been trying original links redirect smooth links. example, if visits www.mydomain.com they'll redirected www.mydomain.com/home , likewise if trail domain index.php or other page name. i've had @ few different rules don't seem work, i'm not familiar module. ideas appreciated! i giving 2 of these new rules: to redirect index.php /home to remove .php extension your full .htaccess: rewriteengine on rewritecond %{the_request} \s/+index\.php[\s?] [nc] rewriterule ^ /home [r=301,l,ne] rewritecond %{the_request} \s/+(.*?)\.php[\s?] [nc] rewriterule ^ /%1 [r=301,l,ne] rewriterule ^home$ /index.php [l] rewriterule ^groups$ /groups.php [l] rewr...

XAML call TabItem Unload event programmatically -

i'm quite new xaml i'm hoping simple question. my main window has tabcontrol , on cases, call unload event on tab. the mainview xaml looks this: <window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:views="clr-namespace:namespace.project1.views" x:class="namespace.project1.views.mainwindow" width="500" height="500" title="hello world"> <grid> <tabcontrol x:name="mytabs" horizontalalignment="stretch" verticalalignment="stretch" > <tabitem header="live" name="childview"> <views:childview horizontalalignment="stretch" verticalalignment="stretch" /> </tabitem> <tabitem header="playback" name...

python - Cython memoryviews on Windows -

when trying use cython on windows (anaconda-based install, using tdm-gcc need support openmp), ran error when using typed memoryviews. test1.pyx def test(int x): pass test2.pyx def test(int[:] x): pass both modules can compiled basic setup.py (using cythonize), while test1 can imported no problem, importing test2 raises following: python3 -c "import test2" (<- note use of python3 -- haven't tried python2) traceback (most recent call last): file "<string>", line 1, in <module> file "stringsource", line 275, in init test2 (test2.c:13146) unicodedecodeerror: 'utf-8' codec can't decode byte in position 1: invalid start byte. with nothing special @ line 13146 of test.c, apparently. is known issue? or doing wrong? welcome. (crossposted cython-users) clarifications: again, please note using python 3 (in fact, bug doesn't appear python 2). i using clean install conda environment, using python 3.4.1 , ...

jQuery UI Dialog Buttons not showing -

Image
i'm attempting use jquery ui dialog box within version of x-cart. problem buttons dialog not show whatsoever. here latest jsfiddle showcasing functionality trying implement. http://jsfiddle.net/iiminov/jsa3a/65/ when go , implement version of x-cart following errors, , hence buttons not show: uncaught typeerror: undefined not function the line in occurs upon this: as not debugging javascript/jquery hoping here shed light on how fix issue?