Skip to content

Instantly share code, notes, and snippets.

View oliveiraev's full-sized avatar

Evandro Oliveira oliveiraev

View GitHub Profile
@oliveiraev
oliveiraev / FizzBuzzLite.php
Created July 18, 2011 18:46
Smallest FizzBuzz that I can do
<?php
for($i = 1; $i <= 100; $i++){
$print = $i % 3 ? 'Fizz' : '';
if($i % 5) $print .= 'Buzz';
echo '<p>'.(empty($print) ? $i : $print).'</p>';
}
@oliveiraev
oliveiraev / cookie.js
Created September 20, 2011 16:08
Cookie Handler and manager
<!DOCTYPE HTML>
<html lang="pt-Br">
<head>
<meta charset="UTF-8">
<title></title>
<style>
table {
border: none;
}
@oliveiraev
oliveiraev / Makefile
Created May 29, 2012 18:32
Setup for fresh new Ubuntu-based installations
ifdef SUDO_USER
USER=$(SUDO_USER)
endif
INSTALL=apt-get install -y
INSTALL_LIB=$(INSTALL) lib$(1)-dev
REMOVE = \
apt-get purge -y $(1)*; \
@oliveiraev
oliveiraev / DateFormatter.php
Created June 11, 2012 21:02
Formata de maneira customizada intervalos de data.
<?php
ini_set('date.timezone','America/Sao_Paulo');
class DateFormatter extends DateTime
{
private $parts = array(
array(31104000, 'ano', 'anos'),
array(2592000, 'mês', 'meses'),
array(86400, 'dia', 'dias'),
@oliveiraev
oliveiraev / download_tweets.sh
Created June 20, 2012 16:41
Baixa todos os tuítes de um usuário com timeline pública
#!/bin/bash
if [ ! -d './downloaded_tweets' ]; then
mkdir downloaded_tweets
if [ ! -d './downloaded_tweets' ]; then
echo "Can't create output dir." > /dev/stderr
exit 1
fi
fi
cd downloaded_tweets
@oliveiraev
oliveiraev / youtube-downloader.sh
Last active July 20, 2022 08:42
Download youtube videos
#!/bin/bash
decode() {
to_decode='s:%([0-9A-Fa-f][0-9A-Fa-f]):\\x\1:g'
printf "%b" `echo $1 | sed 's:&:\n:g' | grep "^$2" | cut -f2 -d'=' | sed -r $to_decode`
}
data=`wget http://www.youtube.com/get_video_info?video_id=$1\&hl=pt_BR -q -O-`
url_encoded_fmt_stream_map=`decode $data 'url_encoded_fmt_stream_map' | cut -f1 -d','`
signature=`decode $url_encoded_fmt_stream_map 'sig'`
url=`decode $url_encoded_fmt_stream_map 'url'`
test $2 && name=$2 || name=`decode $data 'title' | sed 's:+: :g;s:/:-:g'`
<!DOCTYPE HTML>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form action="" method="get">
<fieldset>
<legend>Busca de CEP do Correio Control</legend>
@oliveiraev
oliveiraev / remove-bom.pl
Last active December 11, 2015 07:19
Check and remove Byte-order-mark. Original here: http://rishida.net/blog/?p=102
# program to remove a leading UTF-8 BOM from a file
# works both STDIN -> STDOUT and on the spot (with filename as argument)
if ($#ARGV > 0) {
print STDERR "Too many arguments!\n";
exit;
}
my @file; # file content
my $lineno = 0;
#!/bin/bash
if [ ! -d /opt/Sublime* ]; then
if [ ! -f $HOME/Downloads/Sublime*.bz2 ]; then
echo "Ops! You must visit http://www.sublimetext.com/ and download the *.bz2 file to $HOME/Downloads."
exit
else
echo 'Installing Sublime Text...'
sudo mv $HOME/Downloads/Sublime*.bz2 /opt