Skip to content

Instantly share code, notes, and snippets.

@benfoxall
benfoxall / whatever.twig
Created February 26, 2015 17:25
flashes?
var middlware = function (req, res, next) {
// store flashes incase we need them
var flashes = req.session.flash;
// when flashes are accessed clear them from the session
req.flashes = function() {
req.session.flash = []
return flashes;
}
@benfoxall
benfoxall / resolutions.csv
Created February 18, 2015 16:56
JSOxford screen resolutions
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 1 column, instead of 10 in line 5.
# ----------------------------------------
# All Web Site Data
# Browser & OS
# 20141201-20150217
# ----------------------------------------
Screen Resolution,Sessions,% New Sessions,New Users,Bounce Rate,Pages / Session,Avg. Session Duration,Goal Conversion Rate,Goal Completions,Goal Value
1366x768,166,87.95%,146,87.95%,1.81,00:02:47,0.00%,0,$0.00
1920x1080,121,91.74%,111,90.08%,1.16,00:00:06,0.00%,0,$0.00
1440x900,59,93.22%,55,88.14%,1.12,00:00:03,0.00%,0,$0.00
// (cos allows smooth transitions from 0->1->0)
// 0 -> 1 stepped sin frequency from 1 -> 5
function stepper(i){
var t = 2*Math.PI* ~~(i * 10);
return Math.cos(i*10*t)
}
// generalised version
// helper method for creating functions with
// all arguments mapped through a map_fn
function argument_map(map_fn){
return function(fn){
return function(){
return fn.apply(this,
Array.prototype.slice.call(arguments)
.map(map_fn)
)
}
table[sort=up]:after:extend(.icon-arrow-down-12x12-white);
table[sort=down]:after:extend(.icon-arrow-up-12x12-white);
@benfoxall
benfoxall / futurejs.md
Created May 13, 2014 14:47
FutureJS Libraries

Presentation

reveal.js

Capabilities

  • peerjs - connecting my phone to the slide deck
  • binaryjs - for sending images over websockets. Example is on github
  • modernizr - for pulling capabilties of each device
  • pubnub - for gathering votes and keeping devices in sync

Presentation

reveal.js

Capabilities

  • binaryjs - for sending images over websockets. Example is on github
  • modernizr - for pulling capabilties of each device
  • pubnub - for gathering votes and keeping devices in sync
  • d3js - for visualising capabilities & votes
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-git2.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-git2.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
@benfoxall
benfoxall / backfill-problem.js
Last active August 29, 2015 13:56
PubNub backfill issue
var pubnub = PUBNUB.init({
publish_key : 'pub-c-your-key',
subscribe_key : 'sub-c-your-key',
});
/*---- setup - paste in console a few times to put some messages in A */
pubnub.publish({
channel:'A',
message:'testing-' + Math.random()