Skip to content

Instantly share code, notes, and snippets.

@rubys
rubys / heapfailure.js
Created June 24, 2018 19:23
Processing all runs out of heapspace using remark
'use strict';
const fs = require('fs');
const processIncludes = require('./preprocess');
const unified = require('unified');
const markdown = require('remark-parse');
const remark2rehype = require('remark-rehype');
const html = require('rehype-stringify');
const inputFile = '../../doc/api/all.md';
require 'json'
require 'net/http'
conflist = JSON.parse(Net::HTTP.get(URI('https://raw.githubusercontent.com/afilina/dev-community-data/master/data/conferences.json')))
counts = %w(ticket_included hotel_included travel_included).map do |field|
matches = conflist.select do |conf|
conf['speaker_kit'] && conf['speaker_kit'][field]
end
@rubys
rubys / sw.js
Last active July 27, 2016 18:48
ASF Board Agenda service worker
//
// A very simple service worker
//
// 1) Create an event source and pass all events received to all clients
//
// 2) Return back cached bootstrap page instead of fetching agenda pages
// from the network. Bootstrap will construct page from cached
// agenda.json, as well as update the cache.
//
// 3) For all other pages, serve cached content when offline
# From a fresh install of Ubuntu 16.04:
sudo apt-get install elasticsearch
# After that, the following should work but doesn't:
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
sleep 10
curl http://localhost:9200/
#!/usr/bin/ruby
require 'otp' # gem install ruby-otp
def OTP.md5(sequence, seed, password=nil)
if password == nil
begin
print "password: "
system 'stty -echo -icanon'
password = $stdin.gets
password.chomp! if password
require 'gorp/test'
class LiveHang < Gorp::TestCase
test "including ActionController::Live" do
overview <<-EOF
Any attempt to use ActionController::Live causes all requests to hang
EOF
rails 'demo'
equire 'test_helper'
class CartsControllerTest < ActionDispatch::IntegrationTest
setup do
@cart = carts(:one)
end
test "should get index" do
get carts_url
assert_response :success
@rubys
rubys / PushEvent.py
Last active September 23, 2018 20:41
Allow git-multimail to run as a webhook for GitHub
#!/usr/bin/python
from __future__ import print_function
#
# A simple CGI script useful for debugging GitHub web hooks
# https://developer.github.com/webhooks/
#
import hashlib, hmac, json, os, sys, traceback
from subprocess import Popen, PIPE, STDOUT
require 'wunderbar/sinatra'
require 'wunderbar/react'
require 'ruby2js/filter/functions'
get '/' do
_html do
_div.worklist!
_script do
docTypes = %w(icla grant ccla nda other)
docTypes = %w(icla grant ccla nda other)
class DocumentForm < React
def getInitialState()
end
def handleDocTypeChange(event)
var type = event.target.value;
end