Skip to content

Instantly share code, notes, and snippets.

View andyjeffries's full-sized avatar

Andy Jeffries andyjeffries

View GitHub Profile
@andyjeffries
andyjeffries / internal_redirect_to.rb
Created June 16, 2010 13:47
Internal redirect_to for Rails 2.x
# This is an internal_redirect_to function by Sandro Paganotti
# http://www.railsonwave.com/2008/10/25/how-to-call-a-controller-s-action-from-a-different-controller
# By using this internal_redirect_to function you will be able to
# get the same results as a normal redirect_to without send anything
# to the user, only keep in mind to explicit invoke the return after
# this function.
class ApplicationController
def internal_redirect_to (options={})
@andyjeffries
andyjeffries / gist:348897
Created March 30, 2010 08:10
A short textmate wrapper command
#!/usr/bin/env ruby
if ARGV.size == 0
lines = `ls -1 *.tmproj 2>/dev/null`.split("\n")
if lines.size == 1
`open #{lines[0]}`
else
`mate .`
end
else
# MIGRATION
class CreateBasicTables < ActiveRecord::Migration
def self.up
create_table :books, :force => true do |t|
t.string :title
t.timestamps
end
create_table :authors, :force => true do |t|
t.string :name
#!/usr/bin/env ruby -w
require 'rubygems'
require 'Text'
results = {}
Dir.glob("top100_*.txt") do |filename|
File.read(filename).split("\n").each do |song|
stripped = song.gsub(/[^a-z0-9]/, '').downcase
<!--
Replace the sections with {} with their real values
Add the content
Convert it with:
html2mobi --author "{AUTHOR GOES HERE}" this.html
-->
<html>
<head>
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
<title>{TITLE GOES HERE}</title>
FDJ = {}
FDJ.EventScroller = {
init: function() {
setTimeout(function() {
FDJ.EventScroller.start_all();
}, 3000);
console.log("Setting timeout - done");
},
start_all: function() {
$(".wrapper").each(function() {
fdjstage:
rails_env: fdjstage_public
rails_root: /home/fdjstage-public/fortaleza/current
cap_binary: /home/agp/local/ruby-ee/bin/cap
ruby_binary: /home/agp/local/ruby-ee/bin/ruby
rubyrep_binary: /home/agp/local/ruby-ee/bin/rubyrep
ssh_key: /home/agp/.ssh/id_rsa
user: agp
database:
adapter: mysql
$ gem list --local|grep 'LVS-JSONService'
LVS-JSONService (0.2.5, 0.2.4, 0.2.3, 0.2.2, 0.2.1)
$ irb
>> require 'rubygems'
=> false
>> require 'nokogiri'
=> true
# Just checking gems load OK
>> require 'jsonservice'
require 'rubygems'
require 'builder'
favorites = {
'candy' => 'Neccos', 'novel' => 'Empire of the Sun', 'holiday' => 'Easter'
}
xml = Builder::XmlMarkup.new(:indent => 2 ) do |b|
b.instruct! :xml, :version => "1.1", :encoding => "UTF-8"
module ActionController #:nodoc:
module Cookies
def cookies
@cookies ||= CookieJar.new(self)
end
end
end