Skip to content

Instantly share code, notes, and snippets.

@douglascamata
douglascamata / fish_prompt.fish
Created October 28, 2014 22:10
Numist fish prompt
# name: Numist
function fish_prompt
set -l last_status $status
# Colours
set -l cyan (set_color -o cyan)
set -l yellow (set_color -o yellow)
set -l green (set_color -o green)
set -l red (set_color -o red)
set -l blue (set_color -o blue)
@douglascamata
douglascamata / matriz.c
Created March 20, 2011 19:45
matrizes com ponteiros
#include <stdio.h>
#include <stdlib.h>
void le_numeros(int **matriz){
int i;
for(i=0; i<10; i++){
printf("Entre com um número: ");
scanf("%d", (*matriz+i));
}
}
@douglascamata
douglascamata / gist:889452
Created March 27, 2011 18:42
A buildout Python interpreter
import sys
sys.path[0:0] = [
'/home/user/.pythonenvs/video/lib/python2.6/site-packages/nsi.multimedia-0.1.2-py2.6.egg',
'/mnt/hgfs/nsi/aos/video/eggs/nsi.videoconvert-0.1-py2.6.egg',
'/mnt/hgfs/nsi/aos/video/eggs/celery-2.2.4-py2.6.egg',
'/home/user/.pythonenvs/video/lib/python2.6/site-packages/restfulie-0.8.0-py2.6.egg',
'/usr/lib/python2.6/dist-packages',
'/usr/lib/python2.6/dist-packages',
'/home/user/.pythonenvs/video/lib/python2.6/site-packages/Twisted-10.2.0-py2.6-linux-i686.egg',
@douglascamata
douglascamata / tail.py
Created April 27, 2011 04:59
Tail Call Optimization in Python
#!/usr/bin/env python2.4
# This program shows off a python decorator(
# which implements tail call optimization. It
# does this by throwing an exception if it is
# it's own grandparent, and catching such
# exceptions to recall the stack.
import sys
class TailRecurseException:
@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
@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 / 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: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'
require 'llvm/core'
require 'llvm/execution_engine'
class Gerador
def initialize(syntax_tree)
@tree = syntax_tree
end
def compile
matriz = []
for i in range(1,n):
coluna = []
for j in range(1,n):
coluna.append(1)
matriz.append(coluna)