Skip to content

Instantly share code, notes, and snippets.

Avatar

Carlos León mongrelion

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

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 / marshalling.go
Created Jul 24, 2015
Dummy XML marshalling benchmark in Go
View marshalling.go
package marshalling
import (
"encoding/xml"
)
type Foo struct {
Id int `xml:"id,attr"`
Name string `xml:"name,attr"`
Email string `xml:"email,attr"`
View GET trainings.xml
<?xml version="1.0" encoding="UTF-8"?>
<response>
<meta>
<results type="integer">24030</results>
<offset type="integer">0</offset>
<filters type="array"/>
</meta>
<trainings type="array">
<training>
<id type="integer">123</id>
@mongrelion
mongrelion / 001-markdown-benchmark.rb
Created Jun 1, 2012
Ruby Markdown parser libraries benchmark
View 001-markdown-benchmark.rb
%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 Aug 31, 2011
console.log for Java <3
View HelloWorld.java
public class HelloWorld {
public static void main( String[] args ) {
console.log( "Hello, cruel world!" );
}
}
@mongrelion
mongrelion / user.rb
Created Aug 25, 2011
User authorization in controller actions
View user.rb
class User < ActiveRecord::Base
# - Instance Methods -
def is_admin?
self.role.eql? 'admin'
end
end
@mongrelion
mongrelion / logger_redirect.rb
Created Aug 19, 2011
Log into a string var
View logger_redirect.rb
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 Aug 9, 2011
Dynamic Role methods for Role and User models
View role.rb
class Role < ActiveRecord::Base
ROLES = [ :group_admin, :agency_admin ]
# - Relationships -
has_many :user_roles
has_many :users, :through => :user_roles
# - Class Methods -
class << self
You can’t perform that action at this time.