Skip to content

Instantly share code, notes, and snippets.

View ivanvanderbyl's full-sized avatar
🏝️

Ivan Vanderbyl ivanvanderbyl

🏝️
View GitHub Profile
function XHConn()
{
var xmlhttp, bComplete = false;
try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) { try { xmlhttp = new XMLHttpRequest(); }
catch (e) { xmlhttp = false; }}}
if (!xmlhttp) return null;
this.connect = function(sURL, sMethod, sVars, fnDone)
{
# Daft Golf
# Encode the entire lyrics of Harder Better Faster Stronger in the least amount of characters
# without cheating. Source of lyrics: http://lyricwiki.org/Daft_Punk:Harder,_Better,_Faster,_Stronger
# First attempt without being really anal: 500b
s=%w(after better do ever faster harder hour is it make makes more never our over stronger than us work)
m1="chavnohzy3a7uvnb4iw21ogt3xwazyiw6gqsoaihdjw36q8encnd1oxfpy2eomjfxfr9"
m2="5vjlr1vcd8f7rdjb3c3zfk0kh6cjxc2l8dzvzk2hhfrwkg2n2ln04mpli1tq5gnfu7nvxc6dbk8yq9uxnfboimh5902mqtggizhhaakr2nk2xsh4qar5b8aypdocmeakqelscg11evw57i3ttep2ott0pqteclmae5sckhc"
def d(e, a)
t=e.to_i(36).to_s(2)
t[0]=''
@ivanvanderbyl
ivanvanderbyl / survey
Created November 1, 2009 11:24 — forked from radar/survey.md
What did you do to get good at Rails?
I came from a PHP background, so the path I took was to workout how to do everything I knew with PHP
in Ruby and Rails, as well as reading loads of source code and ripping parts out and making smaller apps.
Who taught you what you know?
Mainly Google, I didn't know anyone using Rails for the first year or more.
Do you have any fond (or not so fond) memories of your learning experiences?
class User < ActiveRecord::Base
serialize :preferences
def method_missing(method_name, *arguments)
pref_match_setter = method_name.to_s.match(/^pref_(.+)\=$/)
pref_match_getter = method_name.to_s.match(/^pref_(.+)$/)
if pref_match_setter
current_prefs = self.preferences && self.preferences.any? && self.preferences || {}
@ivanvanderbyl
ivanvanderbyl / gist:295218
Created February 4, 2010 22:41
Install Rails 3 beta
git clone git://github.com/rails/rails.git
cd rails
gem uninstall bundler #<- all versions
gem install bundler
bundle install
rake install
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="csrf-param" content="authenticity_token"/>
<meta name="csrf-token" content="KfFm2BuhwmRs4I28F2hQVyD7/FB03UehQJnkFf5U/So="/>
<title>My app</title>
</head>
<body>
Rails version 3.0.0.beta1
// A Javascript version of Allan Odgaard's thousands separator regex
// http://blog.macromates.com/2007/recursion-in-regular-expressions/
123456789.toString().replace(/(\d{1,3})(?=(\d{3})+(?!\d))/g, '$1,');
// => "123,456,789"
# Path to your oh-my-zsh configuration.
export ZSH=$HOME/.oh-my-zsh
# Set to the name theme to load.
# Look in ~/.oh-my-zsh/themes/
export ZSH_THEME="robbyrussell"
# Set to this to use case-sensitive completion
# export CASE_SENSITIVE="true"
➜ ~ sudo gem install rails --pre
Password:
Successfully installed activesupport-3.0.0.rc
Successfully installed activemodel-3.0.0.rc
Successfully installed rack-1.2.1
Successfully installed rack-test-0.5.4
Successfully installed rack-mount-0.6.9
Successfully installed tzinfo-0.3.22
Successfully installed erubis-2.6.6
Successfully installed actionpack-3.0.0.rc
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
time_ago_in_words: function(from) {