This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def convertTemp(temp, fs, ts) | |
@conversions ||= { | |
'C' => { | |
'C' => ->(t) { t }, | |
'F' => ->(t) { t * 9 / 5 + 32 }, | |
'K' => ->(t) { t + 273.15 }, | |
'R' => ->(t) { (t + 273.15) * 9 / 5 }, | |
'De' => ->(t) { (100 - t) * 3 / 2 }, | |
'N' => ->(t) { t * 33 / 100 }, | |
'Re' => ->(t) { t * 4 / 5}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User-Agent: curl/7.21.2 (x86_64-apple-darwin) | |
Host: localhost:8080 | |
Accept: */* | |
Content-Length: 1143 | |
Expect: 100-continue | |
Content-Type: multipart/form-data; boundary=----------------------------83ff53821b7c | |
------------------------------83ff53821b7c | |
Content-Disposition: form-data; name="img"; filename="a.png" | |
Content-Type: application/octet-stream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Flatten a hash's keys down and format them like http form data | |
# e.g. { user: { id: 1, posts: [{ name: 'test' }] }, debug: true } | |
# becomes | |
# { 'user[id]' => 1, 'user[posts][0][name]' => 'test', 'debug' => true } | |
def convert_params_to_form_data(params, form_data = {}, prefix = '') | |
bracketeer = ->(p, k) { "#{p}#{p.empty? ? '' : '['}#{k}#{p.empty? ? '' : ']'}" } | |
params.each_with_object form_data do |(key, value), form_data| | |
case value when Hash | |
convert_params_to_form_data value, form_data, bracketeer.call(prefix, key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.lastScroll = 0; | |
$(function() { | |
var lastSnap, isAnimating, | |
snaps = $(".snap-to"), | |
$window = $(window); | |
var heights = snaps.map(function() { | |
return $(this).offset().top; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
BLUE="\[\033[0;34m\]" | |
LIGHT_RED="\[\033[1;31m\]" | |
LIGHT_GREEN="\[\033[1;32m\]" | |
WHITE="\[\033[1;37m\]" | |
LIGHT_GRAY="\[\033[0;37m\]" | |
COLOR_NONE="\[\e[0m\]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
RED="\033[0;31m" | |
WHITE="\033[1;37m" | |
if git diff-index -p -M --cached HEAD | grep '#debug' > /dev/null; then | |
#echo 'debug lines found in commit. Aborting' >&2 | |
#exit 1 | |
echo "\n\t${RED}You left a debug comment in the code!${WHITE}\n" >&2 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
attachments: parent_id, asset_id | |
domain_names: organisation_id | |
event_memberships: user_id, event_id | |
events: editor_id | |
group_actions: user_id, group_id | |
groups: user_id | |
icons: parent_id | |
invitations: sender_id | |
legacy_actions: item_upon_id | |
news_items: author_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
named_scope :with_over_lapping_dates, lambda {|starting_date, ending_date| {:conditions => ["? BETWEEN `start_date` AND `end_date` OR ? BETWEEN `start_date` AND `end_date`", starting_date, ending_date]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DasSpoofenSpleiza | |
def initialize(product_id) | |
@product = Product.find product_id, :include => :variants | |
end | |
def filter | |
start = Time.now | |
puts "\nGetting all order_items for product #{@product.id}..." | |
order_items = OrderItem.all({ | |
:joins => [:order], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ROUTES = { | |
"GET /" => ["RootController", :show], | |
"GET /home" => ["HomeController", :index], | |
"GET /posts/:slug/comments/:id/edit" => ["CommentsController", :edit], | |
"POST /posts/:slug/comments" => ["CommentsController", :create], | |
"PUT /posts/:slug" => ["PostsController", :update] | |
} | |
router = Router.new ROUTES |