Skip to content

Instantly share code, notes, and snippets.

@sealabcore
sealabcore / application.rb
Created July 25, 2014 23:21
Yo Source Code.
def yo
send_push_notification("Yo")
end
def dispense_change(cents)
change = { "quarters" => 0, "dimes" => 0, "nickels" => 0, "pennies" => 0 }
number_of_quarters = cents / 25
if number_of_quarters > 0
change["quarters"] = number_of_quarters
end
cents = cents % 25
@sealabcore
sealabcore / fibonacci.rb
Created March 3, 2014 04:46
Fibonacci implemented in ruby.
def fibonacci(initial, limit = 100)
sum = initial[-1] + initial[-2]
initial << sum
if sum < limit
fibonacci(initial)
else
initial
end
end
@sealabcore
sealabcore / entrancemusic.js
Created August 19, 2011 18:21
Campfire Propane Entrance and Exit Music With Gifs
/*
Play entrance music
*/
/* defining a new responder is probably the best way to insulate your hacks from Campfire and Propane */
Campfire.EntranceMusician = Class.create({
initialize: function(chat) {
this.chat = chat;
Delivered-To: mike.taylor.4@gmail.com
Received: by 10.229.219.3 with SMTP id hs3cs265930qcb;
Wed, 21 Jul 2010 11:15:58 -0700 (PDT)
Received: by 10.100.4.5 with SMTP id 5mr643369and.160.1279736156554;
Wed, 21 Jul 2010 11:15:56 -0700 (PDT)
Return-Path: <bounces+11348-2b2d-mike.taylor.4=gmail.com@e2.kickstarter.com>
Received: from o2.e2.kickstarter.com (o2.e2.kickstarter.com [74.63.202.49])
by mx.google.com with SMTP id s1si17692517anc.34.2010.07.21.11.15.55;
Wed, 21 Jul 2010 11:15:55 -0700 (PDT)
Received-SPF: pass (google.com: domain of bounces+11348-2b2d-mike.taylor.4=gmail.com@e2.kickstarter.com designates 74.63.202.49 as permitted sender) client-ip=74.63.202.49;
def initialize(email=nil, password=nil)
05 @host = 'http://www.tumblr.com'
06 @action = '/login'
07 login(email, password) if email and password
08 end
09
10 def login(email, password)
11 res = Net::HTTP.post_form(URI.parse(@host+@action),{'email'=> email, 'password'=> password })
12 case res
13 when Net::HTTPSuccess
class CommentsController < ApplicationController
include ApplicationHelper, StageHelper, CommentsHelper
before_filter :login_required
before_filter :setup_current_user
def create
case params[:type]
when "Photo"
def self.hot_objects(type, date)
objects = Photo.find_by_sql("SELECT id, title, points_count, filename, parent_id, sum(score) as fame FROM (
SELECT photos.id, photos.title, photos.points_count, photos.filename, photos.parent_id,
COUNT(photos.id) * 5 as score
FROM `photos` LEFT JOIN comments ON comments.commentable_id = photos.id AND comments.commentable_type = 'Photo' AND photos.user_id != comments.user_id AND `photos`.`parent_id` IS NULL
WHERE (comments.created_at > '#{date}') GROUP BY photos.id
UNION
SELECT photos.id, photos.title, photos.points_count, photos.filename, photos.parent_id,
COUNT(photos.id) / 2 as score
body
{
background-color:black;
color:white;
font-family: Georgia, serif;
font-size: 16px;
font-style: normal;
font-weight: normal;
text-transform: normal;
letter-spacing: normal;
<script language="javascript">
function checkScroll(url) {
if (nearBottomOfPage()) {
currentPage++;
new Ajax.Request(url+'page='+currentPage, {asynchronous:true, evalScripts:true, method:'get'});
} else {
setTimeout("checkScroll('"+url+"')", 250);
}
}
document.observe('dom:loaded', checkScroll);