Skip to content

Instantly share code, notes, and snippets.

View brock's full-sized avatar
😎

Brock Angelo brock

😎
View GitHub Profile
@brock
brock / pg_extract.sh
Last active April 22, 2024 11:00
Extract all databases (or one by name) from a sql file created by pg_dumpall
#!/bin/bash
# extract all postgres databases from a sql file created by pg_dumpall
# this script outputs one .sql file for each database in the original .sql file
# unless you pass the name of a database in the dump
if [ $# -lt 1 ]
then
echo "Usage: $0 <postgresql sql dump> [dbname]" >&2
exit 1
fi
@brock
brock / nodereinstall.sh
Last active April 17, 2024 08:26
Complete Node Reinstall. I've moved this to a repo at http://git.io/node-reinstall
#!/bin/bash
# node-reinstall
# credit: http://stackoverflow.com/a/11178106/2083544
## program version
VERSION="0.0.13"
## path prefix
PREFIX="${PREFIX:-/usr/local}"
@brock
brock / psql-with-gzip-cheatsheet.sh
Last active April 10, 2024 10:53
Exporting and Importing Postgres Databases using gzip
# This is just a cheat sheet:
# On production
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz
# On local
scp -C production:~/database.sql.gz
dropdb database && createdb database
gunzip < database.sql.gz | psql database
@brock
brock / lock.scpt
Created January 19, 2015 16:46
AppleScripts to lock and unlock a macbook
tell application "System Events"
tell security preferences
set require password to wake to true
end tell
end tell
activate application "ScreenSaverEngine"
@brock
brock / gh.sh
Created February 26, 2012 16:59
Open Git Project in Github
# GH
# by Brock Angelo
# for Mac OSX & Unix
# https://gist.github.com/1917716
# Description: when you are on the command line and want to open your project in Github, just type "gh". Latest version opens the current branch on github as well.
#
# SETUP:
# 1. Copy this snippet to ~/bin/gh
# 2. Make it executable by running: chmod +x ~/bin/gh
# 3. From the command line, inside your project, type gh and the browser window will open.
@brock
brock / markdown-details-collapsible.md
Created July 17, 2019 19:48 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section with markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@brock
brock / aliascheck.sh
Last active March 19, 2020 04:17
Alias checker
#!/bin/zsh
# aliascheck by @brock
# Description: checks each zsh command and reminds you if you already have an alias for that command
# Instructions:
# copy aliascheck.sh to ~/bin/aliascheck
# chmod +x ~/bin/aliascheck
# uncomment or modify line 14 below to source your aliases
# add the following to your ~/.zshrc or zsh profile:
#
# preexec() { zsh $(which aliascheck) $1}
@brock
brock / gohome.xml
Created January 15, 2015 04:13
Go Home using Tasker
<TaskerData sr="" dvi="1" tv="4.6u3m">
<Profile sr="prof21" ve="2">
<cdate>1421280614090</cdate>
<edate>1421295126863</edate>
<id>21</id>
<mid0>19</mid0>
<nme>Go Home</nme>
<Event sr="con0" ve="2">
<code>3001</code>
<pri>0</pri>
@brock
brock / smt-mod.zsh-theme
Last active May 9, 2019 15:26
ZSH Theme
# -----------------------------------------------------------------------------
# FILE: smt-mod.zsh-theme
# DESCRIPTION: oh-my-zsh theme file, based on smt by Stephen Tudor
# AUTHOR: Brock Angelo
# VERSION: 0.1
# SCREENSHOT:
# -----------------------------------------------------------------------------
MODE_INDICATOR="%{$fg_bold[red]%}❮%{$reset_color%}%{$fg[red]%}❮❮%{$reset_color%}"
local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%}"
@brock
brock / groot.sh
Created July 17, 2014 20:37
GROOT - go to the "git root"
#!/bin/bash
# GROOT! v 1.0.0
# Install in your dotfiles, .bashrc, .zshrc or similar
# No more cd ../../../../.. to get to the root of a git project
# Running the command "groot" will look for the closest .git directory and take you there.
# Note that it doesn't traverse up the tree, it takes you directly to the directory with a .git in it...
# ...so the command `cd -` takes you back to where you were.
# Works with *some* submodules (depending on how your submodule was setup - as a file or a dir)
# If you are using submodules, you should be able to figure out how to modify this.