Skip to content

Instantly share code, notes, and snippets.

View mongrelion's full-sized avatar

Carlos León mongrelion

View GitHub Profile
@mongrelion
mongrelion / nginx.conf
Created May 24, 2017 07:58
Nginx configuration for exposing Kubernetes running inside minikube to an external network
events {
worker_connections 1024;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
@mongrelion
mongrelion / config.hcl
Created September 1, 2017 15:08
Nomad pointing to a Consul ran by Nomad itself
data_dir = "/tmp/consul/data"
log_level = "DEBUG"
server {
enabled = true
bootstrap_expect = 1
}
client {
enabled = true

Keybase proof

I hereby claim:

  • I am mongrelion on github.
  • I am mongrelion (https://keybase.io/mongrelion) on keybase.
  • I have a public key whose fingerprint is C717 8EC2 76E2 CC06 240A 9515 3F5C 8A16 C580 25E8

To claim this, I am signing this object:

@mongrelion
mongrelion / 001-markdown-benchmark.rb
Created June 1, 2012 16:07
Ruby Markdown parser libraries benchmark
%w[rubygems open-uri benchmark kramdown bluecloth maruku rdiscount].each do |lib|
require lib
end
n = 1000
md = open('http://maruku.rubyforge.org/maruku.md').read
def parse_md(parser, md)
parser.new(md).to_html
end
@mongrelion
mongrelion / HelloWorld.java
Created August 31, 2011 02:16
console.log for Java <3
public class HelloWorld {
public static void main( String[] args ) {
console.log( "Hello, cruel world!" );
}
}
@mongrelion
mongrelion / user.rb
Created August 25, 2011 02:53
User authorization in controller actions
class User < ActiveRecord::Base
# - Instance Methods -
def is_admin?
self.role.eql? 'admin'
end
end
@mongrelion
mongrelion / logger_redirect.rb
Created August 19, 2011 06:33
Log into a string var
io = StringIO.new
logger = Logger.new io
logger.info "foo"
io.string
=> "I, [2011-08-19T01:34:05.315739 #7354] INFO -- : foo\n"
logger.debug "bar"
io.string
=> "I, [2011-08-19T01:33:04.132831 #7354] INFO -- : foo\nD, [2011-08-19T01:33:08.836753 #7354] DEBUG -- : bar\n"
@mongrelion
mongrelion / role.rb
Created August 9, 2011 03:45
Dynamic Role methods for Role and User models
class Role < ActiveRecord::Base
ROLES = [ :group_admin, :agency_admin ]
# - Relationships -
has_many :user_roles
has_many :users, :through => :user_roles
# - Class Methods -
class << self
@mongrelion
mongrelion / marshalling.go
Created July 24, 2015 18:27
Dummy XML marshalling benchmark in Go
package marshalling
import (
"encoding/xml"
)
type Foo struct {
Id int `xml:"id,attr"`
Name string `xml:"name,attr"`
Email string `xml:"email,attr"`