Skip to content

Instantly share code, notes, and snippets.

Avatar

Thiago Locks thiagolcks

View GitHub Profile
@thiagolcks
thiagolcks / ML2-Trabalho-1-Q1.ipynb
Created May 8, 2018
Questão 1 - Classificação
View ML2-Trabalho-1-Q1.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thiagolcks
thiagolcks / DecoratorAbstract.php
Last active Jan 31, 2017 — forked from CMCDragonkai/DecoratorAbstract.php
PHP: DecoratorAbstract - Allows the creation of flexible nested decorators.
View DecoratorAbstract.php
<?php
/**
* DecoratorAbstract allows the creation of flexible nested decorators. All decorators must extend from this class.
* Decorators can be stacked. They can also have methods that overwrite each other.
* Decorators can omit methods that parent decorators have defined and/or child decorators have defined.
* Methods will cascade to the original child object.
* Properties will read and set from the original child object except when your instance has the property defined.
*/
abstract class DecoratorAbstract
@thiagolcks
thiagolcks / letsencrypt.sh
Last active Oct 5, 2016
Script to generate the SSL certificate via Letsencrypt
View letsencrypt.sh
#!/bin/sh
if [ ! -d "/opt/letsencrypt" ]
then
sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
fi
if [ ! -f "/etc/nginx/snippets/letsencrypt.conf" ]
then
echo "location '/.well-known/acme-challenge' {\n default_type 'text/plain';\n root /tmp/letsencrypt;\n}" | sudo tee /etc/nginx/snippets/letsencrypt.conf
@thiagolcks
thiagolcks / README.md
Created Sep 27, 2016 — forked from oodavid/README.md
Backup MySQL to Amazon S3
View README.md

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

@thiagolcks
thiagolcks / app-threads.py
Last active Aug 31, 2016
Playing with threads using Python
View app-threads.py
import threading, time, random
class Counter (threading.Thread):
num = 0
def reset(self):
self.num = 0
def run(self):
while True:
@thiagolcks
thiagolcks / CNPJ.php
Created Dec 10, 2015
Validador de CNPJ para Phalcon
View CNPJ.php
<?php
namespace App\Validators;
use Phalcon\Validation\Message;
use Phalcon\Validation\Validator;
use Phalcon\Validation\ValidatorInterface;
use Phalcon\Validation;
class CNPJ extends Validator implements ValidatorInterface
@thiagolcks
thiagolcks / CPF.php
Created Dec 10, 2015
Validador de CPF para Phalcon
View CPF.php
<?php
namespace App\Validators;
use Phalcon\Validation\Message;
use Phalcon\Validation\Validator;
use Phalcon\Validation\ValidatorInterface;
use Phalcon\Validation;
class CPF extends Validator implements ValidatorInterface
@thiagolcks
thiagolcks / ZName.php
Last active Jul 5, 2016
Class to sanitize user names
View ZName.php
<?php
namespace Library\ZName;
class ZName
{
static private $compound_names = [];
public static function validate($name)
{
@thiagolcks
thiagolcks / Z_Settings_Fields.php
Last active Sep 14, 2015
Class to help create fields with WP Settings API
View Z_Settings_Fields.php
<?php
if ( ! class_exists( 'Z_Settings_Fields' ) ) {
class Z_Settings_Fields {
public function text( $args = array() ) {
$value = esc_attr( get_option( $args['id'] ) );
// Note the ID and the name attribute of the element should match that of the ID in the call to add_settings_field
$html = '<input type="text" class="regular-text" id="' . $args['id'] . '" name="' . $args['id'] . '" value="' . $value . '" />';