(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
# ---- Build Stage ---- | |
FROM erlang:22-alpine AS app_builder | |
# Set environment variables for building the application | |
ENV MIX_ENV=prod \ | |
TEST=1 \ | |
LANG=C.UTF-8 | |
# Fetch the latest version of Elixir (once the 1.9 docker image is available you won't have to do this) | |
RUN set -xe \ |
defmodule Decrypt do | |
@iv String.duplicate("0", 16) | |
def unpad(data) do | |
to_remove = :binary.last(data) | |
:binary.part(data, 0, byte_size(data) - to_remove) | |
end | |
def decrypt(data, key) do |
defmodule MyApp.Scheduler do | |
@moduledoc """ | |
Schedules a Mix task to be run at a given interval in milliseconds. | |
## Options | |
- `:task`: The name of the Mix task to run. | |
- `:args`: A list of arguments to pass to the Mix task's `run/1` function. | |
- `:interval`: The time interval in millisconds to rerun the task. |
# Set nvm | |
nvm install 0.10.25 | |
nvm use 0.10.25 | |
# Install global things | |
npm install -g npm@latest | |
npm install -g bower | |
# Install dependencies | |
npm install |
(function() { | |
var Ap = Array.prototype; | |
var slice = Ap.slice; | |
var Fp = Function.prototype; | |
if (!Fp.bind) { | |
// PhantomJS doesn't support Function.prototype.bind natively, so | |
// polyfill it whenever this module is required. | |
Fp.bind = function(context) { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
# Updated for Ruby 2.3 | |
string_t = None | |
def get_rstring(addr): | |
s = addr.cast(string_t.pointer()) | |
if s['basic']['flags'] & (1 << 13): | |
return s['as']['heap']['ptr'].string() | |
else: | |
return s['as']['ary'].string() |
# Ruby pmap, like Scala's pmap method. | |
# ------------------------------------ | |
# modified from t-a-w.blogspot.com | |
require 'thread' | |
module Enumerable | |
def pmap(n) | |
todo = Queue.new | |
On the Refinery29 Mobile Web Team, codenamed "Bicycle", all of our unit tests are written using Jasmine, an awesome BDD library written by Pivotal Labs. We recently switched how we set up data for tests from declaring and assigning to closures, to assigning properties to each test case's this
object, and we've seen some awesome benefits from doing such.
Up until recently, a typical unit test for us looked something like this:
describe('views.Card', function() {
One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.
Most workflows make the following compromises:
Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure
flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.
Use production SSL certificates locally. This is annoying