Skip to content

Instantly share code, notes, and snippets.

View giacobo1's full-sized avatar

Bruno Giacobo Pinto giacobo1

  • Porto Alegre, Rio Grande do Sul, Brazil
View GitHub Profile
@giacobo1
giacobo1 / evil.ipynb
Created March 13, 2017 07:13
Testing a evil possibility.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@giacobo1
giacobo1 / code2pdf_with_latex
Last active August 4, 2016 01:15
code2pdf - Convert source code to pdf using latex facilities;
#!/usr/bin/env bash
code2pdf() {
suffix=".""$1"
for file in *.$1;
do
output_file="$(basename $file $suffix).tex";
DOCCLASS="documentclass{article}";
@giacobo1
giacobo1 / code2pdf.sh
Created August 2, 2016 22:37
Convert source code files of a given type to pdf in a safe way;
code2pdf() {
suffix=".""$1"
for file in *.$1;
do
vim -c "hardcopy > $(basename $file $suffix).ps" -c "wq" $file;
done
for printable in *.ps;
@giacobo1
giacobo1 / NerdXmasTree.py
Created December 26, 2015 14:37
Merry Cristmas! with a Nerd Xmas Tree :}
#!/usr/bin/env python
"""
Author: Bruno G. Pinto
Nerd Xmas Tree
"""
@giacobo1
giacobo1 / pwm.c
Created December 14, 2015 05:01
PWM FUNCTION
#include <stdlib.h>
#include <stdio.h>
short PWM1_SET_DUTY( short cont, short q, short MAX ) {
if (cont >=0 && cont < MAX) {
cont += q;
}
return cont;
@giacobo1
giacobo1 / console_progressbar_percentage.c
Last active October 12, 2015 08:29
Pogress bar in percentage from within the terminal in C.
#include <stdio.h>
#include <unistd.h>
/*
* Program that simulates a progress status in percentage
* from within the terminal;
*
* Inspired by:
* - http://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console
*
@giacobo1
giacobo1 / max.py
Created September 26, 2015 03:41
An simple algorithm to find the maximum element of a integer vector using a divide and conquer approach.
#!/usr/bin/env python
"""
An Algorithm to find the maximum integer number in a vector using a divide and conquer approach.
It takes a lenght from command line and generates a random vector using this lenght,
then it prints this vector and it's maximum value calculated by the algorithm.
# To run the code: ./max.py lenght
"""
@giacobo1
giacobo1 / spotlight_gist
Created June 30, 2015 22:09
Trecho de código em java para setar uma luz semi-direcional que rotaciona infinitamente.
// Por causa do tamanho e composicao da cena, nem a atenuacao da luz, nem sua posicao ou tamanho dos limites influenciou muito
BoundingSphere lightLimits = new BoundingSphere( new Point3d(0.0f, 0f, 0f), Double.MAX_VALUE );
//PointLight spinningLight = new PointLight( new Color3f(0.0f, 0.0f, 1f), new Point3f(0.0f, 0.0f, 0.0f), new Point3f(0.5f, 0f, 0.0f) );
SpotLight spinningLight = new SpotLight(new Color3f(0.0f, 0.0f, 1f),
new Point3f(0.0f,0.0f,1.0f),
new Point3f(0.1f,0.1f,0.01f),
new Vector3f(0.0f,0.0f,-1.0f),
(float) (Math.PI/4),
0.0f);
@giacobo1
giacobo1 / Decorator
Created March 17, 2015 02:05
A C++ Implementation of the Decorator Design Pattern based on the GoF book.
/**
Author: Bruno G. Pinto
Date: 16/03/15
Implementacao do Padrao Decorator em C++;
Compile & run:
g++ Decorator.cpp && ./a.out
*/
@giacobo1
giacobo1 / word_scramble.c
Created October 9, 2014 02:01
Problema: “Bagunça das palavras” (Word Scramble - 483)
#include <stdio.h>
#include <stdlib.h>
// Passa o nome do arquivo com os dados para o main (argv[1])
// exemplo:
// 1. Compila - gcc main.c -o run
// 2. Rodar - ./run data.in
// Onde data.in eh o arquivo que contem o texto a ser invertido.