Skip to content

Instantly share code, notes, and snippets.

def run_pg_fouine():
info = host_info[env.host_string]
db_name = info.tags.get('Name')
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 0/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
time.sleep(30)
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 500/" /etc/postgresql/9.*/main/postgresql.conf')
sudo('/etc/init.d/postgresql reload')
run('tail -n 100000 /var/log/postgresql/postgresql-9.*-main.log > /tmp/pgfouine.txt')
run('gzip -f /tmp/pgfouine.txt')
@matheustp
matheustp / rxjs-diagrams.md
Created April 22, 2019 14:19 — forked from PCreations/rxjs-diagrams.md
Super Intuitive Interactive Diagrams to learn combining RxJS sequences by Max NgWizard K
@matheustp
matheustp / Install Cloud9 on local or remote computer, server, or raspberry pi This gist will help you install Cloud9 on your local or remote computer, server, or even your raspberry pi. Many people are having issues at the time of this Gist's creation.
Complete installation process:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y python-software-properties python make build-essential g++ curl libssl-dev apache2-utils git libxml2-dev
sudo apt-get update
sudo apt-get upgrade
cd ~
mkdir git
cd ~/git
@matheustp
matheustp / reflection.go
Created January 30, 2019 15:23 — forked from drewolson/reflection.go
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@matheustp
matheustp / index.html
Last active December 20, 2018 16:09
Folder list html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Folder Structure</title>
<style>
.container {
display: block;
@matheustp
matheustp / django_cheat_sheet.md
Created November 4, 2018 03:58 — forked from bradtraversy/django_cheat_sheet.md
Django command cheat sheet

Django 2.x Cheat Sheet

Creating a virtual environment

We need to create a virtual env for our app to run in: More Here Run this command in whatever folder you want to create your venv folder

python -m venv ./venv
@matheustp
matheustp / validarTituloEleitor.js
Last active October 31, 2017 18:46
Código de validação do titulo de eleitor extraído do site do TSE
const getDataFromInscricao = ( inscricao ) => [
inscricao.substr( inscricao.length - 2, 2 ),
inscricao.substr( inscricao.length - 4, 2 ),
inscricao.substr( 0, inscricao.length - 2 )
]
const calcSum1 = ( titulo ) =>
titulo.substr( 0, 8 ).split( '' ).reduce( ( total, val, i ) => total += val * ( 9 - i ), 0 )
const fixDigit = ( exce ) => ( dig ) =>
@matheustp
matheustp / cpfRefatorado.js
Last active July 15, 2017 21:15
CPF Refatorado
const getDigit = ( cpf ) => cpf.slice( 9 )
const mod11 = ( num ) => num % 11
const generateArrayOfLength = ( length ) => Array.from( { length }, ( v, k ) => k )
const invalidCpfs = generateArrayOfLength( 10 ).map( val => `${ val }`.repeat( 11 ) )
const isEqual = ( val1 ) => ( val2 ) => val1 === val2
const isIn = ( list ) => ( num ) => list.findIndex( isEqual( num ) ) >= 0
const isInInvalidCpf = isIn( invalidCpfs )
const NOT = ( val ) => !val
const getCpfAsArrayWithoutDigit = ( cpf ) => cpf.split( '' ).slice( 0, 9 )
const calcSumDigit = ( multiplier, digit, sum ) => sum + ( digit * multiplier )
@matheustp
matheustp / anoBissexto.js
Created June 17, 2017 06:21
Verifica se o ano é bissexto
const ehMultiplo = ( multiplo ) => ( ano ) => ano % multiplo === 0
const nao = ( entrada ) => !entrada
const ehMultiploDe400 = ehMultiplo( 400 )
const ehMultiploDe4 = ehMultiplo( 4 )
const ehMultiploDe100 = ehMultiplo( 100 )
const ehBissexto = ( ano ) => (ehMultiploDe400( ano ) || (ehMultiploDe4( ano ) && nao(ehMultiploDe100( ano ))))
console.log(ehBissexto(2016))
console.log(ehBissexto(1600))
const divisors = [...Array(10).keys()].slice(1) //Poderia ser qlqr array, apenas mantive o que ja tava no codigo
const divisorNotEqual1 = (number) => number != 1
const divisorNotEqualNumber = (divisor, number) => divisor != number
const isDivisible = (number) => (divisor) => divisorNotEqual1(divisor) && divisorNotEqualNumber(divisor, number) && number % divisor === 0
const allDivisors = (numberIsDivisibleBy) => divisors.filter(numberIsDivisibleBy)
const isPrime = (number) => {
const divisors = allDivisors(isDivisible(number))
if (divisors.length == 0) {