Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Hallison Batista hallison

I may be slow to respond.
Block or report user

Report or block hallison

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
hallison / Decode JWT
Last active Dec 16, 2019
JS - Parse JWT
View Decode JWT
function jwtDecode(token) {
var base64Url = token.split('.')[1];
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
var payload = decodeURIComponent(atob(base64).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
return JSON.parse(payload);
hallison / array-order-items.js
Last active Feb 25, 2019
Order list items in Array
View array-order-items.js
Array.prototype.orderItems = function(newer, older) {
var list = new Array(...this)
return list.splice(newer - 1, 0, ...list.splice(older, 1))
View optparse-template.rb
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
hallison / chat.rb
Created Jan 2, 2012 — forked from rkh/chat.rb
Simple Chat Application using the Sinatra Streaming API
View chat.rb
# coding: utf-8
require 'sinatra'
set server: 'thin', connections: []
get '/' do
halt erb(:login) unless params[:user]
erb :chat, locals: { user: params[:user].gsub(/\W/, '') }
get '/stream', provides: 'text/event-stream' do
hallison / Makefile
Created Jun 27, 2011
Vim-Markdown Makefile
View Makefile
# Configuration
PLUGIN_NAME = markdown
MAKEDIR = build
SRCDIR = src
PKGDIR = pkg
hallison /
Created Jun 6, 2011
Howto use a simple renderer for Spark-Java
package learn;
import static spark.Spark.*;
import spark.*;
import java.util.Map;
import java.util.HashMap;
import java.util.regex.Pattern;
hallison / weblog.rb
Created Sep 18, 2009
Example of how to use Sinatra::Mapping
View weblog.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'sinatra/mapping' # only this line for use mapping!
map :root, "blog" # /blog/
map :entries, "posts" # /blog/posts
map :tags, "labels" # /blog/labels
mapping :entry => "posts/:entry_id", # /blog/posts/id-for-post
hallison /
Created Aug 6, 2009
Example of the Rackup file for a Sinatra application using Sinatra::Mapping extension.
require 'rubygems'
require 'sinatra'
require 'sinatra/mapping'
require 'blogware'
run Sinatra::Application
View Update SVN project from other invalid SVN project
cd <project>
find . -name ".svn" -exec rm -rf {} 2> /dev/null \;
cd ..
cp -ru <project>/* <svn-project>
cd <svn-project>
svn status
hallison / Array to String with commas and "and" before the last element
Created Jul 30, 2008
Array to String with commas and "and" before the last element
View Array to String with commas and "and" before the last element
array = ["one","two","three","four","five"]
join = array[0..-2].join(', ') + " and " + array[-1].to_s + " are numbers that belongs to the array of integers."
puts join
# "one, two, three, four and five are numbers that belongs to the array of integers."
You can’t perform that action at this time.