Skip to content

Instantly share code, notes, and snippets.

View coryschires's full-sized avatar
💭
Code King

Cory Schires coryschires

💭
Code King
View GitHub Profile
@coryschires
coryschires / moment-timezone-data.js
Created August 14, 2013 22:04
TZInfo mapping between Rails and moment.js
moment.tz.add({
"zones": {
"Africa/Algiers": [
"0:12:12 - LMT 1891_2_15_0_1 0:12:12",
"0:9:21 - PMT 1911_2_11 0:9:21",
"0 Algeria WE%sT 1940_1_25_2",
"1 Algeria CE%sT 1946_9_7 1",
"0 - WET 1956_0_29",
"1 - CET 1963_3_14 1",
"0 Algeria WE%sT 1977_9_21 1",
@coryschires
coryschires / test.rb
Created August 4, 2013 22:35
Test gist
def height
rows_in_legend = (editors.size.to_f / 6.to_f).ceil
case rows_in_legend
when 1 then 580
when 2 then 722
when 3 then 870
when 4 then 1020
else 1160
end
end
file_field.fileupload
dataType: 'xml'
fileInput: file_input
url: "#{document.location.protocol}//s3.amazonaws.com/#{opts.as3.bucket}"
add: (e, data) ->
data_context = data
file_name_wrapper.show().text(get_file_name(data)) if file_valid(data)
send: (e, data) ->
file_name_wrapper.fadeOut 300, -> progress_bar.fadeIn()
progress: (e, data) ->
# Assumes your `days` method will return an array of hashes where the
# key specifies the month number (i.e. 1-12) and the value is an array
# containing the days of the month (i.e. 1-31) when the streets will
# be cleaned.
#
# Following that scheme then your data might looks something like:
#
# [
# 1: [7, 8], # January 7th and 8th
# 2: [2, 4],
# Assumes your `days` method will return an array of hashes where the
# key specifies the month number (i.e. 1-12) and the value is an array
# containing the days of the month # (i.e. 1-31) when the streets will
# be cleaned.
#
# Following that scheme then your data might looks something like:
#
# [
# 1: [7, 8], # January 7th and 8th
# 2: [2, 4],
def test
puts "alkjdfalkjf"
end
first = 0
last = 1000
total = 0
multipules = []
# build the array of multipules
(first..last).each do |list|
if (list % 5 == 0) or (list % 3 == 0)
multipules.push(list)
end
print "What is your start year? "
start = gets.chomp.to_i
print "What is your finish year? "
finish = gets.chomp.to_i
while finish > start
puts finish -= 1
end
@coryschires
coryschires / beer.rb
Created May 7, 2012 20:16
Bottle of beer examples
bottle_num = 100
# You can clean up the the puts statement using interpolation (i.e. "Some words #{a_variable} and more words")
#
while bottle_num > 0
puts "#{bottle_num -= 1} bottles of beer on the wall"
end
# Or you could even one line it.
#
@coryschires
coryschires / html-email-styles.html
Created May 2, 2012 20:49
html-email-styles.html
<h1>A better way to manage HTML emails with Ruby on Rails</h1>
<p>With Transis Planner nearly completed, we're starting to focus on the finer details, making sure everything's nicely polished and ready for launch. Among other things, this means creating great looking HTML emails. After all, Planner is a collaboration tool. Our users will be working together to hammer out effective media plans, and that means we'll be sending lots of media briefs, insertion orders, and so on.</p>
<p>Sending multipart emails (i.e. HTML and plain text) with Rails is very straight forward. Just write a mailer action and create two corresponding view templates &mdash; one with an `.html` extension and one with a `.text` extension. But this method has a few shortcomings:</p>
<ul>
<li>You end up duplicating text (and probably logic) since you need to create both a `.text` and `.html` template.</li>
<li>Emails are a total pain to style. In the process, you'll lay waste to all sorts of web standards &mdash; using table-based la