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
@fhferreira
fhferreira / boilerplate.sh
Created September 19, 2016 03:35
Shell script to create a complete Django project.
# Shell script to create a complete Django project.
# This script require Python 3.x and pyenv and Django 1.10
# The project contains:
# Settings config
# Person model and form
# Person list and detail
# Person create, update and delete
# Admin config
# Tests
@fhferreira
fhferreira / mysql-start.sh
Created August 1, 2016 05:20 — forked from suryart/mysql-start.sh
OSX - Starting MySQL . ERROR! The server quit without updating PID file (/usr/local/var/mysql/<computer_name>.err
// Just empty macbook.local.err file then restart the server
rm /usr/local/var/mysql/macbook.local.err
mysql.server start
@fhferreira
fhferreira / lotofacil.rb
Created July 18, 2016 22:18 — forked from yugi386/lotofacil.rb
Todos os Jogos da Loto fácil - All Games Loto easy
$mapa = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25']
$xmap1 = Array.new
$xmap2 = Array.new
$xmap3 = Array.new
$xmap4 = Array.new
# ----------------------------------------------------------------------------
def formata(palavra)
if palavra.size != 2
palavra = "0" + palavra
<?php
require('parser.php');
define('BOT_TOKEN', 'SEU TOKEN');
define('API_URL', 'https://api.telegram.org/bot'.BOT_TOKEN.'/');
function processMessage($message) {
// processa a mensagem recebida
$message_id = $message['message_id'];
@fhferreira
fhferreira / rm_mysql.md
Created June 23, 2016 17:48 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

brew remove mysql

<?php
namespace App\Support\ViewPresenter;
trait PresentableTrait
{
/**
* View presenter instance.
*
* @var mixed
@fhferreira
fhferreira / blog.md
Created April 8, 2016 04:08 — forked from JacobBennett/blog.md
API Token Authentication in Laravel 5.2

I recently had the need to write a small url shortening application. I am aware that this problem has been solved quite a few times before, but what is being a developer if not reinventing the wheel just for the heck of it? Custom CMS anyone?

Knowing that this was going to be a tiny RESTful API and also knowing that Laravel 5.2 had API rate limiting built in, I was eager to give it a try. Taylor Otwell being Taylor Otwell shipped 5.2 with the rate limiting defaults set up out of the box and I had my application building out short url's in a matter of minutes. The problem for me came when I wanted to start associating those short urls with a user.

Typically my applications have a UI and authentication is done through a simple login page. Obviously for a RESTful API, having a login page isn't ideal. Instead, my hope was to have users append an api_token to the end of their query string and use that to auth

The process starts by creating the CSR and the private key:

openssl req -nodes -newkey rsa:2048 -nodes -keyout dotmarks.net.key -out dotmarks.net.csr -subj "/C=GB/ST=London/L=London/O=dotmarks/OU=IT/CN=dotmarks.net"

Generates

  • dotmarks.net.key
  • dotmarks.net.csr
<?php namespace App\Services\Jwt\Exceptions;
class BeforeValidException extends \UnexpectedValueException { }
@fhferreira
fhferreira / deploy.php
Created February 10, 2016 05:05 — forked from krisnoble/deploy.php
A slightly modified version of Brandon Summers' script. For more information: http://simianstudios.com/blog/post/using-bitbucket-for-automated-deployment-of-multiple-repositories
<?php
date_default_timezone_set('Europe/London'); // Set this to your local timezone - http://www.php.net/manual/en/timezones.php
/**
* The root directory where the repos live.
*
* @var string
*/
$root_dir = '/your/root/dir/';