Skip to content

Instantly share code, notes, and snippets.

On vacation - foreva

John Weir jweir

On vacation - foreva
View GitHub Profile
jweir /
Created Oct 14, 2019
Copy log files to S3
for file in `ls access*.gz` ; do
curl -X PUT -d @$file http://localhost:8081/data/logs/$(hostname)/$(date -Idate)/$file
jweir / App.elm
Last active Sep 21, 2018
Work around for Elm Reactor programWithFlags (elm 0.18)
View App.elm
module App exposing (..)
import Html
type alias Flags =
{ name : String }
type alias Model =
jweir / FloatInput.elm
Last active Jan 23, 2017
Enable decimal input in elm
View FloatInput.elm
module Main exposing (..)
-- solution based on by Witold Szczerba
import Html exposing (beginnerProgram, div, button, text)
import Html.Events exposing (onInput)
import Html.Attributes as HA
import String
type alias Model =
View select.elm
select [onchange ??] [
option [value FILTER_A] [text "Filter a"]
, option [value FILTER_B] [text "Filter b"]
jweir /
Created May 6, 2016
stitch images in python
First make sure you have the Python Image libraries installed
sudo pip install pillow
Down below you will need to define the absolute path to the images see "dir=..."
Run this by entering
jweir / const_parse.rb
Last active Feb 22, 2016
Simple parse to find all constants in a Ruby file
View const_parse.rb
require 'test_helper'
require 'ripper'
# see
# Only finds contants which are referenced or defined via class
# does not find constants which are defined inline i.e. X=true
class ConstParser <
def consts
consts = []
jweir / pipes.js
Last active Aug 29, 2015
Naive pipes in javascript
View pipes.js
function pipe(src){
var value = src;
return function(){
for(var i = 0; i < arguments.length; i++){
var fn = arguments[i];
value =, value);
return value
jweir / fixslides.js
Last active Aug 29, 2015
I dislike the slide deck that the Go team uses for the presentations. It is a bit of a pain to read and follow on a desktop. This bit-o-JS will turn the slide deck into a normal scrolling page.
View fixslides.js
$('article').attr('class','current').css({position: 'relative', margin: 10, padding: '20px',top: 0, left: 0, height: 'auto', width: 'auto'}), $('#help').remove(), document.removeEventListener('keydown', handleBodyKeyDown), $('h2').css({position:'static'})
View gist:bfac545a1648620c1247
// just a sketch to put away for now
// these are weeding functions
// the goal is to remove lables on a graph that are too close together (ie weed out overlapping labels)
function weed(array, x, y){
var f = array[0]
, l = array[array.length -1]
, ex = d3.extent(array, function(d){ return d.y })
, hiLo = array.filter(function(d){ return d.y == ex[0] || d.y == ex[1]});
return _.uniq([f,l].concat(hiLo));
jweir / redis-eventsource.go
Last active Apr 19, 2021
Example of using Redis PubSub and EventSource with golang
View redis-eventsource.go
package main
import (
eventsource ""
redis ""
func haltOnErr(err error){