Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation - foreva

John Weir jweir

🌴
On vacation - foreva
View GitHub Profile
@jweir
jweir / logs-to-s3.sh
Created Oct 14, 2019
Copy log files to S3
View logs-to-s3.sh
for file in `ls access*.gz` ; do
curl -X PUT -d @$file http://localhost:8081/data/logs/$(hostname)/$(date -Idate)/$file
done;
@jweir
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
jweir / FloatInput.elm
Last active Jan 23, 2017
Enable decimal input in elm
View FloatInput.elm
module Main exposing (..)
-- solution based on https://groups.google.com/d/msg/elm-discuss/g7X0jTw87Ck/iudNZekGBQAJ 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
jweir / stitch.py
Created May 6, 2016
stitch images in python
View stitch.py
"""
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
python stitch.py
@jweir
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 http://svenfuchs.com/2009/7/5/using-ruby-1-9-ripper
# Only finds contants which are referenced or defined via class
# does not find constants which are defined inline i.e. X=true
class ConstParser < Struct.new(:source)
def consts
consts = []
@jweir
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 = fn.call(null, value);
}
return value
}
@jweir
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
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 "github.com/antage/eventsource/http"
redis "github.com/vmihailenco/redis"
"log"
"net/http"
)
func haltOnErr(err error){