Skip to content

Instantly share code, notes, and snippets.

View Gazler's full-sized avatar

Gary Rennie Gazler

View GitHub Profile
@Gazler
Gazler / gist:8c893bbcfad2d09a0dd0
Last active August 29, 2015 14:04
Elixir Regex split
gazler@gazler-desktop-pc:~/development/elixir/elixir$ iex
Erlang/OTP 17 [erts-6.0] [source-07b8f44] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
Interactive Elixir (0.14.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Regex.split(~r/(%{[^}]+})/, "%{foo}(%{bar}): %{baz}")
["", "%{foo}", "(", "%{bar}", "): ", "%{baz}", ""]
gazler@gazler-desktop-pc:~/development/elixir/elixir$ iex
Erlang/OTP 17 [erts-6.0] [source-07b8f44] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
@Gazler
Gazler / earmark-pipe.exs
Last active August 29, 2015 14:05
earmark test
test "Columns with pipes" do
result = Earmark.to_html(["a | b | c", "d | e \| f | g"])
expected = """
<table>
<colgroup>
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<tr>
defmodule Authex.Mixfile do
use Mix.Project
def project do
[app: :authex,
version: "0.0.1",
elixir: "~> 1.0",
deps: deps]
end
def show
case Car.create(conn.assigns.user, params) do
{:ok, car} ->
conn
|> redirect(to: car)
{:error, changeset} ->
conn
|> render("new.html", changeset: changeset)
end
end
@Gazler
Gazler / gist:1198898
Created September 6, 2011 20:44 — forked from noahc/gist:1198881
require 'sinatra'
require 'date'
class Doer
attr_accessor :on, :off
def makeDate(date)
return Date.strptime(date, "%m/%d/%Y")
end
@Gazler
Gazler / backbone_render.coffee
Created December 8, 2011 22:38 — forked from sxross/backbone_render.coffee
Backbone render
SONG_TEMPLATE = '''
<table>
{{#if songs.length }}
{{#each songs}}
<tr><td>{{ this.name }}</td><td>{{ this.duration }}</td></tr>
{{/each}}
{{/if}}
</table>
'''
@Gazler
Gazler / gist:2169022
Created March 23, 2012 09:38
ActiveRedis
class User
@redis = Redis.new
def method_missing(m, * args, &block)
return @data[m.to_s] if @data.has_key?(m.to_s)
super
end
def initialize(data)
@data = data
gazler@gazler-desktop-pc:~/development/pubsub_stress$ WS_CLIENTS=10000 PORT=4000 REMOTE_PORT=4002 MIX_ENV=prod mix phoenix.server
#PID<0.253.0>700 subscribers listening on "rooms:lobby"
{"Kernel pid terminated",application_controller,"{application_start_failure,pubsub_stress,{{shutdown,{failed_to_start_child,'Elixir.PubsubStress.WebSocketSimulator',{'EXIT',{undef,[{'Elixir.PubsubStress.WebSocketSimulator',start_link,[10000,<<\"4002\">>],[]},{supervisor,do_start_child,2,[{file,\"supervisor.erl\"},{line,314}]},{supervisor,start_children,3,[{file,\"supervisor.erl\"},{line,297}]},{supervisor,init_children,2,[{file,\"supervisor.erl\"},{line,263}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,306}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,237}]}]}}}},{'Elixir.PubsubStress',start,[normal,[]]}}}"}
@Gazler
Gazler / Gemfile
Last active December 19, 2015 01:28
source :rubygems
gem "rapidash"
gem "activesupport", "~>4.0.0"
difficulty 2
description "You need to fix a bug in the version 1.2 of your app. Checkout the tag `v1.2`."
setup do
repo.init
FileUtils.touch("app.rb")
repo.add("app.rb")
repo.commit_all("Initial commit")