Skip to content

Instantly share code, notes, and snippets.

@alexdantas
alexdantas / test.rb
Created September 18, 2013 00:23
RubySDL test.
# Awesome test on 'rubysdl' gem
# Complete reference:
#
# http://www.kmc.gr.jp/~ohai/rubysdl_ref_2.en.html
require 'sdl'
begin
SDL.init(SDL::INIT_EVERYTHING)
screen = SDL::Screen.open(200, 200, 0, SDL::HWSURFACE)
@alexdantas
alexdantas / circle.rb
Created September 8, 2013 01:32
Shows circles around the screen with ruby Curses' console interface.
require 'curses'
# Hell yeah
DANI_NUMERO_CIRCULOS = 4
DANI_LIMPAR_TELA = false
# All possible colors.
Colors = {
@alexdantas
alexdantas / pipes.rb
Created September 6, 2013 03:15
Shows a nice screensaver on the terminal with Ruby Curses.
#!/usr/bin/env ruby
#
# pipes.rb: Displays a nice animation on the terminal,
# based on an old screensaver.
#
# If you want to see some action, scroll to the bottom.
# The main code is between "begin" and "end".
#
# This code uses Ruby and it's Curses module to display
# characters on the terminal.
@alexdantas
alexdantas / github-zipball.sh
Created June 3, 2013 18:31
Gets the archived zipball of a GitHub repository
#!/bin/bash
# Gets the archived zipball of a GitHub repository
# $1 user
# $2 repo
LINK="https://github.com/$1/$2/archive/master.zip"
ZIPFILE="$2.zip"
echo "Downloading project '$2' from GitHub user '$1'..."
@alexdantas
alexdantas / batch-sign-gpg-keys.sh
Created April 13, 2013 23:21
Signs several GPG keys, outputting each result on a different file.
#!/bin/bash
# This file signs several GPG keys, outputting
# each result on a different file.
MY_KEY=12345678
KEYS="90123456 78901234 56789012 34567890"
for key in $KEYS
do
gpg --sign-key $key
@alexdantas
alexdantas / fucks.sh
Created November 26, 2012 22:10
Cursing terminal (Keep repeating words that contains 'fuck' until interrupted)
# Keep repeating words that contains 'fuck' until interrupted
yes `grep fuck /usr/share/dict/words` | tr '\n' ' '
@alexdantas
alexdantas / gcd.c
Created June 26, 2012 14:00
Returns the greatest common divisor between two numbers
int gcd (int a, int b)
{
if (b == 0)
return a;
if (a > b)
{
int x = a;
a = b;
b = x;
}