Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View francisco-rojas's full-sized avatar

Francisco Rojas francisco-rojas

  • San Jose, Costa Rica
View GitHub Profile
@francisco-rojas
francisco-rojas / Go Resources.md
Last active May 11, 2019 20:22
The Go Programming Language Book

Commands

Comple a program: $ go build helloworld.go

$ ./helloworld
Hello, BF

Build and install program:

@francisco-rojas
francisco-rojas / Chapter1.md
Last active February 20, 2019 18:50
The Docker Book

Chapter 1: Introduction

  • Containers instead run in user space on top of an operating system’s kernel. As a result, container virtualization is often called operating system-level virtualization.
  • Container technology allows multiple isolated user space instances to be run on a single host.
  • Containers can generally only run the same or a similar guest operating system as the underlying host.
  • Containers have also been seen as less secure than the full isolation of hypervisor virtualization. Countering this argument is that lightweight containers lack the larger attack surface of the full operating system needed by a virtual machine combined with the potential exposures of the hypervisor layer itself.
Docker Images

Images are the building blocks of the Docker world. You launch your containers

@francisco-rojas
francisco-rojas / pg_read_only_user.md
Last active June 6, 2017 13:47
Postgresql read only user
# create user with password
CREATE USER read_user WITH ENCRYPTED PASSWORD 'password';

# grant access to existing tables
GRANT CONNECT ON DATABASE cpu TO read_user;
GRANT USAGE ON SCHEMA public TO read_user;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO read_user;
GRANT SELECT ON ALL TABLES IN SCHEMA public to read_user;
@francisco-rojas
francisco-rojas / ruby_splat.rb
Last active January 12, 2019 04:23
Ruby Splat Operator
# https://gist.github.com/francisco-rojas/db0fb04ed6aa509acc18
# https://dev.firmafon.dk/blog/drat-ruby-has-a-double-splat/
# http://blog.simplificator.com/2015/03/20/ruby-and-the-double-splat-operator/
# http://chriszetter.com/blog/2012/11/02/keyword-arguments-in-ruby-2-dot-0/
# ------------------------------------------------------Method Definition-----------------------------------------------------
puts "\n---Method Definition---\n"
def say(what, *people)
people.each { |person| puts "#{person}: #{what}" }
end
say "Hello!", "Alice", "Bob", "Carl"
@francisco-rojas
francisco-rojas / postgresql.md
Created May 19, 2015 17:56
PostgreSQL recipies

To create a Read only user

Access postgres console:

sudo -u postgres psql

Create user and grant read access to the database

CREATE USER user_name WITH ENCRYPTED PASSWORD 'your_password';
CREATE DATABASE user_name;
@francisco-rojas
francisco-rojas / curl.md
Created May 19, 2015 17:55
CURL recipies

Using curl to log in setting the cookie and extracting the CSRF token:

curl http://localhost:3000/users/sign_in --cookie-jar cookie | grep csrf

curl http://localhost:3000/users/sign_in -L --data "user[email]=user@users.com&user[password]=my_password&authenticity_token=oy4J2HVPezOc5JrTXMyaSjeCDHhN%2Bv5yVzlvShm%2FjFc%3D" --cookie cookie
@francisco-rojas
francisco-rojas / rails_cache_permissions_for_nginx.md
Last active August 29, 2015 14:18
Permissions of tmp and cache folder in rails for nginx (To resolve access denied)

In order to have your cache always created with a group of www-data you need to do the following:

cd yourrailsapp
chgrp www-data ./tmp
sudo chmod g+s tmp

This sets the group id on your folder so that everything underneath tmp gets created with the correct permissions

References:

Name Aliases Description
$! $ERROR_INFO The exception information message set by the last 'raise' (last exception thrown).
$@ $ERROR_POSITION Array of the backtrace of the last exception thrown.
$& $MATCH The string matched by the last successful pattern match in this scope.
$` $PREMATCH The string to the left of the last successful match.
$' $POSTMATCH The string to the right of the last successful match.
$+ $LAST_PAREN_MATCH The last group of the last successful match.
$1 to $9 The Nth group of the last successful regexp match.
$~ $LAST_MATCH_INFO The information about the last match in the current scope.
# CLOSURES IN RUBY Paul Cantrell https://innig.net
# Email: username "cantrell", domain name "pobox.com"
# I recommend executing this file, then reading it alongside its output.
#
# Alteratively, you can give yourself a sort of Ruby test by deleting all the comments,
# then trying to guess the output of the code!
# A closure is a block of code which meets three criteria:
#
@francisco-rojas
francisco-rojas / Redis Utils.md
Last active August 29, 2015 14:12
Redis Useful Commands

Redis Installation (Ubuntu)

  • sudo apt-get install -y python-software-properties
  • sudo add-apt-repository -y ppa:rwky/redis
  • sudo apt-get update
  • sudo apt-get install -y redis-server

Start Redis Server

For development