Skip to content

Instantly share code, notes, and snippets.

View tangzero's full-sized avatar
🏠
Working from home

Jairinho tangzero

🏠
Working from home
View GitHub Profile
@tangzero
tangzero / act.py
Created October 11, 2009 01:47
PIL compatibles's .act color palette.
from struct import unpack
class Palette:
color_length = 3
def __init__(self, fp):
self.palette = []
for i in range(256):
color = fp.read(self.color_length)
#!/usr/bin/env coffee
sys: require 'sys'
http: require 'http'
server: http.createServer (req, res) ->
res.writeHeader 200, {'Content-Type': 'text/plain'}
res.write 'Hello, World!'
res.end()
@tangzero
tangzero / .bashrc
Created May 11, 2010 18:13
Show some usefull info
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
export PS1='\[\033[1;38m\]\u\[\033[1;32m\] `~/bin/rvm-prompt i v g`\[\033[1;31m\] \W\[\033[1;33m\]`\
git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/[\\\\\1$(parse_git_dirty)]\/` \[\033[37m\]$\[\033[00m\] '
@tangzero
tangzero / resource_helper.rb
Created June 2, 2010 15:39
Resources Spec Helper
def should_behave_like_resource(opts = {})
before :each do
@opts = opts
end
def class_for(str)
str.capitalize.constantize
end
def clazz
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<script type="text/javascript" src="http://assets.vitrine.abril.com.br/js?c=abrilcomtry_blogs"></script>
</head>
<body>
<style>
#vitbox {
float: left;
>>> type(1)
<type 'int'>
>>> type(2.5)
<type 'float'>
>>> type("foobar")
<type 'str'>
>>> variavel = 1
>>> type(variavel)
<type 'int'>
>>> variavel = 2.5
@tangzero
tangzero / Absurdo.java
Created October 12, 2011 19:01
Absurdo
...
if (condition) {
service.doSomething(arg1, arg2, arg3, arg4, arg5, arg6, ... , arg100, true);
} else {
service.doSomething(arg1, arg2, arg3, arg4, arg5, arg6, ... , arg100, false);
}
...
@tangzero
tangzero / http_server.py
Created February 28, 2012 18:33
Basic HTTP Server in Python
#!/usr/bin/env python
import SocketServer
from os.path import getsize
from mimetypes import read_mime_types
from datetime import date
# Mon, 27 Jul 2009 12:28:53 GMT
template = """HTTP/1.1 200 OK
@tangzero
tangzero / invaders.pde
Created September 5, 2012 21:46 — forked from spoike/invaders.pde
Space Invaders Generator
/**
* Space invaders generator. Generates and draws invaders. Inspired
* by invaders fractals:
* http://www.levitated.net/daily/levInvaderFractal.html
*
* Mouse press will create new invaders and draw the new ones.
*/
/** Scaling factor */
float sc = 3f;
@tangzero
tangzero / open_url.py
Created February 28, 2013 18:12
urllib2.urlopen
import urllib2
print urllib2.urlopen("http://www.google.cl").read()