Skip to content

Instantly share code, notes, and snippets.

View mcollina's full-sized avatar

Matteo Collina mcollina

View GitHub Profile
@jasonkuhrt
jasonkuhrt / index.js
Last active August 29, 2015 13:57
Inspecting net.Socket instance properties as related to connection state
'use strict';
var tcp = require('net');
var s1 = tcp.createServer().listen(9000);
var s2 = tcp.createServer().listen(9001);
var s3 = tcp.createServer().listen(9002);
module VarAccessor
Sass::Script::Functions.send :include, self
def self.variables
@variables ||= {}
end
def self.set(values = {})
variables.merge! values
end
# app/concerns/let.rb
# Ripped from Rspec 2.0 beta.12
# I've found it so useful in Rspec, I made it into a module. Controller code with shared
# code seem to have a lot of use for this. For example, in inherited_resources, you would
# typically override model, parent, etc. to configure it. You would typically memomize it
# as well. With this, you can use a more compact let() syntax.
# (Note: This code will only work in Rails 3)
module Let
@guybrush
guybrush / nodeconf_2011.md
Created May 6, 2011 07:22
a list of slides from nodeconf 2011
@mcollina
mcollina / back.js
Created May 17, 2011 15:24
Sencha Touch Back Button Plugin
BackButton = Ext.extend(Ext.Button, {
ui: 'back',
text: 'Back',
hidden: true,
id: 'back',
handler: function() {
var dispatchOptions = this.backStack.pop();
Ext.dispatch(dispatchOptions);
if(this.backStack.length == 0) {
@cedmax
cedmax / LICENSE.txt
Last active September 25, 2015 23:08 — forked from 140bytes/LICENSE.txt
pub/sub custom events
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 cedmax <http://github.com/cedmax>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@thomasv314
thomasv314 / gist:1058944
Created July 1, 2011 17:00
NoMethodError: Undefined method 'deg2rad' for #<Class:0x0000>
class Listing < ActiveRecord::Base
set_table_name :Listing
scope :near, lambda{
|*args|
origin = *args.first[:origin]
if (origin).is_a?(Array)
origin_lat, origin_lng = origin
else
origin_lat, origin_lng = origin.latitude, origin.longitude
@kyoto
kyoto / coderwall.coffee
Created July 10, 2011 09:13
Coderwall Badge Script for Blogs (or any other Web Page)
# coderwall.coffee
# Display coderwall.com badges
username = "hermanjunge"
el = $(".coderwall")
$.getJSON "http://www.coderwall.com/#{username}.json?callback=?", (data) ->
el.empty()
for item in data.data.badges
$("<img>")
.attr(
@potomak
potomak / git_colors.sh
Created September 21, 2011 12:54
Git colors
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
@mcollina
mcollina / country.json
Created November 8, 2011 21:56
SharpNodes Use Case 1 APIs
// GET /COUNTRY/[COUNTRY_NAME]
{
"opennet_filtering_data": {
"political": {"score": INT},
"social": {"score": INT},
"tools": {"score": INT},
"conflict_security" : {"score": INT}
},
"google_removal_requests": {