Skip to content

Instantly share code, notes, and snippets.

View machuga's full-sized avatar

Matt Machuga machuga

View GitHub Profile
@quiver
quiver / iam-policy.json
Last active April 23, 2024 07:02
How to connect to Amazon RDS PostgreSQL with IAM credentials
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"rds-db:connect"
],
"Resource": [
"arn:aws:rds-db:region:account-id:dbuser:dbi-resource-id/database-user-name"
@buggymcbugfix
buggymcbugfix / catch-all.md
Last active October 11, 2017 15:02
Catch-all considered harmful?

Catch-all considered harmful?

I have been thinking about a potential source of bugs from catch-all pattern matches and would like to know your thoughts.

Motivation

Totality is usually a desirable property of a function and the catch-all can conveniently buy us totality. But at what price?

I have been indoctrinated that rigour goes above convenience (think along the lines of: "Once we indulge in the impurities of I/O, there is no redemption.")

I would like to evaluate the trade-offs between convenience for the programmer and a potential source of bugs.

@seansullivan
seansullivan / consume_kinesis.js
Last active June 30, 2021 18:58
Log Records from AWS Kinesis Stream with Node.js
const AWS = require('aws-sdk');
AWS.config.setPromisesDependency(require('Q').Promise);
const _ = require('lodash');
const moment = require('moment');
const kinesis = new AWS.Kinesis({region: 'us-east-1'});
const streamName = 'my-stream';

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@Startouf
Startouf / google_analytics_turbolinks5.js
Created August 20, 2016 22:09
Google Analytics for Turbolinks 5 (& Rails 5)
// Google Analytics code to work with Turbolniks 5
this.GoogleAnalytics = (function() {
function GoogleAnalytics() {}
GoogleAnalytics.load = function() {
var firstScript, ga;
window._gaq = [];
window._gaq.push(["_setAccount", GoogleAnalytics.analyticsId()]);
window._gaq.push(['_setAllowAnchor', true]);
@kevinelliott
kevinelliott / osx-10.11-setup.md
Last active April 10, 2022 15:47
Mac OS X 10.11 El Capitan Setup

Mac OS X 10.11 El Capitan

Custom recipe to get OS X 10.11 El Capitan running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.10 Yosemite setup recipe (as found on this gist https://gist.github.com/kevinelliott/0726211d17020a6abc1f). Note that I expect this to change significantly as I install El Capitan several times.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your own needs.

@gaearon
gaearon / slim-redux.js
Last active May 5, 2024 15:14
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@jacksonrayhamilton
jacksonrayhamilton / gist:6b89ca3b85182c490816
Last active February 18, 2018 05:23
Context coloring color schemes
(custom-theme-set-faces
'ample
'(context-coloring-level-0-face ((t :foreground "#bdbdb3")))
'(context-coloring-level-1-face ((t :foreground "#baba36")))
'(context-coloring-level-2-face ((t :foreground "#6aaf50")))
'(context-coloring-level-3-face ((t :foreground "#5180b3")))
'(context-coloring-level-4-face ((t :foreground "#ab75c3")))
'(context-coloring-level-5-face ((t :foreground "#cd7542")))
'(context-coloring-level-6-face ((t :foreground "#df9522")))
'(context-coloring-level-7-face ((t :foreground "#454545"))))
# Has your OS/FS/disk lost your data?
# cd to the directory containing your project repositories and run the command
# below. (It's long; make sure you get it all.) It finds all of your git repos
# and runs paranoid fscks in them to check their integrity.
(set -e && find . -type d -and -iname '.git' | while read p; do (cd "$(dirname "$p")" && (set -x && git fsck --full --strict)); done) && echo "OK"
# I have 81 git repos in my ~/proj directory and had no errors.
require 'digest/md5'
hash = {}
Dir.glob("**/*", File::FNM_DOTMATCH).each do |filename|
next if File.directory?(filename)
# puts 'Checking ' + filename
key = Digest::MD5.hexdigest(IO.read(filename)).to_sym
if hash.has_key? key