Skip to content

Instantly share code, notes, and snippets.

View TSMMark's full-sized avatar
🐶

Mark Allen TSMMark

🐶
View GitHub Profile
@TSMMark
TSMMark / s3.rb
Last active March 4, 2022 20:17
Process a remote CSV with SmarterCSV (also example with Paperclip and Amazon S3 AWS)
# this is the code I used to determine the csv_path to use when using Paperclip with Amazon S3 AWS
# necessary because my development environment doesn't upload to S3
# get an object that has_attachment with Paperclip
object = ModelWithPaperclip.last
# use url if no file exists at path
csv_path = File.exists?(object.csv.path) ? object.csv.path : object.csv.url
# this should probably be implemented as a model method
def sent?
self.status == "sent"
end
@TSMMark
TSMMark / Delegator.js
Created October 7, 2014 16:48
Demplate
var $ = require("jQuery")
, Delegator
;
Delegator = function () {
this.$el = $("<p/>");
}
// Add a function to the object that delegates to a property on the same object.
//
@TSMMark
TSMMark / basic_pasta_spec.rb
Last active August 29, 2015 14:18
pasta spec examples
describe Pasta do
describe "#sauce_name" do
describe "when initialized with sauce_type = 2" do
let(:pasta) { Pasta.new(2) }
it "returns \"pesto\"" do
assert_equal(pasta.sauce_name, "pesto")
end
end
end
@TSMMark
TSMMark / main.md
Last active August 29, 2015 14:21
Heading Anchors in GFM

Single hash

[Link to the Single hash](#single-hash).

Link to the Single hash.

Double hash (with parens)

[Link to the Double hash with parens](#double-hash-with-parens).

@TSMMark
TSMMark / Preferences.sublime-settings
Created October 27, 2015 16:27
SublimeText 3 settings
{
"auto_find_in_selection": true,
"enable_tab_scrolling": false,
"ensure_newline_at_eof_on_save": true,
"font_size": 13,
"ignored_packages":
[
"Vintage"
],
"margin": 4,
@TSMMark
TSMMark / main.rb
Created December 14, 2015 21:58
Ruby Object send
class Person
def call_mom!
puts "I just called mom."
end
def wash_car!
puts "I just washed my car."
end
@TSMMark
TSMMark / .bash_profile
Last active March 7, 2016 21:22
.bash_profile
### http://git-prompt.sh/
source ~/.git-prompt.sh
### Set PS1
export PS1="[\[\033[32m\]\w\[\033[0m\]]\$(__git_ps1)\n\[\033[1;36m\]\u\[\033[32m\]$ \[\\033[0m\]"
export PATH=/usr/local/bin:~/bin:$PATH
### Set SublimeText as default editor
ln -sf "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
@TSMMark
TSMMark / .bash_profile
Created February 22, 2016 16:14
Vagrant .bash_profile
### http://git-prompt.sh/
source ~/.git-prompt.sh
### Set PS1
export PS1="[\[\033[32m\]\w\[\033[0m\]]\$(__git_ps1)\n\[\033[1;36m\]\u@vagrant\[\033[32m\]$ \[\\033[0m\]"
export PATH=/usr/local/bin:~/bin:$PATH
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# http://mediadoneright.com/content/ultimate-git-ps1-bash-prompt
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
alias g-delete-all-branches-except-master="git branch | grep -v "master" | xargs git branch -D"