View extract_li_data.js
// Ok. What am I trying to do?
// ===========================
// Extract 3 data values from the li elements in a ul list,
// that are easily identified by classes on the target page.
// Not rocket science.
// Tool: Aartoo. Client Side Javascript. Looks evolved.
// Simple bookmarket run from the extraction page,
View survival_panther.rb
class Panther < RTanque::Bot::Brain
NAME = 'Survival Panther'
include RTanque::Bot::BrainHelper
def tick!
command.radar_heading = sensors.radar_heading + (RTanque::Heading::ONE_DEGREE * 30)
at_tick_interval(25) do
print_stats
end
View gitlg.bash
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit"
View factories_to_make.rb
#for running in the console
require 'factory_girl'
models = []
factories = []
#otherwise this list isn't going to contain all models.
Rails.application.eager_load!
ActiveRecord::Base.descendants.each do |model|
View gist:5880195
FactoryGirl.factories.each{ |fac| puts fac.name.capitalize unless fac.name.to_s.include? "_" };nil
View rails_list_models.rb
#otherwise this list isn't going to contain all models.
Rails.application.eager_load!
ActiveRecord::Base.descendants.each do |model|
puts model.name
end
View fixnum_ordinalize.rb
class Fixnum
def ordinalize
if (11..13).include?(self % 100)
"#{self}th"
else
case self % 10
when 1; "#{self}st"
when 2; "#{self}nd"
when 3; "#{self}rd"
else "#{self}th"
View watch_controller.rb
class WatchController < ApplicationController
def index
max_cast = 222 #todo-fetchMaxCastNumber
base_url = "http://railscasts.com/episodes/"
options = "?autoplay=true"
random_cast = Random.rand(max_cast)
redirect_to base_url + random_cast.to_s + options
end
View gitolite_hn.bash
# Assuming Ubuntu 10.04 with git already installed.
#
# Make sure to secure your server: http://www.andrewault.net/2010/05/17/securing-an-ubuntu-server/
# These instructions are based on:
# http://sitaramc.github.com/gitolite/doc/1-INSTALL.html:
# First, get you id_rsa.pub onto the server as /tmp/YourName.pub
scp ~/ssh/id_rsa.pub you@git.you.com:/tmp/
View weekends.rb
#Author: Ian Moss aka oceanician : http://twitter.com/oceanician
#First Published: https://gist.github.com/1009253
#I'm running as part of a rails project with:
# ruby script/runner lib\weekends.rb
# Returns parameter from_date if it is a Friday.
def next_friday( from_date )
while from_date.cwday!=5
from_date = from_date + 1.day
end