Skip to content

Instantly share code, notes, and snippets.

@joshski
joshski / quick_glance_formatter.rb
Created May 18, 2016 10:23
A nicer rails logger for development time
class QuickGlanceFormatter < ActiveSupport::Logger::SimpleFormatter
def call(severity, timestamp, progname, message)
m = message + "\n"
if m =~ /^Started ([A-Z]+) (.+)/m
"\033[34m\n#{$1} #{$2}\033[0m"
elsif m =~ /^Processing by (.+)/m
"\033[34m↳ #{$1}\033[0m"
elsif m =~ /^Completed (\d\d\d) (.+)/m
status = $1
rest = $2
@joshski
joshski / index.js
Created January 7, 2016 17:25
requirebin sketch
var moment = require('moment');
document.body.innerHTML = moment('5th Jan 2018', 'Do MMM YYYY');
@joshski
joshski / mount.js
Created November 14, 2015 11:58
mount.js
alert('hello');
@joshski
joshski / index.js
Created November 10, 2015 16:15
requirebin sketch
var plastiq = require('plastiq');
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var Linter = require('./linter');
var cheerio = require('cheerio');
function HtmlPage(html) {
this.dom = cheerio.load(html);
}
HtmlPage.prototype.all = function(selector) {
return this.dom(selector);
@joshski
joshski / index.js
Created August 11, 2015 06:38
requirebin sketch
var client = require('browserify-client').connect('http://95.85.22.215:4000');
client.require('plastiq', '1.0.0', function(err, plastiq) {
plastiq.attach(document.body, function() {
return plastiq.html('p', 'plastiq was required dynamically');
});
});
@joshski
joshski / index.js
Created August 4, 2015 07:39
requirebin sketch
var plastiq = require('plastiq');
var inspect = require('plastiq-inspect');
plastiq.append(document.body, function() {
return inspect({
x: [1,2,"three"],
y: { z: [4,5,6] }
});
});
@joshski
joshski / MutationBuilder.java
Last active August 29, 2015 14:24
MutationBuilder.java
public class MutationBuilder<T> implements Builder<T> {
protected Factory<T> factory;
protected MutationBuilder(Factory<T> factory) {
this.factory = factory;
this.mutations = new ArrayList<Mutation<T>>();
}
protected interface Mutation<T> {
@joshski
joshski / index.js
Created June 2, 2015 14:17
requirebin sketch
var routism = require('routism');
var routes = routism.compile([{ pattern: '/fruit/:name', route: 'fruit' }]);
var path = '/fruit/granny+smith';
document.body.innerHTML = JSON.stringify(routes.recognise(path));
@joshski
joshski / index.js
Created February 2, 2015 21:49 — forked from refractalize/index.js
requirebin sketch
var plastiq = require('plastiq');
var h = plastiq.html;
function render(model) {
return h('div.content',
h('h1', 'People'),
h('ol',
model.people.map(function (person) {
return renderPerson(model, person);
})