Skip to content

Instantly share code, notes, and snippets.

View sergiolopes's full-sized avatar

Sérgio Lopes sergiolopes

View GitHub Profile
@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." },
@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 / 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 / lazyload-v2.js
Last active February 11, 2024 23:54
Lazy load de imagens beeem simples
(function(){
// como vamos usar o throttle varias vezes (no scroll e no resize),
// encapsulei essa funcionalidade numa função
function throttle(fn) {
fn.jarodei = false;
return function(){
if (fn.jarodei) return;
fn.jarodei = true;
@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 / osx.sh
Created February 13, 2016 01:35
OSX configs
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true
defaults write com.apple.universalaccess reduceTransparency -bool true
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
defaults write com.apple.finder ShowStatusBar -bool true
defaults write com.apple.Finder AppleShowAllFiles -bool true
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
hash tmutil &> /dev/null && sudo tmutil disablelocal
@sergiolopes
sergiolopes / nginx.conf
Created December 30, 2015 16:42
Mini vimeo proxy
server {
listen 12000;
location / {
set $vimeo_host $arg_host;
resolver 8.8.8.8;
proxy_pass $vimeo_host;
proxy_buffering off;
}
}
@sergiolopes
sergiolopes / 4shared.js
Last active February 11, 2024 23:55
urls do google drive / scribd
javascript:void function(){
var txt = [].slice.call(document.querySelectorAll('.fname h1 a')).map(el => el.href).reduce((url,acc) => acc + '\r\n' + url);
var ta = document.createElement('textarea');
document.body.appendChild(ta);
ta.value = txt;
ta.select();
document.execCommand('copy');
}();
@sergiolopes
sergiolopes / gist:fe4fc275fca6b3115a02
Created November 6, 2015 20:36
weinre webkit angular fix
<script>
function whackWebkitMatchesSelector() {
var oldMatches = Element.prototype.webkitMatchesSelector
function newMatches(selector) {
try {
return oldMatches.call(this, selector)
}
catch (err) {
return false
@sergiolopes
sergiolopes / boleto.js
Created October 30, 2015 13:24
Bookmarklet pra colar codigo de boleto no home banking do santander
javascript:void(function(){
var boleto = prompt();
var partes = boleto.trim().split(/[^\d]+/);
var iframe = document.querySelector('[name="Principal"]').contentWindow.document.querySelector('[name="Corpo"]').contentWindow.document.querySelector('#iframePrinc').contentWindow;
var inputs = iframe.document.querySelectorAll('.lista input');
for (var i = 0; i < inputs.length; i++) {
inputs[i].value = partes[i];