Skip to content

Instantly share code, notes, and snippets.

@brunoleles
brunoleles / apn_p12_to_pem.sh
Last active February 21, 2017 23:19
Convert Apple Push Notification .p12 files to .pem for use on PHP
# not tested
openssl pkcs12 -in aps_cert.p12 -out aps_cert.pem -nodes -clcerts -passin pass:**** -passout pass:****
# "semi" - tested :]
openssl pkcs12 -in aps_cert.p12 -out aps_cert.pem -nodes -clcerts
# worked
openssl pkcs12 -in aps_cert.p12 -out aps_cert.pem
@brunoleles
brunoleles / rm_docker_containers_imagens.sh
Created April 3, 2017 21:25
delete all docker containers and imagens
#!/bin/bash
#SOURCE: https://techoverflow.net/2013/10/22/docker-remove-all-images-and-containers/
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
# Source
# https://gist.github.com/scottnonnenberg/fefa3f65fdb3715d25882f3023b31c29
# About
# Better Git configuration
# https://blog.scottnonnenberg.com/better-git-configuration/
#
[user]
email = scott@nonnenberg.com
name = Scott Nonnenberg
@brunoleles
brunoleles / run_lumen_on_sub_folder.md
Last active April 6, 2017 16:26
Run Lumen On Sub Folder

How to run Lumen on sub folder

Add this lines after the initialization of the $app variable on public/index.php file.

$SCRIPT_NAME = str_replace(['\\', '/index.php'], ['/', ''], array_get($_SERVER, 'SCRIPT_NAME', array_get($_SERVER, 'PHP_SELF', '')));
$_SERVER['REQUEST_URI'] = preg_replace('|' . $SCRIPT_NAME . '|', '', $_SERVER['REQUEST_URI'], 1);

That's it. 😎

@brunoleles
brunoleles / readme.md
Last active April 8, 2017 17:07
PHP : URL safe base64 functions

Snippet para "url safe" base64 functions

function base64_url_decode($input)
{
    return base64_decode(strtr($input, '-_,', '+/='));
}

function base64_url_encode($input)
{
@brunoleles
brunoleles / Utils.java
Last active April 8, 2017 17:11
Calcula o HASH de uma string e retorna o valor em uma HEX String
/**
* Returns the HexString of a String
* eg.: hashDigest("hello") == "5d41402abc4b2a76b9719d911017c592"
*
* @param input input string
* @param algorithm algorithm to be used to compute the hash ( eg.: "MD5", "SHA1", "SHA-256" )
* @return the hash of the input string
*/
public static String hashDigest(String input, String algorithm)
{
@brunoleles
brunoleles / Access-Control-Allow-Origin.php
Last active May 23, 2017 17:54
Access-Control-Allow-Origin Snipet
<?php
// tells the CDN that the content 'Vary' depending on 'Origin' request header
header('Vary: Origin', true);
// allowed origins
$allowed_http_origins = array(
'http://example.com',
'http://www.example.com',
'http://127.0.0.1',
@brunoleles
brunoleles / MySQL general log on table.md
Last active October 23, 2017 18:59
MySQL general log on table

Save MySQL general log on table instead of a log file.

Turn on general log to table

SET GLOBAL general_log = 'OFF';
ALTER TABLE `mysql`.`general_log` ENGINE = MyISAM;
ALTER TABLE `mysql`.`slow_log` ENGINE = MyISAM;
SET GLOBAL general_log = 'ON';
@brunoleles
brunoleles / Gulp Watch ENOSPC.md
Last active October 30, 2017 20:43 — forked from devhero/node_watch_ENOSPC.js
Error: watch ENOSPC

Gulp Watch Error "ENOSPC"

Execute:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

You should see something like: