Skip to content

Instantly share code, notes, and snippets.

def get(self):
key = self._load_request_as_json().get('key')
is_metadata_request = self._load_request_as_json().get('metadata')
response = self.sam.get(key=key).resource()
if hasattr(response.data, 'metadata_key'):
if is_metadata_request:
response = cyclone.web.escape.json_encode({'metadata_key':response.data.metadata_key})
elif response.data.metadata_key:
response = cyclone.web.escape.json_encode({'done':True})
@defer.inlineCallbacks
@cyclone.web.asynchronous
def put(self):
self.set_header('Content-Type', 'application/json')
key = str(uuid4())
today = datetime.today().strftime(u'%d/%m/%y %H:%M')
user = self._get_current_user()[0]
value = self._load_request_as_json().get('value')
if not value:
log.msg("PUT failed!")
@douglascamata
douglascamata / gist:3195859
Created July 29, 2012 02:54
Monkey patch to fix relative url issues with assets in Rails 3.1
module Sass
module Rails
module Helpers
protected
def public_path(asset, kind)
resolver = options[:custom][:resolver]
asset_paths = resolver.context.asset_paths
path = resolver.public_path(asset, kind.pluralize)
if !asset_paths.send(:has_request?) && ENV['RAILS_RELATIVE_URL_ROOT']
path = ENV['RAILS_RELATIVE_URL_ROOT'] + path
@douglascamata
douglascamata / gist:2878100
Created June 5, 2012 21:23 — forked from bernardobarreto/gist:2877446
Sete Atitudes para Hackear a Indústria de Software
Sete Atitudes para Hackear a Indústria de Software
By Klaus Wuestefeld
1) Torne-se excelente.
Seja realmente bom em alguma coisa. Não fique só choramingando ou
querendo progredir às custas dos outros. Não pense q pq vc sentou 4
anos numa faculdade ouvindo um professor falar sobre software q vc
sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo
matriz = []
for i in range(1,n):
coluna = []
for j in range(1,n):
coluna.append(1)
matriz.append(coluna)
require 'llvm/core'
require 'llvm/execution_engine'
class Gerador
def initialize(syntax_tree)
@tree = syntax_tree
end
def compile
@douglascamata
douglascamata / gist:1849308
Created February 17, 2012 00:51
erro estranho
scenario "Relacionar professor com turmas", :driver => :selenium do
periodo_letivo = PeriodoLetivo.create! :sigla => '2012/1', :inicio => Date.today, :termino => Date.tomorrow
professor = Professor.create! :nome => 'Senhor Professor', :email => 'professor@internet.com', :password => 'password'
visit new_disciplina_path
logar_admin('admin@test.com', '123456')
fill_in :nome, with: 'Calculo'
fill_in :credito, with: 4
page.driver.browser.save_screenshot 'screenshot.png'
select '2012/1' , from: 'Periodo letivos'
@douglascamata
douglascamata / ponto_fixo.py
Created December 7, 2011 22:06
Método do ponto fixo para encontrar raízes de uma função
#encoding: utf-8
def ponto_fixo(f, ponto_atual, epsilon=1e-8, maxiter=500):
k = 0
ponto_proximo = f(ponto_atual)
while k < maxiter:
k += 1
ponto_anterior = ponto_atual
ponto_atual = ponto_proximo
@douglascamata
douglascamata / gist:1315262
Created October 26, 2011 02:44
Convert any video file to avi, using xvid and lame
# this AWESOME TOOL can convert any video to an avi/xvid one...
# and the best part is that it's installable in almost any OS (just can't guarantee it'll install in Windows, don't ask my why, ask uncle Bill)
# installation in any debian-like OS will be easy as: [sudo] apt-get install ffmpeg
# in Mac OS X: brew install ffmpeg
# ps.: if you don't use homebrew, try using macports, it should work.
# "video.ogv" is the input video, it can be in any format. And "saida.avi" is the output video.
ffmpeg -i video.ogv -vcodec libxvid -acodec libmp3lame saida.avi
@douglascamata
douglascamata / 1humano.py
Created May 30, 2011 04:03 — forked from rochacbruno/1humano.py
Seres humanos comuns e a reprodução desenfreada orientada a objetos
#encoding: utf-8
class Humano(object):
"""Human Being"""
def __init__(self, nome, pai=None, mae=None):
print "alguem fez besteira e colocou mais um ser Humano no mundo \n"
self.nome = nome
self.pai = pai
self.mae = mae