Skip to content

Instantly share code, notes, and snippets.

View graphaelli's full-sized avatar

Gil Raphaelli graphaelli

View GitHub Profile
@graphaelli
graphaelli / LICENSE
Last active April 25, 2018 14:45
Flickr Archive Utilities - MIT License
Copyright 2018 Gil Raphaelli
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@graphaelli
graphaelli / number_test.go
Created March 27, 2018 20:56
useNumber benchmark
package main
import (
"bytes"
"encoding/json"
"testing"
)
var (
data map[string]interface{}
@graphaelli
graphaelli / Gopkg.toml
Created March 23, 2018 21:19
messing around with the prometheus client
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
@graphaelli
graphaelli / somaxconn.go
Created March 21, 2018 20:50
fetch kern.ipc.somaxconn
if somaxconn, err := unix.Sysctl("kern.ipc.somaxconn"); err != nil {
panic(err)
} else {
var backlog uint16
r := strings.NewReader(somaxconn)
if err := binary.Read(r, binary.LittleEndian, &backlog); err != nil {
fmt.Println("binary.Read failed:", err)
}
fmt.Println(backlog)
}
@graphaelli
graphaelli / sampleflaskapm.py
Created February 27, 2018 20:45
sample elastic apm flask app
#!/usr/bin/env python
import elasticapm
from elasticapm.contrib.flask import ElasticAPM
from flask import Flask
# initialize using environment variables from elasticapm.contrib.flask import ElasticAPM
app = Flask(__name__)
#!/bin/bash -e
if [ ! -d ${GOPATH} ]; then
echo missing GOPATH
exit 1
fi
mv ${GOPATH} ${GOPATH}.$(date '+%Y%m%d_%H%M%S')
mkdir -p ${GOPATH}
go get -u -v \
@graphaelli
graphaelli / aws-session-env.py
Created December 29, 2017 18:21
Export environment variables for AWS cli w/MFA.
#!/usr/bin/env python
"""Export environment variables for AWS cli w/MFA.
eval $(aws-session-env.py $1)
"""
import argparse
import os
import boto3
#!/bin/bash
gotest() {
clear
go test -bench .
}
gotest
export -f gotest
fswatch -o *go | xargs -t -I{} bash -c gotest
package main
import (
"log"
"net/http"
"time"
)
// https://raw.githubusercontent.com/zenazn/goji/master/web/middleware/nocache.go
#!/usr/bin/env python
import importlib
import sys
def actions(module):
mod = importlib.import_module(module)
for attrib in dir(mod):