Skip to content

Instantly share code, notes, and snippets.

View bastos's full-sized avatar
:shipit:
Shipping something

Tiago Bastos bastos

:shipit:
Shipping something
View GitHub Profile
#!/usr/bin/env python
# Drop.io Upload Tool for GNOME
# Copyright (C) 2008 Ryan Paul (SegPhault)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
@bastos
bastos / from.rb
Created December 12, 2008 15:49 — forked from bmizerany/from.rb
get '/:id' do
@vent = Vent.get(params[:id])
erb :show
end
# show post
get '/:id.xml' do
@vent = Vent.get(params[:id])
builder :show
end
require "rubygems"
require "dnssd"
require "set"
require "socket"
require "webrick"
module AliveJour
include Socket::Constants
Paste = Struct.new(:name, :host, :port)
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base
@bastos
bastos / example.rb
Created January 9, 2009 20:37
Render for Sinatra using markaby and with cache.
require "rubygems"
require "sinatra"
require "render"
Sinatra::EventContext.send :include, Render
SVN_REPO_PATH = "/home/tiago/projects/repo/trunk"
get "/" do
render :cache => true, :expire => 60 do
@bastos
bastos / gist:56866
Created February 2, 2009 10:29
Download all videos from Ruby Conf 2008 Confreaks Website
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
open('http://feeds.feedburner.com/Rubyconf2008-Confreaks') do |f|
Hpricot.XML(f).search("link").each do |link|
puts "Downloading #{link.inner_text}"
`wget -c #{link.inner_text}`
...
before_filter :set_views_paths_for_layout
# Add new paths to templates paths.
def set_views_paths_for_layout
paths = []
...
paths << create_a_new_path("#{RAILS_ROOT}/app/views/shared")
# Based on:
# http://github.com/bmizerany/heroku-sinatra-app
# http://www.sinatrarb.com/book.html#heroku
# trial-and-error
#
# I tried using Blake's sample code from github,
# but for some reason my Heroku.com app was running in
# a directory called /mnt. This did not correspond to the
# name of my app. The code below is more explicit when it
# comes to the name of the app file. That is the only difference.
@bastos
bastos / gist:65170
Created February 16, 2009 13:45
Test Memcached
require 'rubygems'
require 'memcache'
memcache_options = {
:namespace => 'agp:test:key',
:multithread => true
}
memcached_servers = [ ENV['MEMCACHED_LOCATION'] || '0.0.0.0:12211']
@bastos
bastos / gist:79867
Created March 16, 2009 13:10
Little Script to reload a rails app on server for tests...
#!/usr/bin/env sh
# On CRON:
# 00,15,30,45 * * * * /home/user/project/reload.sh >> /home/user/log/release_web.log 2>&1
echo "Rebuilding" > /home/user/project/current/public/index.html
# Update the code
svn update /home/user/project/current
# Run migrations
cd /home/user/project/current
rake RAILS_ENV=$RAILS_ENV db:migrate;
# Restart memcached.