Skip to content

Instantly share code, notes, and snippets.

(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 November 10, 2015 16:15
requirebin sketch
var plastiq = require('plastiq');
@joshski
joshski / mount.js
Created November 14, 2015 11:58
mount.js
alert('hello');
@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 / 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 / elastic-multi-field-with-stemming.sh
Last active July 5, 2016 11:34
Elasticsearch multi-field search with stemming
echo
echo "DELETE INDEX"
echo
curl -w "\r\n" -X DELETE http://localhost:9200/temp-index
echo
echo "CREATE MAPPINGS"
echo
curl -w "\r\n" -X POST http://localhost:9200/temp-index -d '{"mappings":{"asset":{"properties":{"name":{"type":"string","analyzer":"snowball"},"description":{"type":"string","analyzer":"snowball"}}}},"settings":{}}'
@joshski
joshski / index.js
Last active July 24, 2016 18:43
requirebin sketch
var browserMonkey = require('browser-monkey');
var builder = require('promise-builder');
function append(html) { document.body.innerHTML += '<p>' + html + '</p>'; }
append('<div id="x"><button id="A">A</button></div>');
append('<div id="y"><button id="B">B</button></div>');
append('<div id="z"><button id="C">C</button></div>');
function apiForScope(scope) {
@joshski
joshski / index.js
Created August 9, 2016 08:01
requirebin sketch
var plastiq = require('plastiq');
var h = plastiq.html;
function render(model) {
return h('form',
renderFieldWithPlaceholder('First name', [model, 'firstName']),
renderFieldWithPlaceholder('Last name', [model, 'lastName']),
h('pre', JSON.stringify(model))
);
}
@joshski
joshski / stateful-promise.js
Last active September 2, 2016 09:41
stateful-promise
/*
# stateful-promise
Encapsulates a repeatable asynchronous operation, and exposes the state of the
current invocation.
```
model.documents = new StatefulPromise(() =>
http.get('/documents').then(response => response.body);
);
window.grecaptcha = {
getResponse: function() {
return 'FAKE-RECAPTCHA-RESPONSE'
},
reset: function() {
console.log("FAKE-RECAPTCHA-RESET", arguments)
},
render: function() {