Skip to content

Instantly share code, notes, and snippets.

View brandonpittman's full-sized avatar

Brandon Pittman brandonpittman

View GitHub Profile
@brandonpittman
brandonpittman / about_scoring_project.rb
Last active December 25, 2015 23:39
My solution to the Greed Game for ruby_koans.
def score(dice)
total = 0
return 0 if dice.empty?
total += 1000 if dice.count(1) >= 3
total += 200 if dice.count(2) >= 3
total += 300 if dice.count(3) >= 3
total += 400 if dice.count(4) >= 3
total += 500 if dice.count(5) >= 3
total += 600 if dice.count(6) >= 3
total += 100 if dice.count(1) == 1 || dice.count(1) == 4
@brandonpittman
brandonpittman / getJavaScriptDate.coffee
Created November 6, 2013 00:04
Get %F strftime style date in JavaScript/CoffeeScript.
now = new Date()
year = now.getFullYear()
day = now.getDate()
month = now.getMonth()+1
console.log "#{year}-#{month}-#{day}"
@brandonpittman
brandonpittman / new_site.sh
Last active December 31, 2015 00:09
Quickly set up a web site project and include Bourbon, Neat and Bitters.
#!/bin/zsh
# This script assumes you're using @codekit-prepend to import dependencies.
mkdir $1
cd $1
mkdir coffee
mkdir css
mkdir sass
mkdir js
{
"bold_folder_labels": true,
"color_scheme": "Packages/Theme - Spacegray/base16-ocean.dark.tmTheme",
"font_size": 18,
"open_files_in_new_window": false,
"show_encoding": true,
"show_line_endings": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"theme": "Spacegray.sublime-theme"
@brandonpittman
brandonpittman / readFile.js
Created January 23, 2014 07:04
read file with node.js
fs.readFile('test.md', {encoding: 'UTF-8'},function (err, data) {
if (err) throw err;
console.log(data);
});
@brandonpittman
brandonpittman / appendFile.js
Created January 23, 2014 07:04
append to file with node.js
fs.appendFile('test.md', "data to append part 2", function (err) {
if (err) throw err;
console.log('The "data to append" was appended to file!');
});
@brandonpittman
brandonpittman / popclip2iterm.applescript
Created February 21, 2014 14:10
Send Popclip text to iTerm 2 and execute
tell application "iTerm"
make new terminal
tell the first terminal
activate first session
launch session "Default Session"
tell the last session
write text "{popclip text}"
end tell
end tell
end tell
@brandonpittman
brandonpittman / remove_reminded.sh
Created February 22, 2014 10:25
Remove @REMINDED tags from nvremind
#!/bin/zsh
cd ~/Dropbox/Documents/Markdown
grep -rl '@reminded' ./ | xargs sed -i '' -E 's/@reminded.+$//g'
@brandonpittman
brandonpittman / incomplete_inbox_tasks.applescript
Created February 26, 2014 00:01
Get count of incomplete inbox tasks in OmniFocus
tell application "OmniFocus"
tell default document
set incomplete to every inbox task where completed is false
count incomplete
end tell
end tell
@brandonpittman
brandonpittman / new_file_at_finder_window.applescript
Last active December 3, 2024 11:35
Creates a new file at location of front Finder window.
tell application "Finder"
set _question to display dialog "Please enter file name..." default answer "" with title "New File"
set _file to text returned of _question
set _target to target of front window as alias
set _path to POSIX path of _target
set full_name to quoted form of _path & _file
do shell script "touch " & full_name
end tell