Skip to content

Instantly share code, notes, and snippets.

View caferrari's full-sized avatar

Carlos A. Ferrari caferrari

View GitHub Profile
@caferrari
caferrari / nginx
Created January 25, 2013 17:39
/etc/logrotate.d/nginx
/var/log/nginx/*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
@caferrari
caferrari / nginx.conf
Created January 25, 2013 17:56
/etc/nginx/nginx.conf
user www-data;
worker_processes 8;
worker_rlimit_nofile 32768;
error_log /var/log/nginx/error.log;
events {
worker_connections 512;
use epoll;
@caferrari
caferrari / pessoal.php
Last active December 12, 2015 04:49
Carregar funcionários do tocantins
<?php
$pages = 554;
$data = array();
$doc = new DOMDocument;
libxml_use_internal_errors(true);
for ($page = 1; $page <= $pages; $page++){
echo "Carregando página: $page" . PHP_EOL;
$body = file_get_contents("http://transparencia.to.gov.br/pessoal/?opt=3&n=&o=&p={$page}");
$body = utf8_encode(utf8_decode($body));
$doc->loadHTML($body);
@caferrari
caferrari / nvm.js
Created April 24, 2013 14:56
Neverwinter classes
var characterData = [
{
'class' : 'Great Weapon Fighter',
'skills' : [
{
name: 'Reaping Strike',
type: 'atwill',
description: 'Hold the button to prepare a powerful sweeping strike that grows in strength the longer you charge it up. While charging your swing, you gain more Determination from taking damage.',
@caferrari
caferrari / textfilesplit.php
Created April 25, 2013 16:27
A simple tool to split csv files in many smaller files
<?php
if ($argc < 2) {
die ('Use textsplit.php /path/do/arquivo linhas');
}
if (!isset($argv[2])) {
$argv[2] = 1000;
}
@caferrari
caferrari / cachePrototype.php
Last active December 19, 2015 08:39
Cache Prototype
<?php
class Controller
{
public function indexAction()
{
$repo = $this->getRepository('User');
@caferrari
caferrari / array_filter.php
Last active May 30, 2019 10:17
array_filter
<?php
// PHP >= 5.3
// resposta: https://www.facebook.com/groups/nao.tem.biscoito/permalink/10153102397605160/
$required = 282261;
$itens = array_filter($seuArray, function($item) use ($required) {
return $item[0] == $required;
});
@caferrari
caferrari / cpf.php
Created July 15, 2013 19:20
preg_replace_cpf
<?php
// resposta: https://www.facebook.com/groups/nao.tem.biscoito/permalink/10153103467920160/
$cpf = preg_replace('@^(\d{3})(\d{3})(\d{3})(\d{2})$@', '$1.$2.$3-$4', '12345678900');
echo $cpf;
{
"meta": {
"code": 200
},
"notifications": [
{
"type": "notificationTray",
"item": {
"unreadCount": 16
}
@caferrari
caferrari / cpf.php
Created November 9, 2013 11:01
cpf.php
<?php
$cpfs = array(
'123.456.789-09',
'2.3.4.4.6.8.2.7.3.4.6',
'528.462.34.278',
'23131378912'
);
foreach ($cpfs as $cpf) {