Skip to content

Instantly share code, notes, and snippets.

View levycarneiro's full-sized avatar

Levy Carneiro Jr. levycarneiro

View GitHub Profile
describe Tweet do
describe "basic fetching of tweets" do
it "should fetch new tweets from Twitter" do
new_search = mock(Twitter::Search)
search_containing = mock(Twitter::Search)
search_not_retweeted = mock(Twitter::Search)
search_since = mock(Twitter::Search)
last_id_processed = Tweet.stub!(:last_id_processed => 123)
search_since = mock(Twitter::Search)
class Tweet < ActiveRecord::Base
Tweet_identificator = 'protip:'
def self.fetch_new_tweets
Twitter::Search.new.
containing(Tweet_identificator).
not_retweeted.
since(last_id_processed).
fetch
end
# Converting a general MySQL query...
UPDATE `jos_content` SET checked_out = 62, checked_out_time = '2009-11-23 13:09:46' WHERE id = '179'
# ...into a Rails Migration
class Migration20091123001 < ActiveRecord::Migration
def self.up
item = JosContent.find(179)
item.checked_out = 62
item.checked_out_time = '2009-11-23 13:09:46'
item.save!
#!/usr/bin/env ruby
#
# Brute-force way to retrieve all Github's repositories at once
# Usage:
# github_repos.rb clone # will clone all the user's repositories
# github_repos.rb clone test # will just clone 6 repositories for testing purposes
# github_repos.rb pull # will update all of the user's local repositories
#
# If you have forked repositories, the original sources will be added
# as remotes with the default 'forked_from' name, and a new 'forked_from'
class Comment
include MongoMapper::EmbeddedDocument
include Gravatarable
key :name, String
key :email, String
key :url, String
key :body, String
key :created_at, Time
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
# Gems for Ruby 1.9.1
gem install rails rails-sqlserver-2000-2005-adapter acts_as_tree acts_as_versioned activerecord-tableless annotate capistrano erubis haml haml-edge inherited_resources nifty-generators rack rack-cache racksh sqlite3-ruby will_paginate passenger
gem install cucumber rspec rspec-rails shoulda test-spec ZenTest autotest-fsevent autotest-growl autotest_screen email_spec factory_girl faker fakeweb log4r metric_fu mocha quietbacktrace rcov integrity webrat Selenium tarantula mash wirble hirb ruby2ruby RubyInline
gem install authlogic authlogic-oid bundler closure-compiler coderay compass cs-active_form dry_scaffold feed-normalizer formtastic has_scope hobo htmlentities validatable liquid newrelic_rpm paperclip responders searchlogic settingslogic thin tlsmail unicorn yui-compressor jammit lockdown
gem install BlueCloth lesstile markaby rdiscount RedCloth nokogiri libxml-ruby hpricot httparty httpclient mechanize rest-client xml-simple restfulie feedzirra prawn rss-client soap4r xmpp4r xm
require 'rubygems'
require 'httparty'
require 'time'
require 'active_support'
File.read("#{ENV['HOME']}/.gitconfig").match(/token = (\w+)/)
TOKEN = $1
class Github
include HTTParty
#!/usr/bin/env ruby
#
# Put this script in your PATH and download from onemanga.com like this:
# onemanga_downloader.rb Bleach [chapter number]
#
# You will find the downloaded chapters under /tmp/Bleach
#
require 'rubygems'
require 'mechanize'
require 'nokogiri'
@levycarneiro
levycarneiro / license
Created January 27, 2010 10:55 — forked from defunkt/license
#!/bin/sh -e
# Usage: license
# Prints an MIT license appropriate for totin' around.
#
# $ license > COPYING
year=`date "+%Y"`
cat <<EOF
Copyright (c) $year Chris Wanstrath
Permission is hereby granted, free of charge, to any person obtaining