Skip to content

Instantly share code, notes, and snippets.

View andreapavoni's full-sized avatar
🎧
❤️‍🔥🪩🕺🏻🚀

Andrea Pavoni andreapavoni

🎧
❤️‍🔥🪩🕺🏻🚀
View GitHub Profile
@andreapavoni
andreapavoni / rcov.rake
Created October 10, 2011 14:18 — forked from alexdreher/rcov.rake
rcov raketask for Rails 3, RSpec 2
# Forked to get it working with Rails 3 and RSpec 2
#
# From http://github.com/jaymcgavren
#
# Save this as rcov.rake in lib/tasks and use rcov:all =>
# to get accurate spec/feature coverage data
#
# Use rcov:rspec or rcov:cucumber
# to get non-aggregated coverage reports for rspec or cucumber separately
@andreapavoni
andreapavoni / config.ru
Created March 8, 2012 06:55
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
# We are not loading Active Record, nor the Assets Pipeline, etc.
# This could also be in your Gemfile.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
# The following lines should come as no surprise. Except by
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@andreapavoni
andreapavoni / myleakedin.rb
Created June 7, 2012 12:51 — forked from riffraff/gist:2882358
linkedin dump password check
#!/usr/bin/env ruby
# USAGE: ruby myleakedin.rb yourpassword
# assumes you have the dump in the same dir as combo_not.txt
require 'digest/sha1'
pass = ARGV.first
hex = Digest::SHA1.hexdigest(pass)
print "HEX: #{hex} => "
@andreapavoni
andreapavoni / inject_vs_plus.rb
Created November 14, 2012 09:58 — forked from rentalcustard/inject_vs_plus.rb
inject vs plus vs concat
require 'benchmark'
class PerfTest
def with_inject(array)
mapped_vals.inject(array, :<<)
end
def with_plus(array)
array + mapped_vals
end
# app/controllers/custom_devise/password_controller.rb
class CustomDevise::PasswordsController < Devise::PasswordsController
def resource_params
params.require(resource_name).permit(:email, :password, :password_confirmation)
end
private :resource_params
end
package main
import (
"code.google.com/p/go.net/websocket"
)
type connection struct {
// The websocket connection.
ws *websocket.Conn
#commit model
class Commit < ActiveRecord::Base
# 1) We don't need a provider based Commit subclass, a String field
# should be enough. In case, we can associate a Provider model
# (1 to 1 relation) that represents a specific provider
# 2) we might want to use commit IDs, then build the commit URL at runtime
# (perhaps an URL template specific to the provider should be specified in Provider model)
# this shuould prevent eventual URL changes by providers :-)
attr_accessible :commit_url, :author, :commit_message, :provider

This is all based on the [alpha release][1].

Properties

From the built-in help system:

For many settings TextMate will look for a .tm_properties file in the current folder and in any parent folders (up to the user’s home folder).

These are simple setting = value listings where the value is a format string in which other variables can be referenced.

// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Modify by linuz.ly
package main
import (
"bytes"
"fmt"
"code.google.com/p/go.crypto/ssh"