Skip to content

Instantly share code, notes, and snippets.

View fcoury's full-sized avatar

Felipe Coury fcoury

View GitHub Profile
@fcoury
fcoury / git-branches-by-commit-date.sh
Created July 30, 2016 20:16 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@fcoury
fcoury / id_rsa_encryption.md
Created December 5, 2015 19:20
Encrypt/Decrypt a File using your SSH Public/Private Key on Mac OS X

A Guide to Encrypting Files with Mac OS X

This guide will demonstrate the steps required to encrypt and decrypt files using OpenSSL on Mac OS X. The working assumption is that by demonstrating how to encrypt a file with your own public key, you'll also be able to encrypt a file you plan to send to somebody else using their private key, though you may wish to use this approach to keep archived data safe from prying eyes.

Too Long, Didn't Read

Assuming you've already done the setup described later in this document, that id_rsa.pub.pcks8 is the public key you want to use, that id_rsa is the private key the recipient will use, and secret.txt is the data you want to transmit…

Encrypting

$ openssl rand 192 -out key

$ openssl aes-256-cbc -in secret.txt -out secret.txt.enc -pass file:key

@fcoury
fcoury / simple.js
Created October 30, 2015 17:08 — forked from paton/simple.js
Super simple implementation of define() and require() used in Localize.js (https://localizejs.com)
var define, require;
(function() {
var modules = {};
require = function(name) {
return modules[name]();
};
define = function(name, fn) {
@fcoury
fcoury / gist:3a75bbab390de6a79b3f
Created October 19, 2015 12:33 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3 -y
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
sudo su - postgres -c "psql template1 -p 5433 -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
sudo su - postgres -c "service postgresql stop"
sudo su - postgres -c '/usr/lib/postgresql/9.3/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.3/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.3/main/ -O "-c config_file=/etc/postgresql/9.3/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"'
@fcoury
fcoury / gist:542adb603e221ef82516
Last active August 29, 2015 14:06
Using React.js with Rails

I recently took over a Rails 4.1 project that was in bad shape and part of the problem is that it was using jQuery spaghetti-style code all over. Fixing the bugs in the messy code wasn't something I was really looking forward to.

My natural approach for JavaScript intensive Rails apps that I start from scratch is to use AngularJS, that I love and use already for a handful of projects.

Problem is that I usually go the all-or-nothing way when using AngularJS and Rails. I definitely wouldn't like mixing jQuery with AngularJS in this project.

I have been reading about React.js for quite a while and even played with it a little bit, but nothing too serious. After researching on how people were using React.js in Rails apps, I found two projects that make it a lot more convenient: react-rails and sprockets-coffee-react.

Rails-react

Keybase proof

I hereby claim:

  • I am fcoury on github.
  • I am fcoury (https://keybase.io/fcoury) on keybase.
  • I have a public key whose fingerprint is 9D30 8412 6689 783E B2CD 4617 1235 3BD4 2350 E2FD

To claim this, I am signing this object:

- name: Group by Distribution
hosts: all
tasks:
- group_by: key=${ansible_distribution}
- name: Set Time Zone
hosts: Ubuntu
gather_facts: False
tasks:
- name: Set timezone variables
# Hack to change the Rails cookie serializer from Marshal to JSON and therefore allow the session
# to be shared between different languages but also avoid that someone knowing the
# cookie secret key could execute arbitrary code on the server by unmarshalling
# modified Ruby code added to the session/permanent cookie.
#
# Note that all users will beed to login again since both the remember me cookie and the session cookies
# won't be valid. Note also that the remember me cookie is tested multiple times per request even when it fails.
# for performance reasons you might want to delete it if these extra cycles are too costly for you.
#
# Rails 4 (not tested on Rails 3).
2013-11-14T18:29:45Z 9454 TID-ov2arn2ro CallbackWorker JID-865a5f8bbf3faa55e5ab52c6 INFO: start
2013-11-14T18:29:45Z 9454 TID-ov2armz4k CallbackWorker JID-c300f0701716ab7559153eec INFO: start
2013-11-14T18:29:45Z 9454 TID-ov2armz4k CallbackWorker JID-c300f0701716ab7559153eec INFO: fail: 0.533 sec
/Users/fcoury/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/openssl/buffering.rb:318: [BUG] Segmentation fault
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter