gem install rails
rails new my_app -T
| #!/usr/bin/env ruby | |
| # A quick and dirty implementation of an HTTP proxy server in Ruby | |
| # because I did not want to install anything. | |
| # | |
| # Copyright (C) 2009-2014 Torsten Becker <[email protected]> | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining | |
| # a copy of this software and associated documentation files (the | |
| # "Software"), to deal in the Software without restriction, including | |
| # without limitation the rights to use, copy, modify, merge, publish, |
| ############################################################################# | |
| # Class: Vash (Ruby Volatile Hash) | |
| # Hash that returns values only for a short time. This is useful as a cache | |
| # where I/O is involved. The primary goal of this object is to reduce I/O | |
| # access and due to the nature of I/O being slower then memory, you should also | |
| # see a gain in quicker response times. | |
| # | |
| # For example, if Person.first found the first person from the database & cache | |
| # was an instance of Vash then the following would only contact the database for | |
| # the first iteration: |
| <html> | |
| <head> | |
| <script src='http://code.jquery.com/jquery-1.5.1.min.js'></script> | |
| </head> | |
| <body> | |
| <h2>Naive canvas</h2> | |
| <canvas id="naive" width="400" height="50"></canvas> | |
| <h2>High-def Canvas</h2> |
| class Lisp | |
| def initialize | |
| @env = { | |
| :label => lambda { |(name,val), _| @env[name] = val }, | |
| :quote => lambda { |sexpr, _| sexpr[0] }, | |
| :car => lambda { |(list), _| list[0] }, | |
| :cdr => lambda { |(list), _| list.drop 1 }, | |
| :cons => lambda { |(e,cell), _| [e] + cell }, | |
| :eq => lambda { |(l,r), _| l == r }, | |
| :if => lambda { |(cond, thn, els), ctx| eval(cond, ctx) ? eval(thn, ctx) : eval(els, ctx) }, |
| module Spree | |
| class Calculator::Bogo < Calculator | |
| preference :number_to_buy, :integer, :default => 1 | |
| preference :number_to_get, :integer, :default => 1 | |
| def self.description | |
| "Buy One Get One" | |
| end | |
| def compute(order) |
| -- Related blog post to this Gist: | |
| -- https://torsten.io/stdout/expanding-json-arrays-to-rows | |
| -- Run these commands on a interactive RedShift session: | |
| CREATE TEMP TABLE clusters AS ( | |
| SELECT 1 AS id, '[1, 2]' AS node_sizes UNION ALL | |
| SELECT 2 AS id, '[5, 1, 3]' AS node_sizes UNION ALL | |
| SELECT 3 AS id, '[2]' AS node_sizes | |
| ); |
| # 1) Create your private key (any password will do, we remove it below) | |
| $ cd ~/.ssh | |
| $ openssl genrsa -des3 -out server.orig.key 2048 | |
| # 2) Remove the password | |
| $ openssl rsa -in server.orig.key -out server.key |