Skip to content

Instantly share code, notes, and snippets.

View aks's full-sized avatar
💭
Working

Alan Stebbens aks

💭
Working
View GitHub Profile
@aks
aks / clear-sidekiq-jobs.sh
Created August 9, 2018 19:39 — forked from wbotelhos/clear-sidekiq-jobs.sh
Clear Sidekiq Jobs
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
Sidekiq::ScheduledSet.new.clear
# 3. Clear 'Processed' and 'Failed' jobs
@michaelstephens
michaelstephens / asdf.sh
Created July 9, 2018 18:29
ASDF Start Script
function asdf() {
case $1 in
"start")
case $2 in
"psql"|"postgres")
pg_ctl -D `asdf where postgres $(asdf current postgres)`/data start > /dev/null 2>&1
echo "[STARTED] Postgres `asdf current postgres`"
;;
"redis"|"redis-server")
`asdf which redis`-server /usr/local/etc/redis.conf
@aks
aks / thor-template.rb
Created February 23, 2018 22:03
A template for a new ruby thor-based command-line utility
#!/usr/bin/env ruby
#
# THOR template
$PROG = File.basename($PROGRAM_NAME)
$DIR = File.dirname($PROGRAM_NAME)
# Possibly modify the LOAD_PATH
# $LOAD_PATH << File.join(__dir__, '..', 'lib/migrations')
@aks
aks / install-pre-push-hook.sh
Created July 20, 2017 17:16
Bash script to install a `pre-push-hook` into the current git repo
#!/usr/bin/env bash
# install-pre-push-hook
# this script installs the pre-push hook into the current .git repo.
# by default, the pre-push hook protects the "master" branch.
set_git_hooks_dir_path() {
set_git_dir_path
git_hooks_dir_path="$git_dir_path/hooks"
if [[ ! -d "$git_hooks_dir_path" ]] ; then
echo 1>&2 "$git_hooks_dir_path does not exist!"
exit
@colinvh
colinvh / aws.md
Last active November 15, 2024 13:07
AWS Region Names

Alternative naming schemes for AWS regions

Purpose

The intent is to define terse, standards-supported names for AWS regions.

Schemes

# for use by collection_select and friends, to link a human-readable label with a db-friendly symbolic value
# todo: ActiveRecord macros for setters (for allowing multiple values or just one)
# Usage:
# Table name: snacks
# id :integer
# ice_cream :string
# class Snack < ActiveRecord::Base
# FLAVORS = Enum.new [
# [:vanilla, "Vanilla"],
# [:chocolate, "Chocolate"],
@messanjah
messanjah / structure_in_conflict
Last active January 21, 2019 14:16
Steps to commit a cleanly merged db/structure.sql file
Dealing with conflicts to db/structure.sql (when merging master)
$ git checkout master
# Change database.yml to point to database: clean (on localhost) in development env
# In one command:
# 1) drops the database specified in database.yml for current env ('clean' database)
# 2) creates a db with name specified in database.yml
# 3) loads master's structure into the database specified in database.yml
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active November 17, 2024 13:10
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@thwarted
thwarted / sshpub-to-rsa
Created June 14, 2011 09:12
converts an openssh RSA public key into a format usable by openssl rsautl (if you don't have openssh 5.6 or later with ssh-keygen PEM export format)
#!/usr/bin/env python
# with help and inspiration from
# * ASN1_generate_nconf(3) (specifically the SubjectPublicKeyInfo structure)
# * http://www.sysmic.org/dotclear/index.php?post/2010/03/24/Convert-keys-betweens-GnuPG%2C-OpenSsh-and-OpenSSL
# * http://blog.oddbit.com/2011/05/converting-openssh-public-keys.html
import sys
import base64
import struct