Skip to content

Instantly share code, notes, and snippets.

View masterkain's full-sized avatar
🤖

Kain masterkain

🤖
View GitHub Profile
@masterkain
masterkain / gist:8557
Created September 3, 2008 08:03 — forked from tokumine/gist:8556
irb(main):001:0> ME = 5.freeze
=> 5
irb(main):002:0> ME.frozen?
=> false
irb(main):003:0> ME = "5".freeze
(irb):3: warning: already initialized constant ME
=> "5"
irb(main):004:0> ME.frozen?
=> true
irb(main):005:0>
def browse
root, dir = File.expand_path("."), request[:dir]
@lis = []
begin
path = root + "/" + dir
Dir.chdir(File.expand_path(path)) do
if Dir.pwd[0,root.length] == root then
files = Dir.glob("*")
files.each{ |x|
next unless File.directory?(x)
# Rename an email address in all old commits.
# WARNING: Will change all your commit SHA1s.
# Based off of the script from here:
# http://coffee.geek.nz/how-change-author-git.html
git filter-branch -f --commit-filter '
if [ "$GIT_COMMITTER_EMAIL" = "joern.zaefferer@googlemail.com" ];
then
GIT_AUTHOR_EMAIL="joern.zaefferer@gmail.com";
GIT_COMMITTER_EMAIL="joern.zaefferer@gmail.com";
git commit-tree "$@";
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
From 4df22d595120e6eef596ebf10e36458b2a88e958 Mon Sep 17 00:00:00 2001
From: Rob Anderton <rob.anderton@thewebfellas.com>
Date: Tue, 30 Mar 2010 16:44:52 +0100
Subject: [PATCH 1/3] fix problems with newer versions of test/unit
---
test/helper.rb | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/test/helper.rb b/test/helper.rb
<html>
<head>
<title>Fetch Image</title>
<script type="text/javascript" src="index.js"></script>
<link href="index.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<h3>Fetch Image From URL:</h3>
<div style='font-weight:bold'>Title</div>
<input id="imgTitle" type="text"></input>
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
class Task < ActiveRecord::Base
belongs_to :category
belongs_to :project
validates_presence_of :project_id, :category_id
validates_with OvertimeValidator
scope :of_date, lambda { |date| where(:date => date) }
end
@masterkain
masterkain / lastfm.rb
Created May 27, 2011 22:20 — forked from lucasmazza/lastfm.rb
a Last.FM Strategy for OmniAuth
require 'omniauth/core'
require 'digest/md5'
require 'rest-client'
require 'multi_json'
module OmniAuth
module Strategies
class Lastfm
include OmniAuth::Strategy
require "resque"
require "resque/failure/multiple"
require "resque/failure/redis"
# Configure Resque connection from config/redis.yml. This file should look
# something like:
# development: localhost:6379
# test: localhost:6379:15
# production: localhost:6379
Resque.redis = YAML.load_file(Rails.root + 'config/redis.yml')[Rails.env]