Skip to content

Instantly share code, notes, and snippets.

View beraldo's full-sized avatar

Roberto Beraldo beraldo

View GitHub Profile
@beraldo
beraldo / gist:1ca4133c8d22f08159c2
Created April 8, 2015 15:50
"Solução" para quem fez gambiarra e salvou números decimais em campo varchar. Neste exemplo, faremos um casting do valor do campo, para, em seguida, somar todos eles
-- Criando uma tabela para armazena ros valores numéricos em campo varchar
-- ATENÇÃO: ISSO É ERRADO! O correto seria usar campo DECIMAL
mysql> create table produtos(
-> valor varchar(10)
-> );
Query OK, 0 rows affected (0.03 sec)
-- Inserindo alguns valores
mysql> insert into produtos values('1,10'), ('2,20'), ('3,30');
@beraldo
beraldo / create-gruntfile.sh
Last active August 29, 2015 14:05
Creates a Gruntfile.js, uglifying all .js files in a given dir. All <file>.js will be uglified and saved as <file>.min.js, in the same dir
#!/bin/bash
#
# Creates a Gruntfile.js, uglifying all .js files in a given dir
# All <file>.js will be uglified and saved as <file>.min.js, in the same dir
#
# EXECUTE THIS SCRIPT IN THE ROOT OF YOUR PROJECT, WHERE THE Gruntfile.js SHALL BE PLACED
# Path to JS dir, from where the files will be uglified
JS_DIR="public/js"
@beraldo
beraldo / check_my_luck.py
Created August 2, 2012 00:13
Programinha simples pra checar se você ficou rico(a) (loteria)
#!/usr/bin/env python
# coding: utf-8
#
# Verifica se você teve sorte e ganhou na loteria
#
# nome do arquivo com as apostas
PLAYS_FILENAME="plays.txt"