For excessively paranoid client authentication.
Updated Apr 5 2019:
because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.
some other notes:
# http://gist.github.com/458158 | |
require 'rubygems' | |
require 'dm-core' | |
require 'dm-migrations' | |
DataMapper::Logger.new($stdout, :debug) | |
DataMapper.setup(:default, 'sqlite::memory:') | |
class Thing | |
include DataMapper::Resource |
{-# LANGUAGE DeriveDataTypeable #-} | |
import Text.JSON | |
import Text.JSON.Generic | |
import Control.Monad (liftM2) | |
data Foo = Foo { name :: String } deriving (Eq, Show, Typeable, Data) | |
data FooSet = FooSet { foos :: [(String, Foo)]} deriving (Eq, Show) | |
-- Input data looks like |
# In config/initializers/local_override.rb: | |
require 'devise/strategies/authenticatable' | |
module Devise | |
module Strategies | |
class LocalOverride < Authenticatable | |
def valid? | |
true | |
end |
// The following is your top-level parent model in serialized JSON format: | |
var myModel = new Person({ | |
"name" : { | |
"first_name" : "Andrew", | |
"last_name" : "de Andrade" | |
}, | |
"address" : { | |
"street_address_1" : "Avenida Paulista 1000", | |
"street_address_2" : "Apt. 101", |
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages. | |
# ghc-pkg-clean -f cabal/dev/packages*.conf also works. | |
function ghc-pkg-clean() { | |
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'` | |
do | |
echo unregistering $p; ghc-pkg $* unregister $p | |
done | |
} | |
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place. |
# Input: | |
# choices = { | |
# 'color' => %w(blue red green), | |
# 'sizes' => %w(small medium large extra-large), | |
# 'style' => %w(tshirt longsleeve) | |
# } | |
# | |
# Output: | |
# [{"sizes"=>"small", "color"=>"blue", "style"=>"tshirt"}, | |
# {"sizes"=>"small", "color"=>"blue", "style"=>"longsleeve"}, |
(.:/) :: (FromJSON a) => Object | |
-> [Text] | |
-> Parser a | |
obj .:/ (k:ks) = maybe (fail msg) parseJSON parsed | |
where parsed = deepValue ks =<< M.lookup k obj | |
msg = "Failed to find " ++ (intercalate "/" $ map unpack (k:ks)) | |
obj .:/ [] = parseJSON $ Object obj | |
deepValue :: [Text] | |
-> Value |
This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.
You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf
using homebrew.
I wrote this up here: http://blog.steveklabnik.com/posts/2012-02-27-hypermedia-api-reading-list