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
@bastos
bastos / xmlrpc_cached_client.rb
Created October 16, 2008 13:55
line 16 just for debbug, remove it later!
# Cache XML RPC calls
#
# Author:: Tiago Bastos (mailto:[email protected]).
# Copyright:: Copyright 2008 Laverock von Schoultz, Gibraltar
class XMLRPCCachedClient < XMLRPC::Client
def call(method, *args)
if ActionController::Base.perform_caching
# Generate unique ley using method and argumets
key = "xmlrpc:call:" + Digest::MD5.hexdigest("#{method}:#{args.to_s}")
@bastos
bastos / diario.rb
Created October 17, 2008 12:37
Busca de anúncios no diário do nordeste
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'cgi'
cgi = CGI.new() # New CGI object
puts "Content-type: text/html\n\n"
puts "<h1>Procurando por #{cgi.params['q']}</h1>"
doc = Hpricot(open("http://diariodonordeste.globo.com/classif/consultando.asp?Filtro=#{cgi.params['q']}&Operador=OU&Filtro2="))
doc.search(".anuncio").each do | anuncio |
@bastos
bastos / arvore.rb
Created October 20, 2008 07:08
Binary tree example!
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'rubygems'
class BinaryTree
attr_reader :root
# Por padrão busca por root primeiro
def search(value, node=@root)
if node == nil
@bastos
bastos / gist:18919
Created October 23, 2008 04:34
LinkedList
#include<stdlib.h>
#include<stdio.h>
struct list_el {
int val;
struct list_el *next;
};
typedef struct list_el item;
@bastos
bastos / gist:20804
Created October 29, 2008 19:55
Emacs lisp function to quick edit dot emacs file
;; from http://dotfiles.org/~lwu/.emacs
; code copied from XEmacs's Options\Edit Init File menu code
(defun edit-dot-emacs ()
"Edits the user's .emacs file"
(interactive)
(progn
(find-file (or user-init-file "~/.xemacs/custom.el"))
(or (eq major-mode (quote emacs-lisp-mode)) (emacs-lisp-mode))))
;; From http://alohakun.blog7.fc2.com/blog-entry-929.html with small changes...
(require-extension xlib)
(let ((dpy (xopendisplay #f)))
(assert dpy)
(let ((root (xdefaultrootwindow dpy)))
(xgrabkey dpy XK_F1 MOD4MASK root 1 GRABMODEASYNC GRABMODEASYNC)
(xgrabbutton dpy 1 MOD4MASK root 1 BUTTONPRESSMASK GRABMODEASYNC GRABMODEASYNC NONE NONE)
(xgrabbutton dpy 3 MOD4MASK root 1 BUTTONPRESSMASK GRABMODEASYNC GRABMODEASYNC NONE NONE)
(let ((event (make-xevent))
! Global
Xft.antialias: true
Xft.rgba : rgb
Xft.hintstyle : hintfull
Xft.hinting : true
! URxvt
URxvt*xftAntialias: true
URxvt*background: #242424
URxvt*foreground: #fafffa
! Monaco Font: http://www.gringod.com/wp-upload/software/Fonts/Monaco_Linux.ttf
@bastos
bastos / bashrc
Created November 11, 2008 20:31
my .bashrc with lots of dotfiles.org stuff :D
# If not running interactively, don't do anything
# [ -z "$PS1" ] && return
export EDITOR=emacsclient
export IOKE_HOME=~/code/ioke
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
// Based on apidock.org Ubiquity Search: http://gist.github.com/8132
CmdUtils.CreateCommand(
{
name: "code",
takes: {"function": noun_arb_text},
icon: "http://github.com/fluidicon.png",
homepage: "http://tiago.zusee.com",
author: {name: "Tiago Bastos", email: "[email protected]"},
license: "MPL,GPL",
description: "Search on Github Code Search",
// Based on apidock.org Ubiquity Search: http://gist.github.com/8132
CmdUtils.CreateCommand(
{
name: "github",
takes: {"function": noun_arb_text},
icon: "http://github.com/fluidicon.png",
homepage: "http://tiago.zusee.com",
author: {name: "Tiago Bastos", email: "[email protected]"},
license: "MPL,GPL",
description: "Search on Github",