Skip to content

Instantly share code, notes, and snippets.

View FernandoBasso's full-sized avatar

Fernando Basso FernandoBasso

View GitHub Profile
failed_dbs='failed-databases.txt';
errors_file='errors-backup.txt';
dirdate=$(date +'%Y-%m-%d');
# site host user pass dbname
hosts=(
'projeto1 foo.bar.net prjeto1user 1234 projeto1dbname'
'projeto2 foo.bar.net prjeto2user 1234 projeto2dbname'
'projeto3 foo.bar.net prjeto3user 1234 projeto3dbname'
@FernandoBasso
FernandoBasso / function-exression-ES5-vs-ES6.js
Created January 25, 2016 12:25
Using () to force a IIFE in ES5 functions vs in ES6 arrow functions
var l = console.log.bind(console);
// ↓
var jedi1 = ((name, skill) => ({
name: name,
skill: skill
}))('Master Yoda', 'The Force') ;
//↑ ↑ Can't close ) at the end.
l(jedi1.name);
l(jedi1.skill);
@FernandoBasso
FernandoBasso / sed-reverse-lines.txt
Created March 14, 2016 23:43
Trying to understand how "reverse lines" in sed works
file:
AA
BB
CC
DD
sed command:
@FernandoBasso
FernandoBasso / urlize.php
Last active April 15, 2021 10:19
Urlize a string for pretty urls and SEO.
<?php
// Thanks to: http://cubiq.org/the-perfect-php-clean-url-generator
function toAscii( $str, $replace = array(), $delimiter = '-' ) {
if( ! empty( $replace ) ) {
$str = str_replace( ( array ) $replace, ' ', $str);
}
$clean = iconv( 'UTF-8', 'ASCII//TRANSLIT', $str );
$clean = preg_replace( "/[^a-zA-Z0-9\/_|+ -]/", '', $clean );

He who knows not and knows not he knows not, He is a fool - Shun him.

He who knows not and knows he knows not, He is simple - Teach him.

He who knows and knows not he knows, he is asleep - Awaken him.

He who knows and knows that he knows, He is wise - Follow him.

<?php
class Person {
private $name;
public function __construct($name = '') {
$this->name = $name;
}
@FernandoBasso
FernandoBasso / pdotransaction.php
Created May 19, 2016 19:10
Example of PDO transaction with insertion in two tables and a loop on the second one.
<?php
public function salvaPedidoDb() {
try {
$this->db->beginTransaction();
$sql1 = 'INSERT INTO pedidos (pessoa_fk, preco_total) VALUES (:pessoa_fk, :preco_total)';
$sth1 = $this->db->prepare($sql1);
@FernandoBasso
FernandoBasso / quotes-of-wisdom.txt
Last active October 22, 2020 12:28
Quotes of Wisdom
“I fear not the man who has practiced 10,000 kicks once, but I fear the
man who has practiced one kick 10,000 times.”
— Bruce Lee
“Eu não temo o homem que pratiou 10.000 chutes uma vez, mas sim do
homem que praticou um chute 10.000 vezes.”
“Se quiser testar o caráter de uma pessoa, dê poder a ela.”
— Abraham Lincoln
#!/usr/bin/env bash
#tmux new-session -d -s rails 'title rails-development; stty -ixon; vim'
cd ~/develop/projs/html5-audio-player-typescript
title oswp
tmux new-session -d -s oswp
# For some reason, send-keys does nothing here, not even an error is displayed.
━━━━━━━━━━━━━━━━
HASKELL-NOTES1
Fernando Basso
━━━━━━━━━━━━━━━━
Table of Contents
─────────────────