Skip to content

Instantly share code, notes, and snippets.

View joaoneto's full-sized avatar

João Neto joaoneto

View GitHub Profile
@joaoneto
joaoneto / .profile
Last active January 26, 2016 13:31
Mac OS .profile
alias ls="ls -G"
# alias mysql=/usr/local/mysql/bin/mysql
# alias mysqladmin=/usr/local/mysql/bin/mysqladmin
export PATH=$PATH:$HOME/bin
# export PATH=$PATH:/usr/local/mongodb/bin
# export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
### Added by the Heroku Toolbelt
@joaoneto
joaoneto / demo.js
Created July 26, 2013 00:29
This gist is to climb a static server, with just one command, to test the examples of several projects that need a web server. Usage: $ npm install express; curl -ks https://gist.github.com/joaoneto/6085097/raw/761598ddb44f390179617702740fe7fbf62f6187/demo.js | node
var express = require('express'),
app = express(),
port = process.argv[2] || process.env.PORT || 9000,
webroot = process.argv[3] || process.env.WEBROOT || './demo';
app
.use(express.bodyParser())
.use(express.cookieParser())
.use(app.router)
.use(express.static(__dirname + '/' + webroot))
.listen(port, function () { console.log('Demo is running on: http://localhost:' + port); });
@joaoneto
joaoneto / correios.js
Last active July 27, 2017 19:28
Track para os correios
var http = require('http');
var parseTrack = function (data) {
var trackLines = data.replace(/[\r\n]/g, '').replace(/<\/tr>/gi, '</tr>\n').match(/<tr.*?>(.*)<\/tr>/gi);
trackLines.shift();
var parsed = [], parts = [];
var length = trackLines.length;
var details, date, track;
while (length--) {
@joaoneto
joaoneto / jquery_ajax_cors.html
Created April 29, 2013 05:57
jQuery ajax with CORS
<!doctype html>
<html>
<header>
<title>Dev tools</title>
</header>
<body>
<h1>Dev tools</h1>
<div data-scope="main"></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="socket.io.min.js"></script>
@joaoneto
joaoneto / client_oauth.sh
Created April 11, 2013 02:51
Authorize and get token
#!/bin/bash
COOKIE_TMP_FILE=".tmp_cookie"
USER_EMAIL="foo@example.com"
USER_PASSWORD="123"
CLIENT_ID="XXXXXXXXXXXXXXXXXXXXXXXX"
CLIENT_SECRET="abc123"
REDIRECT_URI="http://localhost:3000"
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {
@joaoneto
joaoneto / node_env.py
Created March 30, 2013 19:10
Sublime Text 2 Package NVM node path configuration
# Sublime package NVM node path configuration
# Save this file in:
# ~/.config/sublime-text-2/Packages/node_env.py
import os
os.environ["PATH"] = "/home/joao/.nvm/v0.10.2/bin:/home/joao/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
print "PATH=" + os.environ["PATH"]
@joaoneto
joaoneto / login.test.js
Created March 13, 2013 13:49
Login session test with mocha
var request = require('supertest'),
should = require('should'),
app = require('../server');
var Cookies;
describe('Functional Test <Sessions>:', function () {
it('should create user session for valid user', function (done) {
request(app)
.post('/v1/sessions')
@joaoneto
joaoneto / .bashrc_ps1
Last active December 13, 2015 18:18
Put .bashrc_ps1 in your home (~/) and at the end of your .bashrc add follow lines: if [ -f ~/.bashrc_ps1 ]; then . ~/.bashrc_ps1 fi
# Put .bashrc_ps1 in your home (~/) and at the end of your .bashrc add follow lines:
# if [ -f ~/.bashrc_ps1 ]; then
# . ~/.bashrc_ps1
# fi
RED='\[\e[0;31m\]'
BRED='\[\e[1;31m\]'
BLUE='\[\e[0;34m\]'
BBLUE='\[\e[1;34m\]'
CYAN='\[\e[0;36m\]'
@joaoneto
joaoneto / changelog.php
Last active December 11, 2015 23:48
Transform GIT LOG into a cute format Changelog.md
<?php
/**
* Changelog Markdown
*
* This is a script to transform GIT LOG into a cute format Changelog.md
*
* To use, set executable permissions to this file and execute:
* $ php changelog.php > CHANGELOG.md
*
* Copyright (c) 2014 João Pinto Neto