Skip to content

Instantly share code, notes, and snippets.

View andregumieri's full-sized avatar
🕸️
Making a web

André Gumieri andregumieri

🕸️
Making a web
View GitHub Profile
@andregumieri
andregumieri / bookmarklet_imdb.js
Created January 30, 2014 12:48
Bookmarklet que pega o texto selecionado no browser e abre uma nova aba com uma busca no IMDB.
/**
* Bookmarklet que pega o texto selecionado no browser
* e abre uma nova aba com uma busca no IMDB
*
* SITE PARA CRIAR O BOOKMARKLET
* @link http://mrcoles.com/bookmarklet/
*/
var s = window.getSelection();
if(s.rangeCount) {
@andregumieri
andregumieri / refreshitunes.sh
Created November 7, 2013 17:17
Little bash script to Mac that kills and reopen iTunes. Sometimes iTunes has some problems to stream to Apple TV that is resolved by killing it and opening it again.
#!/bin/bash
killall iTunes
osascript -e "tell application \"iTunes\" to open"
@andregumieri
andregumieri / index.html
Created September 2, 2013 16:50
Verifica se um elemento HTML tem scroll
<!DOCTYPE html>
<html>
<head>
<title>Verifica Scroll</title>
<meta charset="UTF-8" />
<style type="text/css">
#lista {
overflow: scroll;
width: 100%;
height: 100px;
@andregumieri
andregumieri / gist:6242310
Created August 15, 2013 16:36
Executar um script php no terminal (cli) em tela cheia
#!/usr/bin/php
<?php
for($x=0; $x<10; $x++) {
echo "\033[2J\n";
echo "X: " . $x . "\n";
echo "+1: " . ($x+1) . "\n";
echo "+2: " . ($x+2) . "\n";
echo "+3: " . ($x+3) . "\n";
echo "+4: " . ($x+4) . "\n";
@andregumieri
andregumieri / gist:6242158
Created August 15, 2013 16:15
Modificadores do terminal
# http://ascii-table.com/ansi-escape-sequences.php
# limpa tela
echo -n -e "\033[2J"
@andregumieri
andregumieri / cli-cores.php
Created August 13, 2013 22:27
Coloca o texto com cores no terminal (PHP CLI)
#!/usr/bin/php
<?php
$cor_reset = "\033[0m";
$cor_texto = array();
$cor_texto['black'] = "\033[0;30m";
$cor_texto['dark_gray'] = "\033[1;30m";
$cor_texto['blue'] = "\033[0;34m";
$cor_texto['light_blue'] = "\033[1;34m";
@andregumieri
andregumieri / barra-de-progresso.php
Created August 13, 2013 22:03
Barra de progresso para PHP em modo CLI (Command Line Interface)
#!/usr/bin/php
<?php
$total = 20;
$x = 0;
while($x<=$total) {
$progresso = str_repeat("#", $x);
echo "\r[{$progresso}] ({$x} de {$total})";
flush();
$x++;
sleep(1);
@andregumieri
andregumieri / comando-cli.php
Created August 13, 2013 22:00
Aguardar comando no PHP em modo CLI (Command Line Interface)
#!/usr/bin/php
<?php
echo "Tem certeza que deseja continuar? Digite 'sim' para continuar: ";
$handle = fopen ("php://stdin","r");
$line = fgets($handle);
if(trim($line) != 'sim'){
echo "OPERACAO CANCELADA!\n";
exit;
}
echo "Ok. Obrigado por continuar... Nada foi executado.\n";
@andregumieri
andregumieri / activate-app.sh
Created August 13, 2013 21:47
Coloca um aplicativo em primeiro plano – ou abre se estiver fechado – no Mac via comando do terminal.
osascript -e "tell application \"Terminal\" to activate"
@andregumieri
andregumieri / curl_resume.php
Created August 13, 2013 21:44
Faz download de um FTP remoto, usando cURL no PHP, e resumindo o arquivo em caso de queda de conexão.
<?php
$remoteFile = "ftp://host.com/caminho/do/arquivo.zip";
$localFile = "/caminho/do/arquivo-local.zip";
$fo = fopen($localFile, 'a');
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $remoteFile); #input
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FILE, $fo); #output
curl_setopt($curl, CURLOPT_USERPWD, "usuario:Senh@!");