Skip to content

Instantly share code, notes, and snippets.

View marcusshepp's full-sized avatar
🎯
Focusing

Marcus Shepherd marcusshepp

🎯
Focusing
View GitHub Profile
@marcusshepp
marcusshepp / sugar.js
Last active June 6, 2016 13:06
syntactic sugar
// http://codegolf.stackexchange.com/questions/2682/tips-for-golfing-in-javascript?lq=1
var test = "hw";
(() => test)(); // >> "hw"
@marcusshepp
marcusshepp / list_remotes.sh
Created June 6, 2016 13:34
List remote branches
## list all local and remote branches
git branch -a
## list only remote branches
git branch -r
@marcusshepp
marcusshepp / terminal.md
Last active June 6, 2016 15:41
Terminal and iTerm Tricks
  • delete a word backword - ctrl + w
  • move between words
    • move back one word: ESC + b
    • move forward one word: ESC + f
    • terminal only !(iTerm):
  • option + left-right-arrow
@marcusshepp
marcusshepp / open.sh
Created June 6, 2016 19:32
opening files from terminal
# -a lets you pass an application name to open with
open -a TextEdit ~/path/to/foo.txt
# -e will open the file in TextEdit
open -e ~/path/to/foo.txt
# -t opens the file with the default text editor
open -t ~/path/to/foo.txt
@marcusshepp
marcusshepp / amp_eq.rb
Last active June 9, 2016 12:48
Ampersand Equal
a, b = 1, 2
a &= b
# is the same as
a = a & b
# does a bitwise `and`
x = true
x = "foo"
# => :foo
x == :foo
# => true
x = @foo
# => @foo
x.to_sym
# => :@foo
x == :@foo
# => true
@marcusshepp
marcusshepp / rindex.rb
Last active June 13, 2016 13:31
rindex
# returns last index of occurance
s = "marcus shepherd"
x = s.rindex(" ")
# => 6
s[0..x-1]
# => "marcus"
s[x+1..s.length]
# => "shepherd"
# returns the first element that returns `true` after being passed to `block`
x = [1, 2, 3]
x = x.detect{|i| i > 1}
# => 2
x == 2
# => true
@marcusshepp
marcusshepp / firefox.css
Created June 16, 2016 13:44
targeting firefox only
@-moz-document url-prefix(){
.foo{
color: blue;
}
}
@marcusshepp
marcusshepp / time_since.py
Created June 18, 2016 23:47
time since object creation
class DateCreatedAndUpdate(models.Model):
"""
Abstract class used to populate childern with a `date_created` field
"""
class Meta:
abstract, ordering = True, ("-id",)
date_created = models.DateTimeField(auto_now_add=True)
date_updated = models.DateTimeField(auto_now=True)
def time_past_since_creation(self):