Skip to content

Instantly share code, notes, and snippets.

View possatti's full-sized avatar

Lucas Possatti possatti

View GitHub Profile
@possatti
possatti / Caracteres UTF-8 para Jogos
Created May 13, 2014 02:48
O arquivo é uma página HTML que mostra como alguns caracteres UTF-8 podem ser usados para Jogos de carta e xadrez.
<center>
<h1>Caracteres UTF-8 Jogos</h1>
<h2>Xadrez</h2>
&#9812
&#9813
&#9814
&#9815
&#9816
&#9817
@possatti
possatti / roubar-ceps.js
Created May 15, 2014 20:57
Pega alguns ceps aleatórios de uma página específica.
/**
* Executar usando o PhantomJs.
*/
var page = require('webpage').create();
var url = 'http://www.gerardocumentos.com.br/?pg=gerador-de-cep';
var fs = require('fs');
var fileName = 'ceps.txt';
var ceps = "";
var qtd = 200;
@possatti
possatti / dull-boy.py
Created May 28, 2014 16:24
Inicia um programa que fica invocando outras janelas do gnome-terminal que fazem exatamente a mesma coisa. :|
from subprocess import call
import random
random.seed()
cyclesCount = 0
cyclesToCreateNewInstance = 9999
sentence = "All work and no play makes Jack a dull boy"
def createNewInstance():
call(["gnome-terminal", "-x", "python", "dull-boy.py"])
<html>
<head>
<style>
/*o.v.
big shout out to http://www.jakpsatweb.cz/css/css-vertical-center-solution.html */
.container {display: table; height: 100%; position:absolute; overflow: hidden;width:100%;}
.helper {#position: absolute; #top: 50%;display: table-cell; vertical-align: middle;}
.content {#position: relative; #top: -50%;margin:0 auto;width:200px;border:1px solid orange;}
#!/usr/bin/python
import fileinput
for line in fileinput.input():
print "hello" + line
#!/usr/bin/perl
while(<STDIN>){ # Puts each line at $_ , which can be used in the loop.
chomp; #Implicitly uses $_, if no parameter is specified.
print "hello $_\n"; # Uses $_ explicitly in a string.
}
## It is possible to do a fast little trick on the command line:
# perl -pe '#Transform $_#'
## -n : surround you code with 'while (<>) { #your code# }' .
@possatti
possatti / rot.pl
Last active August 29, 2015 14:04
#!/usr/bin/perl
## Example from http://langref.org/all-languages/strings/reversing-a-string/simple-substitution-cipher
sub rot13 {
my $str = shift;
$str =~ tr/A-Za-z/N-ZA-Mn-za-m/;
return $str;
}
sub rot47 {
// PhantomJS script for rendering a page to an image.
// Author: Lucas Possatti
// Require system to get the command line arguments.
var system = require('system');
// Verify if the program received the proper arguments. And warns the user
// if necessary.
if (system.args.length != 3) {
console.log('Usage: phantomjs picturize.js page_url image_path');
#!/bin/sh
## Simon Says Script
## www.xkcd.com/149
sudo $@
@possatti
possatti / ruby-thread.rb
Created November 17, 2013 05:59
Exemplo do uso de threads em Ruby.
#!/usr/bin/ruby
# Exemplo tirado de http://www.tutorialspoint.com/ruby/ruby_multithreading.htm
def func1
i=0
while i<=2
sleep(2)
puts "func1 at: #{Time.now}"
i=i+1
end