This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def zip_with(other, op=nil) | |
return [] if self.empty? || other.empty? | |
clipped = self[0..other.length-1] | |
zipped = clipped.zip(other) | |
if op | |
zipped.map { |a, b| a.send(op, b) } | |
else | |
zipped.map { |a, b| yield(a,b) } | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'nokogiri' | |
require 'builder' | |
html = open("https://github.com/languages/Ruby/created") | |
doc = Nokogiri::HTML.parse(html) | |
atom = Builder::XmlMarkup.new(:target => STDOUT, :indent => 2) | |
atom.instruct! | |
atom.feed "xmlns" => "http://www.w3.org/2005/Atom" do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Proc | |
def prim_call(stack) | |
forth_arity = self.arity - 1 | |
if stack.size < forth_arity | |
puts "Buffer underrun" | |
return stack.clear | |
end | |
forth_arity > 0 ? self.call(stack, *stack.pop(forth_arity)) : call(stack) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
def with(obj, &block) | |
obj.instance_eval &block | |
obj | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@-moz-document url(http://derstandard.at/) { | |
div.section.inland { display: none } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loop { print ">> " ; puts("=> %s" % eval(gets.chomp!)) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule FizzBuzz do | |
def compute do | |
receive do | |
n -> IO.puts compute(n) | |
end | |
compute | |
end | |
defp compute(n) do | |
case {rem(n, 3), rem(n, 5)} do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# A colorful, friendly, multiline theme with some handy features. | |
# Based on the 'giddie' theme by Paul Gideon Dann. | |
# | |
# Authors: | |
# Michael Kohl <[email protected]> | |
# Paul Gideon Dann <[email protected]> | |
# Sorin Ionescu <[email protected]> | |
# | |
# Features: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Array { | |
func each(task: (Element) -> ()) { | |
for element in self { | |
task(element) | |
} | |
} | |
func eachWithIndex(start: Int? = nil, task: (Int, Element) -> ()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EvenNumbers: CollectionType { | |
let startIndex : Int | |
let endIndex : Int | |
init(start: Int, end: Int) { | |
self.startIndex = start | |
self.endIndex = end | |
} | |
convenience init() { |