This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Store do | |
def get(ptr) do | |
Metrics.count() | |
Metrics.timed do | |
ptr.store.get(ptr) | |
end | |
end | |
end | |
defmodule Macro do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- maybe our dataset has a column that looks like '(47.000, -128.000)' but some of those values | |
-- are 'unknown', so this will parse the lat/lng from the string if it's there, and if not, then | |
-- geocode using different columns, but both branches of this case return a point. | |
case( | |
location LIKE '%(%' and location LIKE '%)%' and location LIKE '%,%', | |
make_point( | |
to_number( | |
regex_named_capture(incident_location, '\((?<latitude>[-\d\.]+)', 'latitude') | |
), | |
to_number( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- math | |
2 + 2 | |
2 - 2 | |
2 / 2 | |
2 * 2 | |
4 % 1 | |
-- boolean | |
not true | |
true or false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- call the replace function on the `response_type` column | |
-- which will replace the string 'Medic' with 'Medical' | |
replace(`response_type`, 'Medic', 'Medical') | |
-- call the to_number function on the `latitude` column | |
to_number(`latitude`) | |
-- call the to_boolean function on the incident column. Note we don't need the | |
-- `backticks` when the column name is alphanumeric+underscores. | |
to_boolean(incident_number) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- strings | |
'hello' | |
"or double quoted" | |
-- numbers | |
-1.8 | |
47 | |
-- booleans | |
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update && \ | |
sudo apt-get install build-essential software-properties-common -y && \ | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ | |
sudo apt-get update && \ | |
sudo apt-get install gcc-6 g++-6 -y && \ | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 | |
To verify if it worked: | |
gcc -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_mem(label) do | |
case :erlang.process_info(self, :binary) do | |
{:binary, bins} -> | |
{size, count} = Enum.reduce(bins, {0, 0}, fn {_bid, size, count}, {s, c} -> {size + s, count + c} end) | |
Logger.warn("#{label} usage in #{__MODULE__} is #{size / 1000000}mb, #{count} of them") | |
_ -> :ok | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Exsoda.Reader | |
with {:ok, rows} <- query("6zsd-86xi", domain: "data.cityofchicago.org") | |
|> select(["date_trunc_ym(date) as month", "count(*)"]) | |
|> where("primary_type = 'HOMICIDE' AND month = '2001-01-01T00:00:00.000'") | |
|> group("month") | |
|> order("month") | |
|> run do | |
rows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Advance do | |
defp advance_by(stream, count) do | |
Enumerable.reduce(stream, count, fn | |
x, {acc, 1} -> {:suspend, {[x | acc], 0}} | |
x, {acc, counter} -> {:cont, {[x | acc], counter - 1}} | |
end) | |
end | |
defp continue(cont, by) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib3 | |
from urlparse import urlparse | |
import os | |
import json | |
from urllib import urlencode | |
from time import sleep | |
import pprint | |
import argparse | |
import sys |
NewerOlder