Skip to content

Instantly share code, notes, and snippets.

View bitwalker's full-sized avatar

Paul Schoenfelder bitwalker

View GitHub Profile
@bitwalker
bitwalker / observer.md
Created March 17, 2016 16:09 — forked from pnc/observer.md
Using Erlang observer/appmon remotely

Using OTP's observer (appmon replacement) remotely

$ ssh remote-host "epmd -names"
epmd: up and running on port 4369 with data:
name some_node at port 58769

Note the running on port for epmd itself and the port of the node you're interested in debugging. Reconnect to the remote host with these ports forwarded:

$ ssh -L 4369:localhost:4369 -L 58769:localhost:58769 remote-host
@bitwalker
bitwalker / time_vs_datatime.md
Created March 11, 2016 17:41 — forked from pixeltrix/time_vs_datatime.md
When should you use DateTime and when should you use Time?

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
@bitwalker
bitwalker / output.txt
Created December 15, 2015 21:49
Elixir 1.2.0-rc.0 error
{error_logger,{{2015,12,15},{15,50,17}},"~s~n",["driver_select(0x0000000020000ce8, 0, ERL_DRV_READ ERL_DRV_USE, 1) by tty_sl (tty_sl -c -e) driver #Port<0.630> failed: fd=0 (re)selected before stop_select was called for driver tty_sl\n"]}
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
=ERROR REPORT==== 15-Dec-2015::09:50:17 ===
driver_select(0x0000000020000ce8, 0, ERL_DRV_READ ERL_DRV_USE, 1) by tty_sl (tty_sl -c -e) driver #Port<0.630> failed: fd=0 (re)selected before stop_select was called for driver tty_sl
Interactive Elixir (1.2.0-rc.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
@bitwalker
bitwalker / parallel_executor.ex
Created November 23, 2015 21:29
Parallel Executor for Elixir
defmodule ParallelExecutor do
@moduledoc """
This module in conjunction with it's implementation of the Collectable
protocol, handles executing tasks over an enumerable/stream in parallel,
up to a provided parallelization factor `F`. It implements a backpressure mechanism
to ensure that there are never more than, but at least `F` tasks executing.
"""
alias __MODULE__
defstruct procs: 4, func: nil, tasks: []
@bitwalker
bitwalker / bowling.ex
Last active October 14, 2015 17:25
Bowling scorer in Elixir
defmodule Bowling do
@moduledoc """
Takes a bowling game score, with 10 frames seperated by spaces:
`X 53 18 5/ 5/ 44 36 35 9/ 9/4`
An ‘X’ marks a strike, a ‘/’ marks a spare. All frames can have 2 bowls,
except for the last which has up to 3. Your challenge is to come up with a
program that takes the above string as an input and outputs the integral score.
"""
@bitwalker
bitwalker / Clock.scala
Last active August 29, 2015 14:22
.NET Newsletter Challenge #5...in Scala [http://www.scala-js-fiddle.com/gist/26d0dbbe6bfa5e880efc]
import js.{JSApp, Date}
import Page.{canvas, renderer}
import dom.window
/**
* An example of Scala/Scala.js code which renders a clock using HTML5 Canvas
* @author Paul Schoenfelder
**/
object ScalaJSExample extends JSApp {
@bitwalker
bitwalker / Maths.cs
Last active August 29, 2015 14:20
.NET Newsletter #1 - Challenge
using System;
using System.Numerics;
public class Program
{
public void Main(params string[] args)
{
foreach (var n in Maths.Fib().Take(100))
{
Console.WriteLine(n);

How to set up stress-free SSL on an OS X development machine

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

@bitwalker
bitwalker / .conf
Created August 12, 2014 20:17 — forked from johnfoconnor/.conf
my_app.complex_list.buzz.type = person
my_app.complex_list.buzz.age = 25
my_app.complex_list.fido.type = dog
my_app.complex_list.fido.opts.special_value = biz
@bitwalker
bitwalker / .conf
Last active August 29, 2015 14:05 — forked from johnfoconnor/.conf
my_app.complex_list.buzz.type = person
my_app.complex_list.buzz.age = 25
my_app.complex_list.fido.type = dog
my_app.complex_list.fido.age = 5