Skip to content

Instantly share code, notes, and snippets.

View rjz's full-sized avatar
👋
Hey there!

RJ Zaworski rjz

👋
Hey there!
View GitHub Profile
@rjz
rjz / metrics.sh
Last active May 8, 2017 16:00
Dump dynamo consumption high-water marks from cloudwatch
#!/bin/bash
# Usage:
#
# $ metrics.sh > dynamo_tables.txt
#
# $ cat dynamo_tables.txt \
# | tr : ' ' \
# | sed 's/\./ /' \
# | sed 's/ =//' \
@rjz
rjz / update_typings.sh
Last active January 6, 2017 21:43
Updating TypeScript typings to latest versions
#!/bin/bash
# Update TypeScript `typings` to their latest versions.
#
# Running this ad-hoc may break your project; be prepared to resolve issues by
# hand.
#
# Released under the terms of the MIT License
set -e
@rjz
rjz / redux-actions-with-typescript-discriminated-unions.ts
Created September 29, 2016 16:00
Redux actions using TypeScript discriminated unions
// Redux actions using TypeScript discriminated unions
//
// Source: https://github.com/rjz/typescript-react-redux/
// Actions
export type Action =
{ type: 'INCREMENT_COUNTER', delta: number }
| { type: 'RESET_COUNTER' }
@rjz
rjz / extract_github_blob.go
Created July 7, 2016 15:15
Extract base64-encoded github.Blob
import (
"encoding/base64"
"errors"
"fmt"
"github.com/google/go-github/github"
)
// Extract a Blob with arbitrary encoding into a byte array
func ExtractBlob(blob *github.Blob) (*[]byte, error) {
bytes := []byte(*blob.Content)
@rjz
rjz / pre-push
Last active April 20, 2016 22:16
pre-push hook for linting JS / CoffeeScript
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
FILENAME="$( basename "${BASH_SOURCE[0]}" )"
PROJECTDIR="$(readlink "${DIR}/../..")" # $DIR == ${PROJECTDIR}/.git/hooks
log () {
echo -e "\e[90m[`date -u +"%Y-%m-%dT%H:%M:%SZ"`]\e[39m - \e[36m$FILENAME\e[39m - $1"
@rjz
rjz / handler.go
Last active March 26, 2024 23:40
Handle Github webhooks with golang
// Now available in package form at https://github.com/rjz/githubhook
package handler
// https://developer.github.com/webhooks/
import (
"crypto/hmac"
"crypto/sha1"
"encoding/hex"
"errors"
@sebmarkbage
sebmarkbage / Enhance.js
Last active January 31, 2024 18:33
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@gr0uch
gr0uch / errors.js
Last active August 29, 2015 14:14
Custom typed errors in ES6
// Hello. There is now a module for this.
// https://github.com/0x8890/error-class
// $ npm install error-class
const hasCaptureStackTrace = 'captureStackTrace' in Error
// Internal function to set up an error.
function setup (message) {
const { constructor, constructor: { name } } = this
@rjz
rjz / getflow.sh
Last active August 29, 2015 14:10
Linux installer for flow
#!/bin/sh
# Linux x64 install for Facebook's flow JS type checker (flowtype.org). Flow
# will be installed to the local directory, replacing any previous versions
# placed here by this script.
ZIP=flow-linux64-latest.zip
URL=http://flowtype.org/downloads/$ZIP
BINDIR=flow
@antonmedv
antonmedv / Flyspeck.js
Last active November 26, 2019 07:01
Simple and Small Dependency Injection Container inspired by Pimple.
/*
* Flyspeck is Dependency Injection Container.
*
* Copyright (c) 2014 Anton Medvedev
*
* 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