Skip to content

Instantly share code, notes, and snippets.

View bloudermilk's full-sized avatar

Brendan Loudermilk bloudermilk

View GitHub Profile
jruby-1.7.10
[
{
"repo":{
"id":11757750,
"owner":"facebook",
"name":"huxley",
"url":"https://github.com/facebook/huxley",
"homepage":null,
"language":"Python",
"description":"Watches you browse, takes screenshots, tells you when they change."
def input_get
input = gets.chomp
sum[i] = input.to_i
end
def sum
sum = []
i = 0
puts input_get
@bloudermilk
bloudermilk / yield.rb
Last active August 29, 2015 13:58
Example of yield in ruby
def my_fancy_method
# Call the block with 1
yield 1
# Call the block with "cat"
yield "cat"
# Call the block with nothing (i.e. nil)
yield
end
@bloudermilk
bloudermilk / date.coffee
Created February 20, 2010 22:13
Javascript Date prototypes for finding the beginning and end of days and weeks. Beginning of the week is defined as Sunday
Date::beginningOfMonth = ->
beginningOfMonth = @beginningOfDay()
beginningOfMonth.setDate(1)
beginningOfMonth
Date::endOfMonth = ->
endOfMonth = @endOfDay()
endOfMonth.setMonth(endOfMonth.getMonth() + 1)
endOfMonth.setDate(0)
endOfMonth
@bloudermilk
bloudermilk / gist:1235737
Created September 22, 2011 19:19
CoffeseSript + Mongoose
BootModel = Mongoose.model "Boot", new Schema
laces: Number
tied: Boolean
class Boot extends BootModel
boot = new Boot
boot.laces = 4
boot.tied = true
@bloudermilk
bloudermilk / overflow.html
Created November 27, 2011 10:52
Overflow example for a SO question
<!DOCTYPE HTML>
<html>
<head>
<title>Overflow!</title>
<style type="text/css">
#outer {
height: 200px;
position: relative;
overflow: hidden;
background-color: red;
@bloudermilk
bloudermilk / explorer.rb
Created May 2, 2012 04:35
DCell Explorer Problem
require 'dcell/explorer'
DCell::Explorer.supervise("127.0.0.1", 8000)
@bloudermilk
bloudermilk / gist:3147421
Created July 19, 2012 22:52
Lein (uber)jar fails
projects $ lein -v
Leiningen 2.0.0-preview7 on Java 1.6.0_33 Java HotSpot(TM) 64-Bit Server VM
projects $ lein new test
Generating a project called test based on the 'default' template.
To see other templates (app, lein plugin, etc), try `lein help new`.
projects $ cd test/
projects $ vim project.clj
test $ cat project.clj
(defproject test "0.1.0-SNAPSHOT"
:description "FIXME: write description"
@bloudermilk
bloudermilk / admin.rb
Created August 8, 2012 23:03
Stupid-simple invitations with Devise
class Admin < ActiveRecord::Base
attr_accessor :invite
devise :database_authenticatable, :registerable, :recoverable, :rememberable,
:trackable, :validatable
def self.new_invited(attributes)
new(attributes.merge(invite: true))
end