Skip to content

Instantly share code, notes, and snippets.

<strong>Hello world</strong>
@jboner
jboner / gist:939
Created July 22, 2008 13:29
Scala HashCode builder
val SEED = 23
def hash(seed: Int, value: Boolean): Int = firstTerm(seed) + (if (value) 1 else 0)
def hash(seed: Int, value: Char): Int = firstTerm(seed) + value.asInstanceOf[Int]
def hash(seed: Int, value: Int): Int = firstTerm(seed) + value
def hash(seed: Int, value: Long): Int = firstTerm(seed) + (value ^ (value >>> 32) ).asInstanceOf[Int]
def hash(seed: Int, value: Float): Int = hash(seed, JFloat.floatToIntBits(value))
def hash(seed: Int, value: Double): Int = hash(seed, JDouble.doubleToLongBits(value))
def hash(seed: Int, anyRef: AnyRef): Int = {
var result = seed
@andymason
andymason / 1px_CSS_Background_Gitter_Fix.css
Created July 22, 2008 13:30
Solves the 1px gitter bug in multiple browsers
BODY {
background-position: 0 49.9% /* Top and Center */
}
@digitalronin
digitalronin / gitrmall.rb
Created July 22, 2008 13:36
Ruby script to automatically "git rm" deleted files
#!/usr/bin/env ruby
# Ruby script to automatically "git rm" deleted files
DELETED_REXP = /^#\s+deleted:\s+(.*)/
MARKER_LINE = '# Changed but not updated:'
lines = `git status`
found_marker = false
class UserObserver < ActiveRecord::Observer
def after_create(user)
UserMailer.deliver_signup_notification(user)
end
def after_save(user)
UserMailer.deliver_activation(user) if user.recently_activated?
UserMailer.deliver_forgot_password(user) if user.recently_forgot_password?
UserMailer.deliver_reset_password(user) if user.recently_reset_password?
class UserObserver < ActiveRecord::Observer
def after_create(user)
UserMailer.deliver_signup_notification(user)
end
def after_save(user)
UserMailer.deliver_activation(user) if user.recently_activated?
UserMailer.deliver_forgot_password(user) if user.recently_forgot_password?
UserMailer.deliver_reset_password(user) if user.recently_reset_password?
@code
code / woot.txt
Created July 22, 2008 13:40
Just a little test.
Love this.
How do I tell it that I want this to be ruby?
<?php
$handle = fopen('file.csv', 'r');
while ($a=fgetcsv($handle)) {
$b[] = $a;
}
echo "<table border='1'>";
foreach ($b as $v) {
echo "<tr>";