start new:
tmux
start new with session name:
tmux new -s myname
| /* Returns probability of occuring below and above target price. */ | |
| function probability(price, target, days, volatility) { | |
| var p = price; | |
| var q = target; | |
| var t = days / 365; | |
| var v = volatility; | |
| var vt = v*Math.sqrt(t); | |
| var lnpq = Math.log(q/p); |
| #!/usr/bin/env python | |
| """Epic script to rename scary uppercase extensions (like .JPG) to | |
| more friendly lowercase (like .jpg). | |
| How to use | |
| ========== | |
| Recursively rename all files in the current directory:: | |
| fixext |
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
| <html> | |
| <head> | |
| <link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css" media="screen" /> | |
| <!-- when.js Promises implementation --> | |
| <script src="https://raw.github.com/cujojs/when/master/when.js"></script> | |
| <!-- Unit testing and mocking framework --> | |
| <script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js"></script> |
| /* | |
| PutCallFlag: Either "put" or "call" | |
| S: Stock Price | |
| X: Strike Price | |
| T: Time to expiration (in years) | |
| r: Risk-free rate | |
| v: Volatility | |
| This is the same one found in http://www.espenhaug.com/black_scholes.html | |
| but written with proper indentation and a === instead of == because it's |
| #!/bin/bash | |
| set -o errexit | |
| set -o nounset | |
| if [[ ${#} -ne 1 ]] | |
| then | |
| echo "Usage: ${0} upstart-conf-file" >&2 | |
| exit 1 | |
| fi |
| App = new Marionette.Application(); | |
| App.addRegions { | |
| "headerRegion": "#header" | |
| "topMenuRegion": "#top-menu" | |
| "mainRegion" : "#main" | |
| } | |
| App.on 'initialize:after', -> | |
| Backbone.history.start() |
The BBC has a server-side image service which provides developers with multiple sized versions of any image they request. It works in a similar fashion to http://placehold.it/ but it also handles the image ratios returned (where as placehold.it doesn't).
The original BBC News process (and my re-working of the script) follows roughly these steps...
divs within the page (which have a class of delayed-image-load) into a transparent GIF using a Base64 encoded string.
width & height HTML attributes of the image to the required sizediv has custom data-attr set server-side to the size of the imageimage-replace onto each newly created transparent imagesetTimeout to unblock the UI thread and which calls a function resizeImages which enhances the image-replace images so their source is now set to a URL whe| // Timer to continue counting while using bcrypt. | |
| // Demonstrates that the bcrypt functions are asynchronous. | |
| ;(function() { | |
| console.log('start timer'); | |
| var x = 1; | |
| setInterval(function() { | |
| console.log('Timer: ' + x); | |
| x++; | |
| }, 1000); | |
| }()); |
| function onlyStatic (middleware) { | |
| return function (req, res, next) { | |
| var match = /(\.css|\.eot|\.gif|\.html|\.js|\.png|\.svg|\.ttf|\.woff|\.jpg)($|\?.*$)/ig.exec(req.originalUrl); | |
| if (!match) return next(); | |
| middleware(req, res, next); | |
| }; | |
| } | |
| //usage | |
| this.use(onlyStatic(express.static(__dirname + "/public"))); |