Skip to content

Instantly share code, notes, and snippets.

View jnettome's full-sized avatar
🏠
Working from home

João Pedro Netto jnettome

🏠
Working from home
View GitHub Profile
@jnettome
jnettome / config.cfg
Created July 19, 2017 19:59
config.cfg
unbindall
bind "0" "slot10"
bind "1" "slot1"
bind "2" "slot2"
bind "3" "slot3"
bind "4" "slot4"
bind "5" "slot5"
bind "6" "slot6"
bind "7" "slot7"
bind "8" "slot8"
#require 'jwt'
class JsonWebToken
def self.encode(payload, expiration = 24.hours.from_now)
payload = payload.dup
payload['exp'] = expiration.to_i
JWT.encode(payload, Rails.application.secrets.json_web_token_secret)
end
def self.decode(token)
JWT.decode(token, Rails.application.secrets.json_web_token_secret)
@jnettome
jnettome / scraper.rb
Created June 13, 2016 16:00 — forked from Zanfa/scraper.rb
AngelList scraper
require 'open-uri'
require 'angellist_api'
require 'mongoid'
# Load the Startup model
require File.expand_path(File.dirname(__FILE__) + '/app/models/startup')
Mongoid.load!('config/mongoid.yml', :development)
page = 1
startup_ids = []
@jnettome
jnettome / BitmaskOptions (concern)
Created October 19, 2015 21:48
BitmaskOptions
module BitmaskOptions
extend ActiveSupport::Concern
include ActiveModel::Serialization
included do
mattr_accessor :all_options, :all_option_pairs, instance_writer: false
end
# This is a low level method that usually won't be used in public methods
#http://railscasts.com/episodes/189-embedded-association
require 'spec_helper'
shared_examples_for 'bitmask_options' do
# http://stackoverflow.com/questions/16525222/how-to-test-a-concern-in-rails#answer-20010923
# http://stackoverflow.com/questions/25562639/rspec-testing-ar-model-concern-within-described-class-or-dummyclass
let(:model) { described_class } # the class that includes the concern
has_attributes :bitmask_options
it 'has at least one option' do
[alias]
# View abbreviated SHA, description, and history graph of the latest 20 commits
l = log --pretty=oneline -n 20 --graph --abbrev-commit
# View the current working tree status using the short format
s = status -s
# Show the diff between the latest commit and the current state
d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat"
# `git di $number` shows the diff between the state `$number` revisions ago and the current state
di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d"
# Pull in remote changes for the current repository and all its submodules
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
alias pwdcopy='pwd | echo -n $(pwd) | pbcopy'
# Shortcuts
@jnettome
jnettome / clean.rb
Created August 23, 2013 19:40
DatabaseCleaner SQL Server
ActiveRecord::Base.connection.execute "EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
EXEC sp_MSForEachTable '
IF OBJECTPROPERTY(object_id(''?''), ''TableHasForeignRef'') = 1
DELETE FROM ?
else
TRUNCATE TABLE ?
'
EXEC sp_MSForEachTable 'DROP TABLE ?'
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
@jnettome
jnettome / hackme.js.coffee
Created June 26, 2013 19:01
ticket to hell
$ ->
if $('form#new_checkin').length > 0
$('form#new_checkin').on "submit", (e) ->
if $('form#new_checkin').find('#checkin_checkout_date').val() == ""
$('form#new_checkin').find('#checkin_checkout_time').val(" ")