Skip to content

Instantly share code, notes, and snippets.

View safarista's full-sized avatar

Nelson Kelem safarista

View GitHub Profile
# Script to generate a CSV of all your Twitter followers screen_name, name, url, and description (bio)
# Runs fine on OS X: put into a file, and then from a Terminal: ruby whatever.rb to run.
require 'json'
puts "Enter your Twitter username:"
username = gets.chomp
puts "Enter your Twitter password:"
password = gets.chomp
@peterc
peterc / domainavailable
Created February 13, 2009 13:30
Check if a domain is available to register (uses DNS before WHOIS to be fast) - supports .com,.net,.org,.co.uk - inspired by foca/giles http://gilesbowkett.blogspot.com/2009/02/simple-bash-domain-availability.html
#!/bin/bash
# domainavailable
# Fast, domain name checker to use from the shell
# Use globs for real fun:
# domainavailable blah{1..3}.{com,net,org,co.uk}
# Inspired by foca / giles:
# http://gilesbowkett.blogspot.com/2009/02/simple-bash-domain-availability.html
trap 'exit 1' INT TERM EXIT
@peterc
peterc / wordpressr.rb
Created March 14, 2010 01:07
WordPressr - WordPress posting client library for Ruby
require 'rubygems'
require 'mime/types'
require 'xmlrpc/client.rb'
require 'uri'
# WordPressr - WordPress posting client library for Ruby
# By Peter Cooper
#
# LICENSE:
# MIT, BSD, whatever. Use the code at your own risk, I'm not
# Bits and pieces from my large, multi-file Sinatra app.. just to show structure
# -----
# Main base Sinatra app setup
module Cio
class App < Sinatra::Base
configure do
# Set global vars
set :root, APP_ROOT
require "application_responder"
class ApplicationController < ActionController::Base
# ...
def self.acts_as_magical
around_filter :magic_new, :only => :new
around_filter :magic_show, :only => :show
around_filter :magic_edit, :only => :edit
@mbbx6spp
mbbx6spp / gist:1083536
Created July 14, 2011 21:45 — forked from onethirtyfive/gist:1083182
Class-Table Inheritance Meta-model for DataMapper
# Module with mixins for common queries across descendants:
module Descendant
# I guess I could use ActiveSupport::Concern here...
def self.included(receiver)
receiver.extend ClassMethods
receiver.send :include, InstanceMethods
end
module ClassMethods
def self.included(receiver)
@peterc
peterc / irb3.rb
Created September 19, 2011 14:17
irb3 - Run an IRB-esque prompt over multiple Ruby implementations at once using RVM
#!/usr/bin/env ruby
# encoding: utf-8
# irb3 - Runs an IRB-esque prompt (but it's NOT really IRB!) over multiple
# versions of Ruby at once (using RVM)
#
# By Peter Cooper, BSD licensed
#
# Main dependency is term-ansicolor for each impl:
# rvm exec gem install term-ansicolor
@tomoconnor
tomoconnor / script.md
Created February 27, 2012 17:25 — forked from lucasmazza/script.md
Redis 2.2 Install on Ubuntu 10.04

Installation commands:

$ wget http://redis.googlecode.com/files/redis-2.2.2.tar.gz
$ tar xvfz redis-2.2.2.tar.gz 
$ cd redis-2.2.2/
$ mkdir -p /opt/redis
$ make PREFIX=/opt/redis install
$ cp redis.conf /opt/redis/redis.conf
$ sudo useradd redis
@abevoelker
abevoelker / gist:2123152
Created March 19, 2012 18:32
concrete table inheritance
# app/models/wizard.rb
class Wizard
# shared instance methods go here
def self.all_visible_subwizards
descendants.entries.select{|d| d.visible?}.sort
end
end
# lib/wizard_fields.rb
require "rubygems"
require "bundler/setup"
require "sinatra"
require "base64"
get "/" do
Base64.encode64(File.binread("image"))
end