Skip to content

Instantly share code, notes, and snippets.

@ryanemmm
ryanemmm / git-retag.bash
Last active May 22, 2023 17:34
move a git tag to HEAD
# bash/zsh
##
# git-retag.bash
# ** you're proabably not supposed to do this **
# move an existing tag from <old commit> to HEAD
#
# use it like this: `retag <tagname>`
#
@ryanemmm
ryanemmm / pimp_prompt.sh
Created September 15, 2019 18:31 — forked from jamiew/pimp_prompt.sh
put this in your .bashrc/.bash_profile... works with both git and svn
parse_git_branch() {
ref=$(git symbolic-ref -q HEAD 2> /dev/null) || return
printf "${1:-(%s)}" "${ref#refs/heads/}"
}
parse_svn_revision() {
local DIRTY REV=$(svn info 2>/dev/null | grep Revision | sed -e 's/Revision: //')
[ "$REV" ] || return
[ "$(svn st)" ] && DIRTY=' *'
echo "(r$REV$DIRTY)"
@ryanemmm
ryanemmm / stuff-i-forget
Last active April 17, 2019 21:41
stuff i always forget and have to google for
# git: delete local + remote tag
git tag -d TagName && git push origin :refs/tags/TagName
# git: checkout file from a different branch
git checkout <branch_name> -- <paths>
http://nicolasgallagher.com/git-checkout-specific-files-from-another-branch/
# vim: find instances of uncommented out console statements
search mode / then \(\/\/.*\)\@<!console
@ryanemmm
ryanemmm / angularjs_coinbase_button
Last active February 27, 2018 02:05
Implement coinbase button (html + js tag) in Angularjs view
# Used a directive to inject a 'hook' element
# + javascript tag that consumes/acts on said
# 'hook' via an anon, self-exececuting fn that
# fires when the script loads.
#
# The problem this solves is a race condition
# where the javascript executes prematurely
# and throws a SAMEORIGIN error.
<!-- html/directive call -->
@ryanemmm
ryanemmm / toggle-vpn
Created April 29, 2017 18:02
toggle vpn connection from spotlight/launcher cuz I'm lazy
# adapted from: https://gist.github.com/adgedenkers/3874427
# VPN_NAME is the name of your vpn
-- adapted from https://gist.github.com/adgedenkers/3874427
tell application "System Events"
-- start playing with the VPN
tell current location of network preferences
-- set the name of the VPN service from your Network Settings
set VPNService to service "VPN_NAME"
-- determine current VPN connection status
@ryanemmm
ryanemmm / bouncewifi
Last active December 28, 2015 19:29
turns wifi off, then on.
#AppleScript
#- bounce wifi: turn it off, then turn it on
#- open AppleScript Editor, paste lines 4,5,6, save as application
#- ** oh be sure to set the network_device -- en0 in my case to the correct interface
set network_device to "en0"
do shell script "networksetup -setairportpower " & network_device & " off"
do shell script "networksetup -setairportpower " & network_device & " on"
@ryanemmm
ryanemmm / per_app_bundler_local_path
Created September 6, 2013 01:31
Was pointed to http://ryanbigg.com/2013/08/bundler-local-paths/ but I wanted "per app" local paths: i.e. App1 uses local.gem but App2 uses the default
# Original from http://ryanbigg.com/2013/08/bundler-local-paths/
> bundle config local.spree ~/Projects/gems/spree
- creates ~/.bundle/config
- which is used by all projects/apps
# Per app
> bundle config --local local.gem "path/to/local/gem"
- note: I had to manually cd into project/app directory to get this to create the file at 'app/.bundle/config'
# from: http://blog.pivotal.io/labs/labs/a-simple-way-to-detect-unused-files-in-a-project-using-git
# `git ls-files` -> get a list of files from a directory
# `git grep` + loop -> check for reference to file in repo
# list or remove the file
# dry run: just list the unused files
for FILE in $(git ls-files ./img); do
git grep $(basename "$FILE") > /dev/null || echo "would remove $FILE"
done
@ryanemmm
ryanemmm / bouncebluetooth
Created November 21, 2014 20:34
bounce bluetooth (trying to reconnect mouse)
#bounce bluetooth
set unload to "kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport"
set load to "kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport"
do shell script unload with administrator privileges
do shell script load with administrator privileges
@ryanemmm
ryanemmm / atm_to_psi
Created September 14, 2014 09:38
atmospheres to psi conversion
atm = psi
============
1.0 = 14.696
1.1 = 16.166
1.2 = 17.635
1.3 = 19.105
1.4 = 20.574
1.5 = 22.044
1.6 = 23.514
1.7 = 24.983