Skip to content

Instantly share code, notes, and snippets.

View Ajwah's full-sized avatar

Kevin Johnson Ajwah

  • Toronto, Canada
View GitHub Profile
@Ajwah
Ajwah / remove_brew-mongo_osx.sh
Created January 14, 2016 22:41 — forked from katychuang/remove_brew-mongo_osx.sh
remove mongodb that was installed via brew
#!/usr/bin/env sh
# checks to see if running
launchctl list | grep mongo
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
launchctl remove homebrew.mxcl.mongodb
pkill -f mongod
@Ajwah
Ajwah / meteor.js
Created October 23, 2015 22:41
Meteor in vagrant symlink
Symlinking the .meteor/local directory to a non-shared directory worked for me.
Removing the existing .meteor/local locally:
cd $MY_APP_DIR
cp -R .meteor .meteor.bak
rm -R .meteor/local
Then from within the vagrant vm:
mkdir -p /home/vagrant/.meteorlocal
@Ajwah
Ajwah / .gitconfig
Created October 7, 2015 22:42
configurations for git and helpful commands
[alias]
lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"
-------------
git blame name_file
git stash
git stash pop
sudo service postgresql restart
@Ajwah
Ajwah / rebase
Created October 6, 2015 22:15
Update premature commit on remote with more changes
Commit the extra changes you want.
You now have newest commit and commit you want to update.
git log -> determine id of commit right before the commit you want to update. 0e841350
git rebase --interactive 0e841350^ (The ^ is to tell you want to combine)
--> change entry to s/squash to indicate the one you want to merge in the previous one.
Safe the file
--> new window opens with opportunity to change git commit message
Save and then push to remote:
git push --force origin master
@Ajwah
Ajwah / gist:44104badf978363aeb08
Created September 26, 2015 20:05 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@Ajwah
Ajwah / sin_number.rb
Created September 23, 2015 22:23
Regex practice on SIN numbers
require 'pry'
# Determine whether a string contains a SIN (Social Insurance Number).
# A SIN is 9 digits and we are assuming that they must have dashes in them
def has_sin?(string)
/\b\d{3}-\d{3}-\d{3}\b/.match(string) != nil
end
puts "has_sin? returns true if it has what looks like a SIN"
puts has_sin?("please don't share this: 234-604-142") == true
@Ajwah
Ajwah / yield.rb
Created September 23, 2015 19:25
implement usage of yield for benchmark method
def benchmark
start_time = Time.now
yield
end_time = Time.now
running_time = end_time - start_time
end
long_string = "apple" * 100000000
running_time = benchmark { long_string.reverse }
@Ajwah
Ajwah / bottles.rb
Created September 23, 2015 16:52
Recycling Bottles
def redeem(dollar_amount)
bottles_amount = dollar_amount / 2
recycle_bottles = bottles_amount / 2
recycle_caps = bottles_amount / 4
recycle_total = recycle_bottles + recycle_caps
bottles_remaining = bottles_amount % 2
caps_remaining = bottles_amount % 4
[" Dollar Amount: #{dollar_amount}",
" Total Amount Bottles Purchased: #{bottles_amount}",
@Ajwah
Ajwah / roman_numerals.rb
Last active September 23, 2015 18:56
Implement Roman Numerals Exercise
module Romans
CONVERSIONS = {
1 => 'I',
4 => 'IV',
5 => 'V',
9 => 'IX',
10 => 'X',
40 => 'XL',
50 => 'L',
90 => 'XC',