Skip to content

Instantly share code, notes, and snippets.

@Hanmac
Hanmac / test.rb
Last active March 13, 2016 21:02
def snapshot_description
initialization
@resp.snapshots.each do |n|
if name = n.tags.find { |t| t.key == 'Name' }
desc = name.value
end
if n.start_time < @threshold
@count += 1
snapshot_list(n, desc)
end
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
#
# Copyright (c) 2014 Marvin Gülker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
class ReadIngredients
def perform
while input = gets.chomp
break if input == 'done'
yield input
end
end
end
ingredients = []
@Hanmac
Hanmac / regex.rb
Last active December 18, 2015 03:19 — forked from bricker/regex.rb
m = query.query_url.match(Regexp.union(
/form_code=(?<id>[a-zA-Z0-9]+)/,
/form\/.+?\/(?<id>[a-zA-Z0-9]+)/,
/iframe\/(?<id>[a-zA-Z0-9]+)/))
@Hanmac
Hanmac / 03-lottery.rb
Last active December 16, 2015 10:28 — forked from repomaa/03-lottery.rb
def draw n=6
to_enum(__method__) unless block_given?
draw_all(n).each do |number|
break unless number
yield number
end
end
def draw_sorted n=6
to_enum(__method__) unless block_given?
require 'delegate'
class HiddenDelegator < SimpleDelegator
def initialize(obj)
super
end
def class
__getobj__.class
end