Skip to content

Instantly share code, notes, and snippets.

--Apple-Mail=_59C7D647-374A-400F-8319-847E1514446E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=utf-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" =
class=3D""><h2 class=3D"chapter-name" style=3D"border: 0px; font-size: =
2.8em; margin: 21px 0px 0px; outline: 0px; padding: 15px 25px; =
defmodule Issues.GitHubIssues do
@user_agent [{"User-agent", "Issues [email protected]"}]
def fetch(user, project) do
issues_url(user, project)
|> HTTPoison.get(@user_agent)
|> handle_response
end
def issues_url(user, project) do
defmodule Issues.CLI do
@moduledoc """
Handle the command line parsing and the dispatch to the various functions
that end up generating a table of the last _n_ issues in a GitHub project.
"""
@default_count 4
def run(argv) do
argv
defmodule Parse do
def calculate(expression) do
{ left, rest } = Enum.split_while(expression, &(!(&1 in '+-*/')))
[ op | right ] = rest
{ result, _ } = Code.eval_quoted { :erlang.list_to_atom([op]), [],
[value(left), value(right)] }
result
end
defp value(digits) do
defmodule Eval do
def calculate(str), do: _calculate(str)
defp _calculate(str) do
{op, i} = find(str)
list1 = Enum.slice(str, 0..i-1)
list2 = Enum.slice(str, i+2..length(str))
_calculate(op, list1, list2)
end
defp _calculate(?+, list1, list2), do: number(list1) + number(list2)
defmodule Countdown do
def sleep(seconds) do
receive do
after seconds*1000 -> nil
end
end
def say(text) do
spawn fn -> :os.cmd('say #{text}') end
end
defmodule Swapper do
def swap([]), do: []
def swap([a,b | tail]), do: [b, a | swap(tail)]
def swap([_]), do: raise "Can't swap a list with an odd number of elements"
end
source 'https://rubygems.org'
require 'json'
require 'open-uri'
versions = JSON.parse(open('https://pages.github.com/versions.json').read)
gem 'github-pages', versions['github-pages']
gem 'rake'
gem 'rouge'
gem 'html-proofer'
# Site settings
title: seitz - a blog or something
email: [email protected]
description: > # this means to ignore newlines until "baseurl:"
This site exists as a resource for me to dump all the little thoughts
that come to me concerning programming. I am interested in Rust and
functional programming languages.
baseurl: "" # the subpath of your site, e.g. /blog
url: "http://seitz.space" # the base hostname & protocol for your site
twitter_username: ds3itz
class X {
int x[3];
public:
X() : x{0, 1, 3} {}
};
int main() {
X x;
}