Skip to content

Instantly share code, notes, and snippets.

@johngraham262
johngraham262 / keybase.md
Created July 25, 2014 19:05
Keybase proof for Github

Keybase proof

I hereby claim:

  • I am johngraham262 on github.
  • I am johngraham262 (https://keybase.io/johngraham262) on keybase.
  • I have a public key whose fingerprint is ABE3 59D4 73A9 3AF5 2EA8 FF3C 0FEA 5C80 76E5 B222

To claim this, I am signing this object:

@johngraham262
johngraham262 / git_search_replace_bash
Last active August 29, 2015 13:56
Git grep is a great search too, but I often find myself wanting to git grep for a term and then *replace* it too. With the "gsr" command, you can type in a search_term and a replace_term and it will search-->replace all matches. It's case-sensitive too.
# gsr = Git Search Replace
gsr() {
search_string=$1
replace_string=$2
if [ -z $search_string ] || [ -z $replace_string ]
then
echo "-- Git Search & Replace (gsr)"
echo "-- usage: gsr search_string replace_string"
else
git grep -l $search_string | xargs sed -i '' "s/$search_string/$replace_string/g"
@johngraham262
johngraham262 / openx_bash_for_ios
Last active December 9, 2022 02:34
A simple bash script that will open a `.xcworkspace` if it exists in the current directory, otherwise a `.xcodeproj` if it exists, otherwise nothing. It will print the name of the file that is being opened. When using Cocoapods with iOS apps, a second file is created with the `MyProject.xcworkspace` name, alongside the `MyProject.xcproject` file…
# Add the following lines of code to your `~/.bash_profile`,
# and then run `source ~/.bash_profile` to be able to execute
# this from the command line.
openx() {
fileToOpen='';
for file in `find . -maxdepth 1 -name *.xcworkspace`; do
fileToOpen=$file
done