Skip to content

Instantly share code, notes, and snippets.

View fhferreira's full-sized avatar
🏠
Home-Office since 2005

Flávio H. Ferreira fhferreira

🏠
Home-Office since 2005
View GitHub Profile
var e = new Array;
e.AF = "Afghanistan",
e.AL = "Albania",
e.DZ = "Algeria",
e.AS = "American Samoa",
e.AD = "Andorra",
e.AO = "Angola",
e.AI = "Anguilla",
e.AQ = "Antarctica",
e.AG = "Antigua And Barbuda",
@fhferreira
fhferreira / webhook.php
Created May 27, 2021 19:58
Verify signature webhook - hash_hmac sha256
<?php
$webhook = fopen('php://input', 'rb');
$webhook_content = "";
while (!feof($webhook)) {
$webhook_content .= fread($webhook, 4096);
}
fclose($webhook);
$webhook_data = json_decode($webhook_content, true);
$signature = $webhook_data["signature"];
@fhferreira
fhferreira / debug-fpm-segfaut.md
Created May 5, 2021 14:24 — forked from guilhermeblanco/debug-fpm-segfaut.md
Debugging PHP-FPM segfaults

Assuming PHP is compiled with debug enabled.

$ gdb /usr/sbin/php-fpm

Then:

r --nodaemonize --fpm-config /etc/php7/fpm/php-fpm.conf
@fhferreira
fhferreira / Dockerfile
Created April 28, 2021 16:25 — forked from evansims/Dockerfile
Dockerfile: php-fpm 7.4-fpm alpine w/ gd bz2 intl mbstring redis mongodb xdebug opcache
FROM php:7.4-fpm-alpine
WORKDIR "/application"
# Install essential build tools
RUN apk add --no-cache \
git \
yarn \
autoconf \
g++ \
make \
@fhferreira
fhferreira / addrgen
Created April 27, 2021 15:06 — forked from JBaczuk/addrgen
addrgen
#!/bin/bash
echo
echo "Welcome to the Bitcoin address generator!"
echo "input private key (32 bytes, hex format)"
read priv
echo ""
echo "#####################################"
# priv=0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D # Testing only
@fhferreira
fhferreira / bitcoin.js
Created April 3, 2021 22:44 — forked from sanjukurian/bitcoin.js
create bitcoin wallet, make a transaction on bitcoin network using bitcoinjs-lib and blockcypher
var request = require('request');
const bitcoin = require('bitcoinjs-lib');
var buffer = require('buffer');
const bitcoinNetwork = bitcoin.networks.testnet;
var rootUrl = "https://api.blockcypher.com/v1/btc/test3";
//create wallets
const TestNet = bitcoin.networks.testnet3;
@fhferreira
fhferreira / LearnGoIn5mins.md
Created January 14, 2021 03:53 — forked from prologic/LearnGoIn5mins.md
Learn Go in ~5mins
<?php
namespace App\Helpers\Mail;
/**
* This is a complete rewrite to use the Mandrill API
*
* @author fhferreira
* @version 2020-12-23
* @link https://mandrillapp.com/api/docs/messages.JSON.html#method=send
@fhferreira
fhferreira / sigep.php
Created December 21, 2020 14:12 — forked from viebig/sigep.php
Exemplo de requisição para geração de etiquetas do correios
<?php
$usuario = 'sigep';
$senha = 'n5f9t8';
$contrato = '9912208555';
$cartao = '0057018901';
$context = stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
<?php
/*
This is a demo task.
Write a function that, given an array A of n integers, returns the smallest positive integer (greater than 0) that does not occur in A.
For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5.
Given A = [1, 2, 3], the function should return 4.
Given A = [-1, -3], the function should return 1.