Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am marcel on github.
  • I am marcelmolina (https://keybase.io/marcelmolina) on keybase.
  • I have a public key ASAuJPmRumV3sIFsF6idkKy9B6sUI34TkSaG3HIpdB3tzwo

To claim this, I am signing this object:

View deployment.yaml
# v1beta1.Deployment: Deployment enables declarative updates for Pods and ReplicaSets.
# (apiVersion <string>): APIVersion defines the versioned schema of this
# representation of an object. Servers should convert recognized schemas to the
# latest internal value, and may reject unrecognized values. More info:
# http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#resources
apiVersion:
# (kind <string>): Kind is a string value representing the REST resource this
# object represents. Servers may infer this from the endpoint the client submits
# requests to. Cannot be updated. In CamelCase. More info:
@marcel
marcel / puun-alla-lyrics.txt
Last active Dec 20, 2015
Puun Alla lyrics
View puun-alla-lyrics.txt
Puun alla katselen, (under the tree I watch)
lentäviä tähtiä (the flying stars [shooting stars])
Puun alla uneksin (under the tree i dream of)
Rakkaudesta ikuisesta (love everlasting)
[chorus]
jos voisin kiivetä (if I could climb)
korkealle (way up high)
voisin nähdä kaiken (I could see it all)
@marcel
marcel / extractor.scala
Last active Aug 29, 2015
unapply tuple extraction
View extractor.scala
import scala.util.matching.Regex
import scala.util.matching.Regex.Match
trait RegexExtractor[M] {
def pattner: Regex
def unapply(line: String): Option[M] = {
pattern.findFirstMatchIn(line) map { matches =>
extractMatches(matches)
}
View gist:2957562
require "rubygems"
require "rbench"
require "set"
RANGE = (1..1000)
ARRAY = RANGE.to_a
SET = Set.new(ARRAY)
WORST_CASE_COMPLEXITY = ARRAY.size + 1
@marcel
marcel / gist:2100703
Created Mar 19, 2012
giftube – Generates an animated gif from a YouTube url.
View gist:2100703
#!/usr/bin/env ruby
# giftube – Generates an animated gif from a YouTube url.
#
# Usage:
#
# giftube [youtube url] [minute:second] [duration]
#
# ex.
#
@marcel
marcel / ConcurrentBlockingQueueConsumer.scala
Created Mar 24, 2011
Abstracts away the common pattern of producing items into a queue that are consumed concurrently by a pool of workers.
View ConcurrentBlockingQueueConsumer.scala
import java.util.concurrent.{BlockingQueue, ArrayBlockingQueue, CountDownLatch, Executors, TimeUnit}
/*
Abstracts away the common pattern of producing items into a queue that are
consumed concurrently by a pool of workers.
*/
class ConcurrentBlockingQueueConsumer[T](queue: BlockingQueue[T], producer: Iterator[T], concurrencyLevel: Int) {
lazy val stopLatch = new CountDownLatch(1)
lazy val pool = Executors.newFixedThreadPool(concurrencyLevel)
@marcel
marcel / gist:821588
Created Feb 10, 2011
Nested default procs
View gist:821588
intersections = Hash.new do |h, k|
# k = segment type 1
h[k] = Hash.new do |h, k|
# k = segment value 1
h[k] = Hash.new do |h, k|
# k = segment type 2
h[k] = {}
end
end
end
View Easily explore an object's methods from irb
module Kernel
def m(object=Object.new, pattern=nil)
methods = object.public_methods(false).sort
methods = methods.grep pattern unless pattern.nil?
ObjectMethods.new(methods)
end
class ObjectMethods < Array
def inspect
puts sort
View gist:259989
module Twurl
class OAuthClient
class << self
def rcfile(reload = false)
if reload || @rcfile.nil?
@rcfile = RCFile.new
end
@rcfile
end