Skip to content

Instantly share code, notes, and snippets.

View randito's full-sized avatar
:octocat:
(⊙_⊙)

Randy randito

:octocat:
(⊙_⊙)
View GitHub Profile
@randito
randito / grid.js
Created October 10, 2011 16:20 — forked from webxl/grid.js
CSS prototyping bookmarklet
javascript:(function(){s1=document.createTextNode('body::before { content:""; position:fixed; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAACxEAAAsRAX9kX5EAAAAZdEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjVJivzgAAAAyUlEQVRoQ%2B2abQqAIBBEPW1X6CzdqTv1RUFIipi2o72gPyXV7uybKci5wDZM8xI6dz%2Buvs6pP2Dq81GI2qiiiJkiOzQ97EGHTXUF9XUwYsaI2o1LjyqjpaYwiqDI2YFs2HtI9Wjx2Z0R%2B1ADdmB%2FC7taB0uzCSNqCqOImSIkeyW7xLXMZvqjdzJcS01hFEGRSnbe3miR7JVGgWRXcxkUQRFgj%2F8Y8htGtkJHL%2FvGaGtKd6bU9Z4C%2FCiEZDeCPahIa%2FbbDSNX433mVkIrV5rTnhDyAAAAAElFTkSuQmCC) 50% 0; z-index:1; top:0; right:0; bottom:0; left:0; opacity:.3; pointer-events:none; } * { -webkit-user-modify: read-write; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; } a { -webkit-user-modify: initial; }');s2=document.createTextNode('#a1_z { background-color: #fff; float: left; position: absolute; z-index:2; padding: 3px; border: 1px solid; }');css=document.createE
@randito
randito / binary-search.coffee
Created September 13, 2011 21:53 — forked from mythz/binary-search.coffee
Side by Side: CoffeeScript vs JavaScript - Algorithms Edition
# All CoffeeScript examples from: https://github.com/jashkenas/coffee-script/blob/master/examples/computer_science/
# All Java Script examples from: https://github.com/nzakas/computer-science-in-javascript - Copyright (c) 2009 Nicholas C. Zakas
# - Released under https://github.com/nzakas/computer-science-in-javascript/blob/master/LICENSE (*.js copyright headers reduced for clarity)
# Uses a binary search algorithm to locate a value in the specified array.
binary_search = (items, value) ->
start = 0
@randito
randito / Luhn algorithm
Created August 17, 2011 16:13
Luhn algorithm (valid CC check)
# Luhn algorithm to determine if a CC is valid
def valid(cc)
return false unless cc.respond_to?(:to_i) && cc.to_i != 0
doubled = []
cc.reverse.each_char.each_with_index do |c,i|
v = (i % 2 == 0) ? c.to_i : c.to_i * 2
doubled << v
end
@randito
randito / rails_3_1_rc4_changes.md
Created August 4, 2011 22:24 — forked from ryanb/rails_3_1_rc4_changes.md
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 RC4

  • The new rake task assets:clean removes precompiled assets. [fxn]

  • Application and plugin generation run bundle install unless --skip-gemfile or --skip-bundle. [fxn]

  • Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]

  • Template generation for jdbcpostgresql #jruby [Vishnu Atrai]

@randito
randito / application.html.haml
Created March 7, 2011 02:13
Base layout for haml using blueprint css and jquery
!!! 5
%html
%head
%title Hello World
= stylesheet_link_tag 'screen'
= stylesheet_link_tag 'print', :media => 'print'
/ [if lt IE 8]
= stylesheet_link_tag 'ie'
= csrf_meta_tag
%body
@randito
randito / gist:839155
Created February 22, 2011 18:59 — forked from veganstraightedge/gist:421959
Ruby implementation of nice URL shortner.
require "date"
require "time"
# converts base10 integers into NewBase60
def num_to_sxg(num=nil)
sxg = ""
vocabulary = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ_abcdefghijkmnopqrstuvwxyz"
return 0 if num.nil? || num.zero?
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
// Add a Mustache.js templating function to your JavaScript:
Mustache.template = function(templateString) {
return function () {
if (arguments.length < 1) {
// With no arguments, return the raw template -- useful for rendering
// partials.
return templateString;
} else {
return Mustache.to_html(templateString, arguments[0], arguments[1]);
@randito
randito / redis.cfg
Created January 27, 2011 16:43
Redis Config
# == From http://blog.zawodny.com/2011/01/27/redis-replication-consistency-maxmemory-lru/ ==
appendonly no
appendfsync no
rdbcompression yes
maxmemory 6gb
maxmemory-policy volatile-lru
maxmemory-samples 3
glueoutputbuf yes
hash-max-zipmap-entries 512
hash-max-zipmap-value 512
require 'rubygems'
require 'sinatra'
require 'redis'
# To use, simply start your Redis server and boot this
# example app with:
# ruby example_note_keeping_app.rb
#
# Point your browser to http://localhost:4567 and enjoy!
#