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
module Vigenere | |
def self.encrypt(key, phrase) | |
exec key, phrase | |
end | |
def self.decrypt(key, phrase) | |
exec key, phrase, -1 | |
end | |
def self.exec(key, phrase, direction=1) |
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
module Palindrome | |
def self.palindrome?(n) | |
n == reverse(n) | |
end | |
def self.reverse(n) | |
rs = 0 | |
while n > 0 | |
n, r = n.divmod 10 | |
rs = rs * 10 + r |
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
;; emacs configuration | |
(push "/usr/local/bin" exec-path) | |
(add-to-list 'load-path "~/.emacs.d") | |
(setq make-backup-files nil) | |
(setq auto-save-default nil) | |
(setq-default tab-width 2) | |
(setq-default indent-tabs-mode nil) | |
(setq inhibit-startup-message t) |
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 play(m) | |
a,c=%w(Rock Scissors Paper),rand(4);[a[c%3],%w(Draw Lose Win)[a.index(m)-c]]*',' | |
end |
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
# Quickly thrown together, but it works, and maybe it'll get YOU started on | |
# a better solution to the problem. Enjoy! | |
class TextLayout | |
attr_reader :page_width, :tab_width | |
def initialize(tab_width=4, page_width=80) | |
@tab_width, @page_width = tab_width, page_width | |
end | |
# Takes a title and an optional character which will be used |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
user = ENV['OPSCODE_USER'] || ENV['USER'] | |
base_box = "precise64" | |
# ------------------------------------------------------------------------------ | |
# Short-hand node defs. | |
# ------------------------------------------------------------------------------ | |
nodes = { | |
:eh_app_node => { |
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
<LocationMatch "^/assets/.*$"> | |
Header unset ETag | |
FileETag None | |
# RFC says only cache for 1 year | |
ExpiresActive On | |
ExpiresDefault "access plus 1 year" | |
RewriteEngine On | |
RewriteCond %{HTTP:Accept-Encoding} gzip |
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
module ActiveRecord::OrScope | |
def self.included(base) | |
base.send :extend, ClassMethods | |
end | |
module ClassMethods | |
def or_scope(*scopes) | |
conditions = | |
scopes | |
.map { |scope| "(#{scope.where_clauses.map{ |clause| "(#{clause})"}.join(" AND ")})" } |
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
module Sluggo::Controller | |
MATCHER = /(^.+)-(.*$)/ | |
def self.included(base) | |
base.send :include, InstanceMethods | |
end | |
module InstanceMethods | |
private | |
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
function jankylog(msg) { | |
let konsole = document.getElementById('jankylog'); | |
if(!konsole) { | |
konsole = document.createElement('pre'); | |
konsole.id = 'jankylog'; | |
konsole.style.backgroundColor = 'white'; | |
konsole.style.padding = '1rem'; | |
document.body.append(konsole); |
OlderNewer