Skip to content

Instantly share code, notes, and snippets.

View bgmarx's full-sized avatar

Ben Marx bgmarx

View GitHub Profile
# Delete every Docker containers
# Must be run first because images are attached to containers
docker rm -f $(docker ps -a -q)
# Delete every Docker image
docker rmi -f $(docker images -q)
#
docker inspect
["Due", "to", "their", "lightweight", "nature,", "it", "is", "not", "uncommon",
"to", "have", "hundreds", "of", "thousands", "of", "processes", "running",
"concurrently", "in", "the", "same", "machine.", "Isolation", "allows",
"processes", "to", "be", "garbage", "collected", "independently,", "reducing",
"system-wide", "pauses,", "and", "using", "all", "machine", "resources", "as",
"efficiently", "as", "possible", "(vertical", "scaling).\n\nProcesses", "are",
"also", "able", "to", "communicate", "with", "other", "processes", "running",
"on", "different", "machines", "in", "the", "same", "network.", "This",
"provides", "the", "foundation", "for", "distribution,", "allowing",
"developers", "to", "coordinate", "work", "across", "multiple", "nodes",
@bgmarx
bgmarx / .credo.exs
Last active January 3, 2017 23:39
Sample Credo file
%{
configs: [
%{
name: "default",
files: %{
included: ["lib/", "src/", "web/", "test/"],
excluded: []
},
checks: [
{Credo.Check.Consistency.ExceptionNames},

Keybase proof

I hereby claim:

  • I am bgmarx on github.
  • I am bgmarx (https://keybase.io/bgmarx) on keybase.
  • I have a public key whose fingerprint is 1954 3E85 C8CE 08BE 3631 53B6 0A37 825B 5F07 FB1B

To claim this, I am signing this object:

@bgmarx
bgmarx / gist:2593bf45d9576b46600f
Last active August 29, 2015 14:19
memoized fib
@max_size = 1000
@placeholder = []
(1..@max_size).each { |i| @placeholder[i] = :not_yet }
def fib(n)
return "too large" if n > @max_size
if n <= 1
n
elsif @placeholder[n] != :not_yet
@placeholder[n]
def map
[].tap { |out| each { |e| out << yield(e) } }
end
def select
[].tap { |out| each { |e| out << if e yield(e) } }
end
def sort_by
map { |a| [yield(a), a] }.sort.map { |a| a[1] }
@bgmarx
bgmarx / gist:c847a56c2cc33b5395ea
Created April 17, 2015 20:44
reverse implementation
def rev(str)
lp = 0
rp = str.length - 1
while lp < rp
temp = str[lp]
str[lp] = str[rp]
str[rp] = str[lp]
lp += 1
@bgmarx
bgmarx / stabby
Last active August 29, 2015 14:19
fib stabby lambda
f = -> (x) { x < 2 ? x : f[x-1] + f[x-2] }
# puts f[5] => 5
defmodule Fib do
def fib(0) do 0 end
def fib(1) do 1 end
def fib(n) do fib(n-1) + fib(n-2) end
end
sqlite> CREATE TABLE skypelog (author TEXT, from_dispname TEXT, timestamp INTEGER, body_xml TEXT);
sqlite> CREATE TRIGGER update_skypelog AFTER UPDATE ON Messages
...> BEGIN
...> INSERT INTO skypelog
...> SELECT new.author, new.from_dispname, new.timestamp, new.body_xml
...> WHERE (SELECT count(*) FROM skypelog
...> WHERE timestamp = new.timestamp AND body_xml = new.body_xml) = 0;
...> END;