Skip to content

Instantly share code, notes, and snippets.

View oliveiraev's full-sized avatar

Evandro Oliveira oliveiraev

View GitHub Profile
<?php
/**
* Calcula a participação total de cada contribuinte em uma vaquinha
* a partir de suas contribuições iniciais
*
* @param float $total O valor total da vaquinha
* @param float[] $iniciais A parcela inicial de cada contribuinte
* @return float[] A parcela final de cada contribuinte
*/

Keybase proof

I hereby claim:

  • I am oliveiraev on github.
  • I am oliveiraev (https://keybase.io/oliveiraev) on keybase.
  • I have a public key ASC7gWebPQaXflpt5quGwBmSH_cloq_ice6D7P4TwNFxhgo

To claim this, I am signing this object:

@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'`
@oliveiraev
oliveiraev / get_tibia_worlds.php
Last active March 1, 2022 21:35
Get Tibia available Worlds
<?php
$curl = curl_init('https://www.tibia.com/community/?subtopic=killstatistics');
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => 'utf-8',
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_USERAGENT => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36',
@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'),
#!/usr/bin/env /bin/bash
set -e
function writeHeader () {
python3 - ${1} <<EOF
# -*- coding: utf-8 -*-
import sys
import os
@oliveiraev
oliveiraev / convert.py
Created September 15, 2017 23:35
Imprimidor de numeral ordinal.
# -*- coding: utf-8 -*-
u"""Imprimidor de numeral ordinal."""
import sys
UNITS = [
'',
'primeiro',
" Utiliza a área de transferência do sistema
set clipboard=unnamed,unnamedplus
" Navegação por teclas direcionais
noremap <UP> k
noremap <C-UP> (
noremap <RIGHT> l
noremap <C-RIGHT> E
noremap <DOWN> j
noremap <C-DOWN> )
@oliveiraev
oliveiraev / pretty_json
Created November 26, 2014 15:59
Given an input (filename or stdin), prints out it space-indented
#!/usr/bin/env node
/**
* @name JSON Prettifier
* @summary Given an input (filename or stdin), prints out it space-indented
* @license [LGPLv3]{@link https://www.gnu.org/licenses/lgpl-3.0.txt}
* @version 0.0.1a
*
*/
(function () {
"use strict";
@oliveiraev
oliveiraev / Jasmine-to-Casper.js
Last active December 26, 2015 05:49
Convert Jasmine suite into parseable CasperJS test suite.
/**
* Convert Jasmine suite into parseable CasperJS test suite.
*/
casper.parseJasmineTests = (function (casper) {
"use strict";
/**
* Build a structure from Jasmine test results.
*
* Each spec generates an object with two keys: specs and tests.