Skip to content

Instantly share code, notes, and snippets.

@WagnerMatos
WagnerMatos / .rubocop.yml
Created May 9, 2019 14:10 — forked from jhass/.rubocop.yml
My preferred Rubocop config
AllCops:
RunRailsCops: true
# Commonly used screens these days easily fit more than 80 characters.
Metrics/LineLength:
Max: 120
# Too short methods lead to extraction of single-use methods, which can make
# the code easier to read (by naming things), but can also clutter the class
Metrics/MethodLength:
"use strict";
let jwt = require("jsonwebtoken");
let sharedSecret = "shh";
let issuer = "my-awesome-website.com";
const User = require('../../api/models/user');
//Here we setup the security checks for the endpoints
//that need it (in our case, only /protected). This
//function will be called every time a request to a protected
@WagnerMatos
WagnerMatos / something.py
Created October 4, 2018 05:49 — forked from kirang89/something.py
Creating a mutable ARRAY data type in sqlalchemy
class Something(Base):
__tablename__ = 'yaddayadda'
id = Column(Integer, primary_key=True)
data = Column(MutableList.as_mutable(ARRAY(String(100))))
@WagnerMatos
WagnerMatos / generate_twitter_bearer_token.rb
Created November 23, 2017 13:15 — forked from jkotchoff/generate_twitter_bearer_token.rb
Example of how to generate and use a Twitter bearer token for the purpose of performing application-only authentication for the Twitter API
# Generate and use an oauth2 bearer token for the Twitter API in Ruby
#
# For Application-Only authentication to the twitter API, a 'bearer token'
# is required to authenticate agains their endpoints for rate limiting
# purposes.
#
# This script generates a bearer token by posting to twitter and then it
# uses that token to poll their API.
#
# Note, the base 64 encoded consumer credentials for the bearer token needs
@WagnerMatos
WagnerMatos / Procfile
Created September 18, 2017 14:45 — forked from pboling/Procfile
sidekiq initializer
web: bundle exec rails server puma -p $PORT -e $RACK_ENV
critical: env HEROKU_PROCESS=critical bundle exec sidekiq -c 2 -q critical,4
default: env HEROKU_PROCESS=default bundle exec sidekiq -c 4 -q default,2
low: env HEROKU_PROCESS=low bundle exec sidekiq -c 1 -q low,1
@WagnerMatos
WagnerMatos / 0002_sidekiq_initial.config
Created June 29, 2017 15:12 — forked from jeffdeville/0002_sidekiq_initial.config
ElasticBeanstalk Sidekiq configuration
---
restart_sidekiq: &RESTART_SIDEKIQ
mode: "000755"
content: |
#!/bin/bash
initctl restart sidekiq || initctl start sidekiq
ln -sf /var/app/current/log/sidekiq.log /var/app/containerfiles/logs/sidekiq.log
mute_sidekiq: &MUTE_SIDEKIQ
mode: "000755"
content: |
@WagnerMatos
WagnerMatos / 0000_packages.config
Created June 29, 2017 15:12 — forked from gcarrion-gfrmedia/0000_packages.config
AWS Elastic Beanstalk Ruby 2.0/Puma Environment - .ebextensions tweaks and Sidekiq configuration. This is known to work fine with AWS Elastic Beanstalk 's 64bit Amazon Linux 2014.03 v1.0.1 running Ruby 2.0 (Puma) stack. Later stack versions might not work, but for that specific version works fine.
# Install Git needed for Git based gems
packages:
yum:
git: []
@WagnerMatos
WagnerMatos / redis.rb
Created June 28, 2017 11:03 — forked from pubis/redis.rb
Redis config and initialization for rails
#config/initializers/redis.rb
require 'redis'
require 'redis/objects'
REDIS_CONFIG = YAML.load( File.open( Rails.root.join("config/redis.yml") ) ).symbolize_keys
dflt = REDIS_CONFIG[:default].symbolize_keys
cnfg = dflt.merge(REDIS_CONFIG[Rails.env.to_sym].symbolize_keys) if REDIS_CONFIG[Rails.env.to_sym]
$redis = Redis.new(cnfg)
Redis::Objects.redis = $redis
@WagnerMatos
WagnerMatos / syncFilesystemToImage.sh
Created June 27, 2017 20:28 — forked from geoffreyanderson/syncFilesystemToImage.sh
A script to rsync a running Linux OS to an image file (specifically, a 10GB image file for deployment to AWS EC2).
#!/bin/bash
# Run this script on a running Linux OS that you want to be put into an image file.
# Ensure that the system you run this on is less than 10GB in size if you wish to
# deploy the image file to AWS EC2.
# Note: This is based on Michael Fairchild's instance-to-ebs-ami.sh script.
# -https://gist.github.com/249915
imageFile=${1:-"awsImage-$(date +%m%d%y-%H%M).img"}
imageMountPoint=${2:-'/mnt/image'}
extraFilesArchive=${3:-'awsInstanceFiles.tar.gz'}
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten