Skip to content

Instantly share code, notes, and snippets.

View lucassmagal's full-sized avatar

Lucas S. Magalhães lucassmagal

View GitHub Profile
@lucassmagal
lucassmagal / config.ru
Created October 1, 2012 20:17
Rack::TryStatic
require 'bundler'
Bundler.setup
Bundler.require
require 'rack/contrib/try_static'
use Rack::TryStatic,
:root => "public", # static files root dir
:urls => %w[/], # match all requests
:try => ['.html', 'index.html', '/index.html']
run lambda { [404, {'Content-Type' => 'text/html'}, ['Not Found']]}
@lucassmagal
lucassmagal / .hgrc
Created October 17, 2012 13:48
My .hgrc
[ui]
username=Lucas Sampaio <...>
merge=internal:merge
[extensions]
hgext.extdiff =
hgshelve=~/projects/hgshelve/hgshelve.py
[extdiff]
cmd.meld =
@lucassmagal
lucassmagal / settings.py
Created October 30, 2012 14:11
Sublime text user settings
{
"color_scheme": "Packages/Color Scheme - Default/Solarized (Light).tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_face": "Source Code Pro",
"font_size": 12,
"highlight_line": true,
"highlight_modified_tabs": true,
"line_padding_bottom": 1,
"line_padding_top": 1,
"rulers":
@lucassmagal
lucassmagal / sample.rb
Created November 14, 2012 17:24
sample.rb
class Dog
def set_name( aName )
@myname = aName
end
def get_name
return @myname
end
def talk
@lucassmagal
lucassmagal / dog.rb
Created November 14, 2012 17:28
dog.rb
class Dog
def initialize(name)
@myname = name
end
def set_name( aName )
@myname = aName
end
def get_name
@lucassmagal
lucassmagal / gera_txt.py
Created November 28, 2012 01:09
Salva n numeros ordenados randomicamente em um arquivo
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from random import random, shuffle
TOTAL_NUMBERS = 1000000
def gera_txt(n=TOTAL_NUMBERS):
@lucassmagal
lucassmagal / test.py
Created November 28, 2012 19:04
probleminha básico nos testes
# Dado um usuário logado
user = UserProfileFactory()
# Quando eu acesso a página inicial
response = self.app.get(reverse('home'), user=user)
# Então eu vejo a lista dos ambientes ativos
self.assertContains(response, 'Meus Ambientes')
@lucassmagal
lucassmagal / is_equal.py
Created December 24, 2012 22:10
constant-time algorithm for string comparing in Python. This is a refactoring of a snippet found in http://codahale.com/a-lesson-in-timing-attacks/ to work with strings.
def is_equal(a, b):
result = 0
for x, y in zip(a, b):
result |= ord(x) ^ ord(y)
return result == 0
{
"color_scheme": "Packages/Color Scheme - Default/Solarized (Light).tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_face": "Source Code Pro",
"font_size": 12,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Vintage"
(function(window, $, undefined) {
'use strict';
// code goes here
})(window, jQuery);