Skip to content

Instantly share code, notes, and snippets.

View guiman's full-sized avatar

Alvaro Fernando Lara guiman

View GitHub Profile
@guiman
guiman / ruby weirdness
Created July 2, 2015 11:47
Ruby 2.1.4 defines variables on unexecuted if block conditions
$ irb
irb(main):001:0> that
NameError: undefined local variable or method `that' for main:Object
from (irb):1
from /Users/guiman/.rbenv/versions/2.1.4/bin/irb:11:in `<main>'
irb(main):002:0> (true) ? this = "a" : that = "b"
=> "a"
irb(main):003:0> that
=> nil
@guiman
guiman / Dockerfile
Created May 3, 2015 09:13
Example dockerfile for rails app
FROM ruby:2.2
MAINTAINER Alvaro F. Lara <alvaro.lara@alliants.com>
ENV HOME /home/app
ENV RAILS_ENV development
EXPOSE 8080
RUN useradd -m -s /bin/bash app
@guiman
guiman / deploy.rb
Created May 2, 2015 21:08
Example Mina script for Rails app and Unicorn
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv'
set :domain, 'your_server'
set :user, 'ubuntu'
set :deploy_to, '/path/to/app'
set :app_path, "#{deploy_to}/#{current_path}"
set :repository, 'repo'
@guiman
guiman / config.rb
Last active October 26, 2018 13:50
Example mina deploy script using docker
require 'mina/git'
require 'mina/nginx'
set :application, 'your_app_name'
set :domain, 'your_server'
set :user, 'ubuntu'
set :deploy_to, '/location/to/deploy'
set :app_path, "#{deploy_to}/#{current_path}"
set :repository, 'your_repo'
set :branch, 'master'
@guiman
guiman / balancing_two_docker_containers
Created April 28, 2015 14:20
A description of a nginx configuration for two Docker containers
upstream demo.localhost {
server 127.0.0.1:3001;
}
server {
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server_name demo1.localhost;
location / {
### Keybase proof
I hereby claim:
* I am guiman on github.
* I am guiman (https://keybase.io/guiman) on keybase.
* I have a public key whose fingerprint is 8547 0C03 E8F5 E653 6A69 5DD7 D450 C55E 104D 5903
To claim this, I am signing this object:
@guiman
guiman / 0_reuse_code.js
Created March 1, 2014 16:44
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@guiman
guiman / Gemfile
Created May 9, 2013 15:01
Well I think there is something wrong with DataMapper::Collection slice, when mixing queries and slices. Any thoughts? I'm working on what seems to be an issue
# A sample Gemfile
source "https://rubygems.org"
gem 'data_mapper'
gem 'dm-sqlite-adapter'
@guiman
guiman / install_rails_4
Last active December 10, 2015 05:29
Work in progress for a rails 4 instalation script using bundler for Mac/Linux systems
TMP_DIR="/tmp/installing_rails_4"
USER_BIN_DIR="~/bin"
curr=`pwd`
if [ -d "$TMP_DIR" ]; then
rm -rf $TMP_DIR
fi
mkdir $TMP_DIR
cd $TMP_DIR
@guiman
guiman / active_area_mechanism
Created November 2, 2012 19:32
Javascript active area mechanism draft
/*
Javascript Active area.
-----------------------
So this is pretty much what it does, you define areas and this code
allows you to verify if your data source is retreiving points
in any of the defined areas.
*/