This file contains 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
RATE_LIMIT_SCRIPT = r''' | |
local now = tonumber(ARGV[1]) | |
local required = tonumber(ARGV[2]) | |
local rate = tonumber(ARGV[3]) | |
local per_secs = tonumber(ARGV[4]) | |
local do_subtract = tonumber(ARGV[5]) == 1 | |
local full_at = tonumber(redis.call('GET', KEYS[1])) or 0 | |
local score, result | |
if full_at < now then | |
score = rate |
This file contains 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
This is a preview of Tom Ellis' database query library for Haskell. | |
> {-# LANGUAGE Arrows, FlexibleContexts #-} | |
> -- TODO: Get rid of FlexibleContexts if we ever move the definition of s | |
> -- elsewhere. | |
> {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} | |
> {-# LANGUAGE TemplateHaskell #-} | |
> | |
> module Karamaan.Opaleye.Examples where | |
> |
This file contains 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 FizzBuzz | |
-- Dependently-typed FizzBuzz, about 5 years late to the party. | |
-- A specification of the problem. Each constructor tells the conditions | |
-- under which it can be applied, and the "auto" keyword means that proof | |
-- search will be used in the context where they are applied to fill them | |
-- out. For instance, applying `N` to some Nat fails unless there's a proof in | |
-- scope that the argument meets the criteria. | |
data FB : Nat -> Type where |
This file contains 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
# chruby-exec 2.1.2 -- ruby y.rb | |
{:a=>:foo} | |
# chruby-exec 2.1.3 -- ruby y.rb | |
y.rb:2: syntax error, unexpected modifier_if | |
a: if true; :foo; end | |
^ | |
y.rb:2: syntax error, unexpected keyword_end, expecting end-of-input |
This file contains 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 'json' | |
require 'verkehr/zookeeper' | |
module Verkehr | |
class Brokers | |
Broker = Struct.new(:id, :host, :port) do | |
def to_s | |
"#{host}:#{port}" | |
end |
This file contains 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
curl -s "$url" | tar -zxC "$dest" |
This file contains 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 with mixins for common queries across descendants: | |
module Descendant | |
# I guess I could use ActiveSupport::Concern here... | |
def self.included(receiver) | |
receiver.extend ClassMethods | |
receiver.send :include, InstanceMethods | |
end | |
module ClassMethods | |
def self.included(receiver) |
This file contains 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
:+1: | |
:-1: | |
:0: | |
:1: | |
:109: | |
:2: | |
:3: | |
:4: | |
:5: | |
:6: |
This file contains 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
source :rubygems | |
gem "jdbc-openedge", "11.1" | |
gem "dm-openedge-adapter", :git => "git://github.com/abevoelker/dm-openedge-adapter.git" | |
gem "data_mapper", "~> 1.2.0" |
This file contains 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
#### | |
## Ruby port of "A Tale of 3 Nightclubs" | |
## | |
## Based on Scala version here: https://gist.github.com/970717 | |
## | |
## Demonstrates applicative validation in Ruby, inspired by the blog post: | |
## "An example of applicative validation in FSharpx" | |
## (http://bugsquash.blogspot.com/2012/03/example-of-applicative-validation-in.html) | |
#### |
OlderNewer