Skip to content

Instantly share code, notes, and snippets.

require 'sprockets/directive_processor'
class MiddleIncludeProcessor < Sprockets::DirectiveProcessor
def prepare
@pathname = Pathname.new(file)
@header = ''
@body = data
@included_pathnames = []
@compat = false
object KryoExperiment {
case class SomeClass(x: String, v: String)
case class BigClass(x: String, v: Long, k: Double)
def main(args: Array[String]): Unit = {
val sparkConf1 = new SparkConf()
.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
.registerKryoClasses(Array())
def memoize(func):
def inner(*args):
objeto = args[0]
if not '__cache_memoize__' in objeto.__dict__:
objeto.__cache_memoize__ = {}
chave = tuple([func]) + tuple(args)
if chave in objeto.__cache_memoize__:
return objeto.__cache_memoize__[chave]
else:
class HttpCharset
def initialize(content_type)
@content_type = content_type
end
def encoding
return nil unless @content_type
par = @content_type.split(';').select do |c|
c.split('=').first.strip == 'charset'
end.first
return nil unless par
# -*- encoding: utf-8 -*-
class Conteudo
include Mongoid::Document
field :titulo, :type => String
field :tags, :type => Array, :default => []
end
FBXPTO = {
iniciado: false,
init:function(callback) {
var self = this;
$('body').append('<div id="fb-root"></div>');
window.fbAsyncInit = function() {
FB.init({appId: 'MYID', status: true, cookie: true, xfbml: true});
callback();
self.iniciado = true;
# -*- coding: utf-8 -*-
import redis
import ujson
from django.conf import settings
class RedisMasterSlave():
master_pool = redis.ConnectionPool(host=settings.REDIS.get('master').get('HOST'),
port=settings.REDIS.get('master').get('PORT'),
db='musica')
@timotta
timotta / cli.js
Created July 17, 2012 17:18
Node js tutorial
var dgram = require("dgram");
var fs = require("fs");
var http = require("http");
var udp = dgram.createSocket("udp4");
var buf = new Buffer("ping");
udp.send(buf, 0, 4, 42, '10.10.26.62');
console.log("pinged the object");
var controllers = {
@timotta
timotta / teste-pool.py
Created December 5, 2012 00:31
geventhttpclient connection pool
from geventhttpclient.url import URL
from geventhttpclient.client import HTTPClient
url = URL("http://musica.com.br/artistas/a/")
http = HTTPClient.from_url(url, connection_timeout=1, concurrency=5)
def get():
print "Getting..."
response = http.get(url.path)
try:
@timotta
timotta / teste-pool-2.py
Created December 5, 2012 00:50
geventhttpclient connection pool
import gevent
from geventhttpclient.url import URL
from geventhttpclient.client import HTTPClient
url = URL("http://musica.com.br/artistas/a/")
http = HTTPClient.from_url(url, connection_timeout=5, concurrency=5)
def get():
print "Getting..."
response = http.get(url.path)