Skip to content

Instantly share code, notes, and snippets.

@mabenson00
mabenson00 / cheatsheet.rb
Last active June 28, 2024 17:24
Rails ActiveRecord JSON cheatsheet
# Basic key operators to query the JSON objects :
# #> : Get the JSON object at that path (if you need to do something fancy)
# -> : Get the JSON object at that path (if you don't)
# ->> : Get the JSON object at that path as text
# {obj, n} : Get the nth item in that object
# https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE
# Date
# date before today
@bennylope
bennylope / migrate.py
Last active July 18, 2023 05:43
PostgreSQL migration script, Heroku -> Crunchy
#!/usr/bin/env python
import argparse
import os
import subprocess
import sys
import time
# Required so we don't generate tons of logs during restore
disable_logging_sql = "ALTER USER postgres RESET pgaudit.log;"
@r00k
r00k / retro-questions.md
Last active May 27, 2022 21:59
Helpful retrospective (retro) questions

Retro Questions

  • KPI dashboard review
  • Since our last retro, what's gone well?
  • How do we feel about our productivity and work/life balance
  • How is the product better than last week?
  • How is the company better than last week?
  • Is there anything we should ask a consultant about?
  • How is the office/ops?
  • How can we enjoy the journey more?

The 5-minute backpack demo

Here's what I carry in a Tom Bihn Synapse 19 bag when I travel for 1-to-n days. In general, I optimize for low-weight items, with a secondary focus on reducing maintenance. You can peruse a gallery of pictures, too.

Clothing

@solarce
solarce / getting_more_familiar_with_go_resources.md
Last active June 19, 2017 13:54
A list of resources for getting more familiar with Go

Getting more familiar with Go

@sax
sax / load_data.sh
Last active February 16, 2017 11:18
Dump and reload data into PostgreSQL with massive concurrency
# interpolated load tables step
find . -type f -print0 | xargs -0 -n1 -P50 bash -c "psql -U <postgres_user> <mydatabase> < \$0"
@rantav
rantav / cloudwatch-event-to-slack-lambda.md
Last active January 14, 2021 03:18
CloudWatch Events to Slack

Sends Cloudwatch Event notifications to Slack

What is this?

AWS have released a new featue called CloudWatch Events, which lets you configure events fired by cloudwatch and direct them to SNS, Lambda functions, etc. Here's the blog post

Motivational image:

Here's the motivational image:

Slack image

@beanieboi
beanieboi / gist:ad526faf063181f336a2
Last active May 11, 2023 15:59
Codeship Nginx Config for Heroku
daemon off;
# Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;
events {
use epoll;
accept_mutex on;
worker_connections 1024;
}
@JoshCheek
JoshCheek / quiz.md
Last active August 29, 2015 14:17
HTTP quiz!

Quiz time!

  • What does the dot mean in in StringIO.new, what does the hash mean in StringIO#puts?
  • How do you make a String literal?
  • How do you make a String without using a literal?

This is an HTTP request, it is a String that is sent across a Socket, which your program can read from as if it were a file or $stdin.

01 POST /users/5?omg=wtf&amp;bbq=lol HTTP/1.1\r\n
@darron
darron / gist:811cf41a6ec3dbfcb97a
Created January 5, 2015 23:19
Get IP Ranges from EC2
#!/bin/bash
# You need: curl, jq, and ipcalc to run this.
# You should already have cut, sort and uniq if you're on OS X or Linux.
RANGES=$(curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq .prefixes | jq '.[] | select(.region=="us-east-1")' | jq 'select(.service=="EC2")' | jq .ip_prefix | cut -d '"' -f 2 | sort | uniq)
for range in $RANGES
do
MIN=$(ipcalc -bn $range | grep "HostMin" | cut -d ':' -f 2)