This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- encoding: utf-8 -*- | |
| class Conteudo | |
| include Mongoid::Document | |
| field :titulo, :type => String | |
| field :tags, :type => Array, :default => [] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- 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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'sprockets/directive_processor' | |
| class MiddleIncludeProcessor < Sprockets::DirectiveProcessor | |
| def prepare | |
| @pathname = Pathname.new(file) | |
| @header = '' | |
| @body = data | |
| @included_pathnames = [] | |
| @compat = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()) |
OlderNewer