Skip to content

Instantly share code, notes, and snippets.

View sergiolopes's full-sized avatar

Sérgio Lopes sergiolopes

View GitHub Profile
var conta = new Conta(900)
var cliente = new Cliente()
// DSL bacana
cliente debita 500 da conta
println(conta saldo)
// classes
class Cliente {
def debita(valor: Int) = new Debito(valor, this)
#!/usr/bin/env python
# A simple python script to grab all your photos from flickr,
# dump into a directory - organised into folders by set -
# along with any favourites you have saved.
#
# Based on FlickrTouchr 1.2 plus:
# - Video download support
# - Photo title on filename
#
/*!
* $.preload() function for jQuery
* Preload images, CSS and JavaScript files without executing them
* Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
* Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
* Demo: http://mathiasbynens.be/demo/javascript-preload
* Note that since this script relies on jQuery, the preloading process will not start until jQuery has finished loading.
*/
$.extend({
@sergiolopes
sergiolopes / svg_stack.py
Created August 12, 2013 19:18
svg_stack com suporte a viewBox e output das coordenadas
#!/usr/bin/env python
## Copyright (c) 2009 Andrew D. Straw
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
@sergiolopes
sergiolopes / build.sh
Created October 28, 2013 13:58
Compressão de HTML, JSP e Tagfiles em build time usando htmlcompressor. O arquivo regex.txt exclui patterns (no caso, scriptlets e diretivas JSP).
java -jar war/WEB-INF/lib/htmlcompressor-*.jar \
--type html --recursive --mask '*.jsp;*.html;*.tag;*.htm' \
--compress-css --compress-js --js-compressor closure \
--remove-intertag-spaces --remove-quotes \
--preserve-server-script -p regex.txt \
-o war/ war/ 2> /dev/null
@sergiolopes
sergiolopes / Gruntfile.js
Created June 10, 2013 22:07
Exemplo mínimo de Grunt.js pro blog da Caelum
module.exports = function(grunt) {
grunt.initConfig({
uglify: {
'build/teste.js': 'src/teste.js'
},
less: {
'build/estilo.css': ['src/*.less']
}
});
@sergiolopes
sergiolopes / nginx.conf
Created April 7, 2016 15:02
config de server static simples com gzip
server {
listen 3030;
root /Users/alura/performance-web/site;
gzip on;
gzip_types text/css application/javascript image/svg+xml;
}
@sergiolopes
sergiolopes / nerdnews.sh
Created June 6, 2016 18:58
Extrai textos das noticias do nerdnews
#!/bin/bash
for PAGINA in {1..2}; do
curl -s -L https://jovemnerd.com.br/categoria/nerdnews/page/$PAGINA/ | sed -n 's/.*href="\(https:\/\/jovemnerd.com.br\/nerdnews\/[^"]*\).*/\1/p'
done | \
while read link; do
curl -s $link > /tmp/nerdtech.html
xmllint --html --xpath '//div[@class="title"]/h2/text()' /tmp/nerdtech.html 2> /dev/null
@sergiolopes
sergiolopes / duracao.sh
Last active April 3, 2018 17:48
Retorna o tempo total em segundos de um arquivo do ScreenFlow
#!/bin/bash
# Retorna o tempo total em segundos de um arquivo do ScreenFlow
#
# Requisito: Dar permissão de acessibilidade pro Terminal ou outra App que vai executar
# (System Preferences > Security & Privacy > Privacy > Accessibility > Add Application)
file=$1
if [ "$file" = "" ] || [ ! -d "$file" ]; then
echo Passe o nome do arquivo pra detectar a duração
@sergiolopes
sergiolopes / gpt.js
Last active July 1, 2023 14:36
Use GPT no Google Spreadcheets com essa função App Script
const SECRET_KEY = "YOUR API KEY";
const MAX_TOKENS = 3000;
const TEMPERATURE = 0.9;
function EMAILALUNO(aluno, nota) {
const url = "https://api.openai.com/v1/chat/completions";
const payload = {
model: 'gpt-3.5-turbo',
messages: [
{ role: "system", content: "Crie um parágrafo de incentivo para um aluno que recebeu uma nota na prova. Vou passar o nome do aluno e a nota." },