Skip to content

Instantly share code, notes, and snippets.

👨‍🎓
I may be slow to respond.

Fernando Jorge Mota fjorgemota

👨‍🎓
I may be slow to respond.
Block or report user

Report or block fjorgemota

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:5223013
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAkABzADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDh/svt+n/2NH2X2/T/AOxrd+zn0H5D/Gj7OfQfkP8AGv8AFc/DzC+y+36f/Y0fZfb9P/sa3fs59B+Q/wAaPs59B+Q/xoAwvsvt+n/2NH2X2/T/AOxrd+zn0H5D/Gj7OfQfkP8AGgDC+y+36f8A2NH2X2/T/wCxrd+zn0H5D/Gj7
@fjorgemota
fjorgemota / PrivateAttributes.py
Last active Dec 11, 2015
Simple example of a pratical method to create private attributes in Python using functions closures
View PrivateAttributes.py
class People:
'''Just a class to save the name of a people'''
def __init__(self, name):
'''Just saves the name of a people'''
obj = {} #A internal variable to save the state of the attribute
def setName(new_name):
'''Just a function to set the name of a people'''
obj["name"] = new_name #It's available in the internal variable representation
self.setName = setName #Just point it to the object
def getName():
@fjorgemota
fjorgemota / convertHTMLtoJS.php
Created Sep 16, 2012
Convert HTML to Javascript using DOM in PHP
View convertHTMLtoJS.php
<?php
function convertHTMLtoJS($html){
if(is_string($html)){
$type = "string";
}
else{
$type = get_class($html);
}
switch($type){
case "DOMDocument":
View functions.php
<?php
/**
* Verifica o papel do usuário.
*
* Exempo de uso:
* if (is_current_user('administrator')) {
* echo 'Olá administrador';
* }
*
* @param string $user
@fjorgemota
fjorgemota / sift3.py
Created Jul 7, 2012
Sift3 in Python
View sift3.py
def sift3(s1,s2, maxOffset):
s1L = len(s1)
s2L = len(s2)
if not s1:
return (not s2 and 0 or s2L)
if not s2:
return s1L
c1 = 0
c2 = 0
lcs = 0
@fjorgemota
fjorgemota / table.html
Created May 17, 2012
Exemplo de Tabela HTML (apenas para fins educativos aqui no curso :P)
View table.html
<table border="0" width="100%">
<!-- Primeira linnha indica o nome das colunas -->
<th>
<td>Coluna 1</td>
<td>Coluna 2</td>
<td>Coluna 3</td>
</th>
<!-- Proximas linhas somente conteudo -->
<tr>
<td>
@fjorgemota
fjorgemota / gist:1975415
Created Mar 4, 2012
Cutucada automática
View gist:1975415
1) Para cutucar automaticamente quem lhe cutuca, acesse a página https://www.facebook.com/pokes pelo Google Chrome e tecle CTRL+SHIFT+I
2) Será aberto um terminal para você digitar o que quiser. Clique em "Console" e cole o seguinte código: setInterval(function(){var els = document.querySelectorAll("a.uiIconText[ajaxify*='\\/ajax\\/pokes']");for(var c=0;c<els.length;c++){var el = els[c];var e = document.createEvent("MouseEvent");e.initMouseEvent("click",true,true);el.dispatchEvent(e)}},1000)
3) Dê ENTER e deixe a aba aberta..Pronto! Agora quem lhe cutucar será re-cutucado em 1 segundo. :)
4) Agradeça ao http://facebook.com/fjorgemota/, ou não, depois desses importantíssimos procedimentos de utilidade PÚBLICA.
@fjorgemota
fjorgemota / patinhos.py
Created Mar 2, 2012
Patinhos em Python (código completamente inútil, mas ok)
View patinhos.py
# -*- coding: cp1252 -*-
import time
ns = range(1,6)
ns.reverse()
for n in ns:
print "%d patinho%s foram passear"%(n,["","s"][n!=1])
print "além das montanhas para brincar"
print "a mamãe gritou"
for x in range(1,5):
print "quá!"
@fjorgemota
fjorgemota / gist:1609192
Created Jan 13, 2012
Benchmarking of my WebServer with the HTTP/1.1 specifications and timeout running in Ubuntu with Python 2.7 and epoll
View gist:1609192
fernando@ubuntu:/etc$ ab -n 10000 -c 25 http://127.0.0.1/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
@fjorgemota
fjorgemota / gist:1519616
Created Dec 25, 2011
Benchmarking of my WebServer - Updated with the HTTP/1.1 Specifications
View gist:1519616
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
You can’t perform that action at this time.