Skip to content

Instantly share code, notes, and snippets.

View makevoid's full-sized avatar

Francesco 'makevoid' Canessa makevoid

View GitHub Profile
@makevoid
makevoid / thorrents_jsonp_embed.haml
Created March 19, 2011 15:26
Thorrents JSONP embed example [HAML]
%script{ type: "text/javascript" }
:plain
$(function(){
var query = "ubuntu"
var element = "#thorrents"
var limit = 5
// TODO: jquery function - $("element").thorrents()
var domain = "thorrents.com"
var url = 'http://'+domain+'/search/'+query+'?callback=?'
@makevoid
makevoid / thorrents_jsonp_embed.html
Created March 19, 2011 15:28
Thorrents JSONP embed example [html]
<html><body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type='text/javascript'>
$(function(){
var query = "ubuntu"
var element = "#thorrents"
var limit = 5
// TODO: jquery function - $("element").thorrents()
var domain = "thorrents.com"
@makevoid
makevoid / deline.rb
Created April 10, 2011 23:28
Deletes a line from a file - unix semicolun notation - file:line
#!/usr/bin/env ruby
# Deletes a line from a file - unix semicolun notation - file:line
# Usage:
#
path, line_number = ARGV[0].split(":")
file = ""
File.open(path).readlines.each_with_index do |line, idx|
@makevoid
makevoid / ruby hash_representation_improvement.txt
Created April 12, 2011 12:08
ruby hash representation improvement
# ruby hash representation improvement (or fix)
ruby-1.9.2-head :001 > {a: "b"}
=> {:a=>"b"}
ruby-1.9.2-head :002 > {a: "b"}.to_s
=> "{:a=>\"b\"}"
should become:
ruby-1.9.2-head :001 > {a: "b"}
@makevoid
makevoid / new_term.rb
Created April 27, 2011 13:07
open new terminal tab and executes a command (with rb-appscript)
require 'appscript' # gem i rb-appscript
include Appscript
command = "ls"
app('Terminal').activate()
app("System Events").application_processes["Terminal.app"].keystroke("t", :using => :command_down)
tab = app('Terminal').windows[1].tabs.last.get
app('Terminal').do_script(command, :in => tab)
@makevoid
makevoid / hosted_example.txt
Created August 27, 2011 02:01
JQuery DOM HighLighter (it's a basic "Inspect element" simple implementation to mimic what webkit inspector and firebug do)
http://uploads.makevoid.com/jquery_dom_highlighter.html
@makevoid
makevoid / README.md
Created August 27, 2011 02:23 — forked from reborg/open_local_html_hotcocoa_webview.rb
Hotcocoa basic WebView hello world (to embed a webpp in a native one basically)

Run

if you don't have macruby and hotcocoa already:

rvm use macruby
gem i hotcocoa

ok then you can run:

hotcocoa webviewbasic

@makevoid
makevoid / switch_to_vim.sh
Created September 7, 2011 00:42
A function in my .profile to help me remember to learn vim :)
function editor() { # randomly chooses an editor for you :)
[[ `expr $RANDOM % 2` == 0 ]] && editor="vim" || editor="mate"
$editor $1
}
@makevoid
makevoid / Gemfile
Created September 12, 2011 02:59
Rails 3.1 Gemfile with DataMapper, RSpec, Haml, Sass, CoffeeScript and Thin (in dev)
source 'http://rubygems.org'
gem 'activesupport', :require => 'active_support'
gem 'actionpack', :require => 'action_pack'
gem 'actionmailer', :require => 'action_mailer'
gem 'railties', :require => 'rails'
gem 'mysql2'
DM_VERSION = '~> 1.2.0.rc1'
@makevoid
makevoid / your_model_spec.rb
Created October 14, 2011 13:19
running model specs requiring active record
require 'active_record' # or older require "activerecord"
require_relative 'app/models/your_model'
ActiveRecord::Base.establish_connection(adapter: 'mysql', host: 'localhost', username: 'root', database: 'your_database')
describe "something" do
it "should spec somehting" do
YourModel.first.should be_a(YourModel)
end
end