Skip to content

Instantly share code, notes, and snippets.

@marcel
marcel / keybase.md
Created October 12, 2017 21:40
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:

# 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 December 20, 2015 09:12
Puun Alla lyrics
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 August 29, 2015 14:26
unapply tuple extraction
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)
}
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 March 19, 2012 07:24
giftube – Generates an animated gif from a YouTube url.
#!/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 March 24, 2011 22:43
Abstracts away the common pattern of producing items into a queue that are consumed concurrently by a pool of workers.
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 February 10, 2011 23:19
Nested default procs
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
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
module Twurl
class OAuthClient
class << self
def rcfile(reload = false)
if reload || @rcfile.nil?
@rcfile = RCFile.new
end
@rcfile
end