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
@leite
leite / php.mkd
Last active November 3, 2023 23:35
how to php 5.4.45 (old stable)

ubuntu 14.04 LTS

~ docker run -d -ti --name=xenophon ubuntu:14.04 /bin/bash
~ docker attach xenophon

update && install build essentials plus libraries

root@bdb791349df9:~# sudo apt-get update
@leite
leite / bla.php
Created December 2, 2015 15:37
wtf!
# log / debug
$filename = $this->api_json . 'debug.txt';
$fp = fopen($filename, 'w');
fwrite($fp, "\n\n------- スタート " . $debug['date_start'] . " ----------\n\n");
//fwrite($fp, print_r($result, true));
fwrite($fp, "\n\n------- 終わり " . $debug['date_end'] . " ----------\n\n");
fclose($fp);
echo "end\n";
@leite
leite / pretty_stack_trace.php
Created January 27, 2016 20:58
stack trace php
function stackTrace() {
$stack = debug_backtrace();
$output = '';
$stackLen = count($stack);
for ($i = 1; $i < $stackLen; $i++) {
$entry = $stack[$i];
$func = $entry['function'] . '(';
$argsLen = count($entry['args']);
@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(
@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 / 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 / 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 / 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 / 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 / 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'
];