Skip to content

Instantly share code, notes, and snippets.

require 'RMagick'
class WatermarkMe
def initialize(app, args)
@app = app
@watermark_text, @mime_types = *args
@mime_types ||= %w[image/jpeg image/png image/gif]
end
def call(env)
From e6ec1f637ab3d6c235eef05142abf373e08f5c4b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20Garn=C3=A6s?= <[email protected]>
Date: Thu, 2 Sep 2010 12:35:37 +0200
Subject: [PATCH] ActiveModel#to_xml fix (renamed parameter).
---
activemodel/lib/active_model/serializers/xml.rb | 2 +-
activeresource/test/cases/base_test.rb | 6 ++++++
2 files changed, 7 insertions(+), 1 deletions(-)
da:
errors:
messages:
not_found: "ikke fundet"
already_confirmed: "er allerede bekræftet"
not_locked: "var ikke låst"
devise:
failure:
unauthenticated: 'Du skal logge ind for at kunne fortsætte.'
@andreas
andreas / gist:5432990
Created April 22, 2013 07:14
Use [rblineprof](https://github.com/tmm1/rblineprof) for profiling Rails apps
class RBLineProfiler
WALL_TIME_LIMIT = 10e3 # ms
def initialize(app)
@app = app
end
def call(env)
result = nil
profile = lineprof(/./) { result = @app.call(env) }
{"script":"(a+b)*c*d", "context": {"a": 3, "b": 5, "c": 7, "d": 11}}
open Core.Std
open Async.Std
module Ints = struct
type t = int
let to_string = string_of_int
let of_string = int_of_string
end
module IntCache = Memcached.Make(Ints)
# Start with these
[0, [0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0]]
[20, [1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1]]
# Games with a spare
[29, [5,5, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1]]
[38, [5,5, 1,9, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1]]
# Games with a strike
[30, [1,1, 10, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1, 1,1]]
@andreas
andreas / envelope_encryption.go
Created February 3, 2015 19:25
Envelope Encryption with Amazon KMS and Go
package main
import (
"bytes"
"crypto/rand"
"encoding/gob"
"fmt"
"io/ioutil"
"os"
"time"
@andreas
andreas / main.go
Created June 9, 2016 10:55
This gist shows the impact of resolving fields in parallel in graphql-go.
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"github.com/graphql-go/graphql"
)
package main
import (
"fmt"
"github.com/andreas/podio-go"
)
func main() {
authToken, err := podio.AuthWithUserCredentials("my-client-id", "my-client-secret", "my-username", "my-password")