Skip to content

Instantly share code, notes, and snippets.

View webcracy's full-sized avatar

Alexandre Loureiro Solleiro webcracy

View GitHub Profile
def index
@${1:things} = ${2:Thing}.find :all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @$1 }
end
end
def show
@webcracy
webcracy / gist:191254
Created September 22, 2009 17:37
Polling of TVI.pt latest videos
# Stupid polling of TVI.pt latest videos
# Also tries to match a string to test for specific videos
# If true, it sends a Growl notification and outputs the video title to STDOUT
require 'rubygems'
require 'open-uri'
require 'cgi'
require 'hpricot'
require 'ruby-growl'
@webcracy
webcracy / wordpress2tumblr.rb
Created September 26, 2009 17:51
A script to import your Wordpress posts on Tumblr
# Export your Wordpress posts to Tumblr (also allows to delete some.)
# Author: Alexandre Solleiro <alex@webcracy.org>
# How-to:
# 1. Export your Wordpress posts (http://en.blog.wordpress.com/2006/06/12/xml-import-export/)
# 2. Edit the information below to match your settings
# 3. To import, type "ruby wordpress2tumblr.rb --run" in the command line
# 4. To delete some posts, type "ruby wordpress2tumblr.rb --delete 1,2,3,4" where 1,2,3,4 are post numbers. (Be careful not to use spaces between IDs)
# Edit these
WP_EXPORT_PATH = "./wordpress.2009-09-14.xml" # path to the Wordpress Export file
@webcracy
webcracy / ss
Created March 22, 2010 15:58
ss is a ./script/server shortcut
#!/usr/local/bin/ruby
#
# Name: ss
# Description: ss is a ./script/server shortcut
# Author: Alex Solleiro <alex@webcracy.org>
# Instructions:
# Save this file as 'ss' within a directory in your $PATH
# Make it executable, ex: 'chmod +x ss'
# Type 'ss' at the root of a Rails app to run './script/server'
# You can pass arguments in the usual way
@webcracy
webcracy / defaults.css
Created August 18, 2010 00:44
Styles for simple FamFamFam icons
/* Styles for p, div or span with nice FamFamFam icons, to use around a link*/
.add {font-size: 12px; background: url('/images/icons/add.png') 0 0 no-repeat; padding-left: 18px; line-height: 16px; font-weight: normal;}
.new_password {font-size: 12px; background: url('/images/icons/lock_go.png') 0 0 no-repeat; padding-left: 18px; line-height: 16px; font-weight: normal;}
.ok {font-size: 12px; background: url('/images/icons/accept.png') 0 0 no-repeat; padding-left: 18px; line-height: 16px; font-weight: normal;}
.edit {font-size: 12px; background: url('/images/icons/pencil.png') 0 0 no-repeat; padding-left: 18px; line-height: 16px; font-weight: normal;}
.delete {font-size: 12px; background: url('/images/icons/delete.png') 0 0 no-repeat; padding-left: 18px; line-height: 16px; font-weight: normal;}
.show {font-size: 12px; background: url('/images/icons/magnifier.png') 0 0 no-repeat; padding-left: 18px; line-height: 16px; font-weight: normal;}
@webcracy
webcracy / tvi_video_poller.rb
Created November 8, 2010 14:02
Poll and Scrape TVI website for a given News Show and do growl notification
require 'rubygems'
require 'open-uri'
require 'cgi'
require 'hpricot'
require 'ruby-growl'
url = "http://www.tvi.iol.pt/frame_videos_tvi.html"
growl = Growl.new 'localhost', 'ruby-growl', ["ruby-growl Notification"]
loop do
@webcracy
webcracy / slide.jquery.js
Created October 4, 2011 13:00
Dead simple JS / jquery slideshow
$('.slide').each(function() {
$(this).hide();
});
(function shownext(jq){
jq.eq(0).fadeIn(500, function(){
$(this).delay(5500).fadeOut(250, function() {
if ((jq=jq.slice(1)).length == 0)
(jq=$('.slide')).length && shownext(jq);
else
@webcracy
webcracy / dashboard_controller.rb
Created November 3, 2011 16:39
Manybots - Ruby on Rails tutorial
class DashboardController < ApplicationController
before_filter :authenticate_user!
def index
end
def post_activity
test_activity = Manybots::Feed::Item.new_test_activity(current_user)
activity_from_manybots = current_user.post_to_manybots!(test_activity)
@webcracy
webcracy / activity_get_example.js
Created November 22, 2011 10:47
Manybots - Activity Streams examples
{
"data": {
"items": [
{
"id": "http://examplemanybotsserver.com/activities/170",
url: "http://examplemanybotsserver.com/activities/170",
"title": "<%= "<a href='http://examplemanybotsserver.com/users/1'>Alex Solleiro</a> joined <a href='http://examplemanybotsserver.com'>Manybots Server</a>."%>",
"summary": "Welcome to Manybots Server",
"published": "2010-11-09 17:22:41 UTC",
"tags": [ "manybots", "account"],
@webcracy
webcracy / manybots_auth_token_example.rb
Created November 25, 2011 14:43
Manybots API - Auth Token example
# encoding: UTF-8
require 'rubygems'
require 'json/add/core'
require 'httparty'
TOKEN = 'YOUR API TOKEN' #find it in your /account page
module Manybots