Skip to content

Instantly share code, notes, and snippets.

View guilhermesouza's full-sized avatar

Guilherme Souza guilhermesouza

View GitHub Profile
@guilhermesouza
guilhermesouza / modelo_django.sql
Created July 14, 2015 23:57
Converter o script de SQL para um modelo do Django (models.py).
CREATE TABLE "user" (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(128) NOT NULL,
email VARCHAR(128) NOT NULL UNIQUE,
hashedPassword VARCHAR(128) NOT NULL,
salt VARCHAR(128) DEFAULT '' NOT NULL,
readonly BIT DEFAULT 0 NOT NULL,
admin BIT DEFAULT 0 NOT NULL,
map VARCHAR(128) DEFAULT 'osm' NOT NULL,
language VARCHAR(128) DEFAULT 'en' NOT NULL,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$.getJSON('estados_cidades.json', function (data) {
@guilhermesouza
guilhermesouza / 0_reuse_code.js
Created January 14, 2014 16:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#Problema quando o numeros comecam com 0:
#PacketData = '78781F120A03170F3217CC027AC7EB0C46584900148F01CC00287D001FB8000380810D0A'.decode('hex')
#PacketData = 'xx\x1f\x12\n\x03\x17\x0f2\x17\xcc\x02z\xc7\xeb\x0cFXI\x00\x14\x8f\x01\xcc\x00(}\x00\x1f\xb8\x00\x03\x80\x81\r\n'
def gpsDateTime(PacketData): # Example: '2010-03-23 15:30:23'
datahora = PacketData[4:10-len(PacketData)].encode('hex')
Year = datahora[:2]
Month = datahora[2:4]
Day = datahora[4:6]
Hour = datahora[6:8]
Minute = datahora[8:10]
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh
@guilhermesouza
guilhermesouza / crc-16java
Created October 7, 2013 20:58
crc-16java - Exemplo de CRC em JAVA
/*
* Copyright 2012 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@guilhermesouza
guilhermesouza / CRC-16-ITU
Last active April 30, 2021 18:46
CRC-GT06 - How do I calculate the CRC-16-ITU? You can share the code here?
#!/usr/bin/env python
'''
calc-crc16
Created by Guilherme Souza on 19/09/13.
Copyright (c) 2013 Guilherme Souza. All rights reserved.
'''
s = '0d0101234567890123450001'
#s = '123456789'
@guilhermesouza
guilhermesouza / CRC16-bit
Created September 17, 2013 15:11
Code fragment of the CRC-ITU lookup table algorithm implemented based on C language
static const U16 crctab16[] = {
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
@guilhermesouza
guilhermesouza / gist:3779427
Created September 25, 2012 01:21 — forked from pithyless/gist:1208841
Install Python 2.7 (homebrew + pip + virtualenv) on Mac OS X Lion

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...

@guilhermesouza
guilhermesouza / .gitignore
Created September 2, 2012 17:44
Arquivo default .gitignore
# A decent default .gitignore
# Same as GitHub's at https://github.com/github/gitignore/blob/master/Python.gitignore
# except keeps /bin directory.
*.py[co]
# Packages
*.egg
*.egg-info
dist