Skip to content

Instantly share code, notes, and snippets.

View kaiquewdev's full-sized avatar

Kaique Silva kaiquewdev

View GitHub Profile
var Event = function Event() {};
// Define a private method
Event.prototype._target;
// Define a set value function
Event.prototype.set = function set( value ) {
value = value || '';
if ( value ) {
var Event = (function () {
var Event = function Event() {};
Event.prototype._target;
Event.prototype.set = function set( value ) {
value = value || '';
if ( value ) {
_target = value;
@kaiquewdev
kaiquewdev / exchange.py
Created April 6, 2012 05:47
Get a value of a place in web page
#!/usr/bin/env python
# coding: utf-8
class Exchange( object ):
def __init__( self, url ):
'''
External Dependencies: Pycurl and BeautifulSoup
'''
output = False
try:
@kaiquewdev
kaiquewdev / semicolon.js
Created April 25, 2012 16:45
Exemplo do uso das chaves e terminador com ponto e virgula.
var range = function ( sequence ) {
var output = []
if ( sequence !== undefined )
for ( var pointerSequence = 0, end = sequence; pointerSequence <= end; pointerSequence += 1 )
if ( pointerSequence > 0 )
output.push( pointerSequence )
return output
}
@kaiquewdev
kaiquewdev / gist:2655801
Created May 10, 2012 20:49 — forked from wesbos/gist:1476820
PhantomJS Screenshot
var page = new WebPage(),
address, output, size;
address = "http://www.metachunk.com/";
width = 1024; height = 600;
output = "./screenshots/wat-"+width+"X"+height+".png";
page.viewportSize = { width: width, height: height };
if (phantom.args.length === 3 && phantom.args[1].substr(-4) === ".pdf") {
@kaiquewdev
kaiquewdev / encontel.js
Created May 21, 2012 17:04
Decode letters to phone number.
#!/usr/bin/env node
var phoneDecode = function ( input ) {
var output = '';
var letters = {
ABC: 2,
DEF: 3,
GHI: 4,
JKL: 5,
MNO: 6,
@kaiquewdev
kaiquewdev / drag.js
Created May 23, 2012 13:19 — forked from mattheworiordan/drag.js
Drag and drop example for Titanium
var circle = Titanium.UI.createView({
height:200,
width:200,
borderRadius:50,
backgroundColor:'#336699',
top:10,
left:50
});
currentWindow.add(circle);
@kaiquewdev
kaiquewdev / server-example.js
Created May 31, 2012 01:03
Servidor http simples usando node.js
// Servidor HTTP
var http = require( 'http' );
var server = http.createServer( function ( request, response ) {
var body = {
type: 'text/plain',
content: 'Hello World!',
};
response.writeHead( 200, {
#!/usr/bin/env python
def cozimento( tempo_cozimento=0, a=0, b=0 ):
output = False
if tempo_cozimento and a and b:
if a > tempo_cozimento < b:
# Other stuff
tempo_minimo = min( a, b )
tempo_maximo = max( a, b )
@kaiquewdev
kaiquewdev / miojo-test.py
Created July 12, 2012 04:35
Teste do miojo
import unittest, miojo
class MiojoTest( unittest.TestCase ):
def test_falha_quando_nao_recebe_entradas( self ):
self.assertEquals( False, miojo.cozimento() )
def test_tempo_cozimento_sempre_menor( self ):
self.assertEquals( False, miojo.cozimento( 10, 7, 5 ) )
def test_tempo_para_comparacao_do_cozimento( self ):