Skip to content

Instantly share code, notes, and snippets.

View mingomax's full-sized avatar
🏠
Working from home

Domingos Teruel mingomax

🏠
Working from home
View GitHub Profile
@mingomax
mingomax / cloudSettings
Last active December 4, 2020 08:32
Visual Studio Code Insiders Settings
{"lastUpload":"2020-12-04T08:32:22.967Z","extensionVersion":"v3.4.3"}
@mingomax
mingomax / generate-ssh-key.sh
Created June 18, 2018 13:01 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
@mingomax
mingomax / Monitoring.php
Last active April 18, 2017 14:14
Class Monitoring Server
<?php
declare(strict_types = 1);
namespace Cellmidia\Monitoring;
/**
* Class Monitoring
* @package Cellmidia/Monitoring
*
* @author Domingos Teruel <mingomax@dteruel.net.br>
@mingomax
mingomax / gist:aa464163dc6c87065a421eb3bf60dd4c
Created October 11, 2016 22:49 — forked from imluxin/gist:5858665
Get random table row with doctrine DQL in Symfony2
<?php
//
// Theory (for MySQL): http://jan.kneschke.de/projects/mysql/order-by-rand/
//
class QuestionRepository extends EntityRepository
{
public function findOneRandom()
{
$em = $this->getEntityManager();
Options -MultiViews
RewriteBase /web
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !\.(js|ico|gif|jpg|png|css|htm|html|txt|mp3)$ index.php [QSA,L]
RewriteRule .? - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
FallbackResource /index.php
@mingomax
mingomax / date_grab.php
Created November 26, 2014 15:58
Tratamento de diversos formato de data em PHP
<?php
function date_grab($str)
{
// regex pattern will match any date formatted dd-mm-yyy or d-m-y with
// separators: periods, slahes, dashes
$p = '{.*?(\d\d?)[\\/\.\-]([\d]{2})[\\/\.\-]([\d]{4}).*}';
$date = preg_replace($p, '$3-$2-$1', $str);
return new \DateTime($date, new DateTimeZone('America/Sao_Paulo'));
}
<?php
Class Route
{
//TRAP REQUESTS ARRAY:
public static $request;
private static $param;
public static function matchURI($uri = null) {
@mingomax
mingomax / gist:9161766
Created February 22, 2014 20:22
Updating SSH private keys on OSX Mavericks 10.9
Here is a method for updating SSH private keys to work with OS X 10.9 Mavericks, using Terminal commands.
cd /Users/nameofuser/.ssh
cp id_rsa{,.bak}
chmod +w id_rsa id_rsa.pub
openssl rsa -in id_rsa -out id_rsa # decrypt in place
openssl rsa -in id_rsa -aes256 -out id_rsa # encrypt in place
ssh-keygen -y -f id_rsa > id_rsa.pub # regen public key
chmod 400 id_rsa id_rsa.pub
#source
@mingomax
mingomax / functions.php
Created January 28, 2014 19:34
Parse para tratar a seguite estrutura de dados @[12334243:Fulando Cilano]
<?php
/**
* Funcao auxiliar que processa o conteudo e retira os usuarios mencionados no post
* @author Domingos Teruel
**/
function split_content_mentioneds($content) {
$pattern = "/((@\[(\d)+\:)([\w\d\s\_\.(\:){2}]+)\])/";
//Cria os links para os perfis mencionandos
$html = preg_replace_callback(
$pattern,
@mingomax
mingomax / mysql_bkp.sh
Created December 12, 2013 15:49
Exemplo de uso do bash do linux para criar uma função que realiza do DUMP de todas as tabelas de um servidor mysql.
#!/bin/bash
#Variaveis de apoio
#IP ou URL do Servidor MySQL
SERVER_MYSQL = 172.1.22.49
#Usuario com os privilegios de SUPER, USAGE, EXECUTE e FILE
USER ="usrbkp"
PWD = "senha"
#Arquivo temporario
FILE_TEMP = "databases"
#Diretório onde os backups residem