Skip to content

Instantly share code, notes, and snippets.

View leite's full-sized avatar
🔍
searching for work

Francisco Leite leite

🔍
searching for work
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
São Paulo(SP) 01000-000 a 19999-999
Rio de Janeiro(RJ) 20000-000 a 28999-999
Espírito Santo(ES) 29000-000 a 29999-999
Minas Gerais(MG) 30000-000 a 39999-999
Bahia(BA) 40000-000 a 48999-999
Sergipe(SE) 49000-000 a 49999-999
Pernambuco(PE) 50000-000 a 56999-999
Alagoas(AL) 57000-000 a 57999-999
Paraíba(PB) 58000-000 a 58999-999
Rio Grande do Norte(RN) 59000-000 a 59999-999
@leite
leite / znc.sh
Created February 24, 2017 01:49
Install znc on a cheap debian-linux hosting
sudo apt-get install libperl-dev libtcl8.6 libtclap-dev libtcl-perl perl-base perl-depends perl-modules python3 python3-dev perl python tcl tcl-tclreadline
curl -O http://ufpr.dl.sourceforge.net/project/swig/swig/swig-3.0.10/swig-3.0.10.tar.gz
tar xf swig-3.0.10.tar.gz
cd swig-3.0.10/
./configure
make && make install
dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
mkswap /var/swap.img
@leite
leite / gauge.php
Last active November 5, 2016 02:47
gauge class
<?php
class Gauge {
static $_sizes = ['B','kB','MB','GB','TB','PB','EB','ZB','YB'];
static $_short = ['%dh%dm%ds', '%sm%ds', '%ds'];
static $_time = [
'%d second', '%d seconds', '%d minute, ', '%d minutes', '%d hour, ', '%d hours'
];
@leite
leite / report.mkd
Created March 23, 2016 21:05
docker and devicemapper

docker and devicemapper

devicemapper is garbage, switch to aufs.

backup images

list images ...

$ docker ps -a
@leite
leite / poolboy_demo.ex
Created March 21, 2016 16:40 — forked from henrik/poolboy_demo.ex
Example of using Poolboy in Elixir to limit concurrency (e.g. of HTTP requests).
defmodule HttpRequester do
use GenServer
def start_link(_) do
GenServer.start_link(__MODULE__, nil, [])
end
def fetch(server, url) do
# Don't use cast: http://blog.elixirsips.com/2014/07/16/errata-dont-use-cast-in-a-poolboy-transaction/
timeout_ms = 10_000
@leite
leite / mysqldump.mkd
Last active March 19, 2016 20:41
compact mysql dump

compact mysql dump

$> mysqldump -u root -p --hex-blob --routines --triggers --compact YOUR_DATABASE_HERE | \
  egrep -v "(^SET|^/\*\!)" | sed 's/ AUTO_INCREMENT=[0-9]*\b//' | \
  sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' > YOUR_DATABASE_HERE.sql
@leite
leite / foo.php
Created March 18, 2016 20:54
debug layout inside template/view in magento
<?php
$req = Mage::app()->getRequest();
error_log(sprintf(
"\nRequest: %s\nFull Action Name: %s_%s_%s\nHandles:\n\t%s\nUpdate XML:\n%s",
$req->getRouteName(),
$req->getRequestedRouteName(), //full action name 1/3
$req->getRequestedControllerName(), //full action name 2/3
$req->getRequestedActionName(), //full action name 3/3
implode("\n\t", $this->getLayout()->getUpdate()->getHandles()),
$this->getLayout()->getUpdate()->asString()
@leite
leite / test.c
Last active March 4, 2016 21:36
test libssh connectivity and iteraction
#include <libssh/libssh.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
int verify_knownhost (ssh_session session) {
int state, hlen;
unsigned char *hash = NULL;
@leite
leite / Category_Attributes.sql
Created March 3, 2016 21:16 — forked from grafikchaos/Category_Attributes.sql
Magento EAV SQL Queries
SET @entityid = 5; -- category's ID
-- Select varchar/string based category attribute values
SELECT ea.attribute_id, ea.attribute_code, eav.value AS 'value', 'varchar' AS 'type'
FROM catalog_category_entity e
JOIN catalog_category_entity_varchar eav ON e.entity_id = eav.entity_id
JOIN eav_attribute ea ON eav.attribute_id = ea.attribute_id
WHERE e.entity_id = @entityid
-- Select integer based category attribute values (includes boolean values)
UNION(