Skip to content

Instantly share code, notes, and snippets.

View andersonfraga's full-sized avatar
🧩
Focusing

Anderson Fraga andersonfraga

🧩
Focusing
View GitHub Profile
#!/usr/bin/php
<?php
require '../phpwatcher.php';
phpwatcher(['./module/','./tests/unit/'], '(.*)\.php', function ($_, $objfile) {
echo "\nChanged {$_}\n";
echo ($exec = 'cd ./tests/unit/ && phpunit .') . PHP_EOL;
system($exec);
echo PHP_EOL;
@andersonfraga
andersonfraga / gist:04b9744f1f6e3a55e0dd
Created July 16, 2014 12:10
Tempo retroativo por extenso pt-br
<?php
function dateFormat($date) {
if (!$date) {
return '';
}
$nowDay = new DateTime('now');
$pastDay = new DateTime($date);
@andersonfraga
andersonfraga / wcs.php
Created July 30, 2014 15:10
Code watchers default
#!/usr/bin/php
<?php
require '../phpwatcher.php';
phpwatcher(['./tests/unit/', './module/'], '(.*)\.php', function ($file) {
echo ($exec = "php-cs-fixer fix {$file} --level=all") . PHP_EOL;
system($exec);
echo PHP_EOL;
});
# alias
alias la='ls -la --color=auto'
alias ..='cd ..'
alias .='pwd'
alias www='cd /www'
alias cntfiledir='ls -l | awk "!/^d/{print }" | wc -l'
alias g='git'
export PATH=$HOME/local/bin:$PATH
@andersonfraga
andersonfraga / Main.java
Created September 2, 2014 13:43
BigDecimal?
class Conta
{
private BigDecimal saldo;
public Teste()
{
saldo = new BigDecimal(0.0);
}
@andersonfraga
andersonfraga / ques.sml
Created October 9, 2014 02:24
E em 30mins brincando com esse tal de AliceML...
(********************
Especifique a função mediaListaSemPares que recebe uma lista de inteiros umaLista e retorna a média dos elementos de umaLista, descartando os valores pares (listas com 1 ou nenhum elemento, retornam vazias)
********************)
fun listaSemPares umaLista = List.filter (fn x => x mod 2 <> 0) umaLista;
fun somaLista [] = 0
| somaLista (x::res) = x + somaLista res;
fun mediaListaSemPares [] = 0.0
| mediaListaSemPares umaLista =
@andersonfraga
andersonfraga / index.php
Last active August 29, 2015 14:10
Busca a menor máscara possível em uma lista de CIDRs
<?php
class IPv4Subnet
{
private $address, $mask;
function __construct($ip)
{
list($this->address, $this->mask) = $this->toBin($ip);
}
%%
/**
* Anderson Jean Fraga
* 13180375
* Compiladores - Trabalho 1 - Exercicio 1
*/
%public
%class Lexica_01
@andersonfraga
andersonfraga / gist:824075
Created February 12, 2011 20:16
2º Trabalho de Algoritmos... Remotos 2008
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <conio.h>
#include <io.h>
@andersonfraga
andersonfraga / gist:824063
Created February 12, 2011 19:58
Trabalho de Algoritmos na Faculdade, remotos 2008... :s
/*!
* Integrantes:
* - Anderson Fraga
* - Teu Solano
* - Thiago Garcia
*