Skip to content

Instantly share code, notes, and snippets.

View stiller's full-sized avatar

Joachim Nolten stiller

View GitHub Profile
@stiller
stiller / anna.js
Last active October 27, 2021 10:21
anna
input = [ { personId: 1, color: 'red' }, { personId: 2, color: 'red' } ]
personIds = [...new Set(input.map(e => e.personId))]
//add 'green'
personIds.forEach(personId => input.push({ personId, color: 'green' }))
//remove 'green'
input = input.filter(item => item.color !== 'green')
require 'parser/current'
require 'rexml/document'
class XMLAST
include REXML
attr_reader :doc
def initialize sexp
@doc = Document.new "<root></root>"
@sexp = sexp
@stiller
stiller / rate-limit-routes.rb
Created June 13, 2012 13:20
Rate limiting specific Rails routes
class RateConstraint
def matches?(request)
last_request = request.session[:request_time]
request.session[:request_time] = Time.now
!(last_request and (Time.now - last_request < 2.second))
end
end
Application.routes.draw do
constraints RateConstraint.new do

Keybase proof

I hereby claim:

  • I am stiller on github.
  • I am joachim (https://keybase.io/joachim) on keybase.
  • I have a public key whose fingerprint is B0B4 EDA7 1F9D A7C8 19F0 31A7 4D7C 27F5 4637 0D05

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am stiller on github.
* I am joachim (https://keybase.io/joachim) on keybase.
* I have a public key whose fingerprint is E9B5 E7BF 07D8 D78A 0527 E737 3225 1732 D79B E6D7
To claim this, I am signing this object: