Skip to content

Instantly share code, notes, and snippets.

Fabian Kochem vortec

Block or report user

Report or block vortec

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View aa.exs
defmodule KVServer.Command do
@doc ~S"""
Parses a line into a command.
## Examples
iex> KVServer.Command.parse "CREATE shopping\r\n"
{:ok, {:create, "shopping"}}
iex> KVServer.Command.parse "CREATE shopping \r\n"
View aa.exs
defmodule KVServer.Command do
@doc ~S"""
Parses a line into a command.
## Examples
iex> KVServer.Command.parse "CREATE shopping\r\n"
{:ok, {:create, "shopping"}}
"""
def parse(line) do
View action.exs
defmodule Action do
defmodule Configuration do
end
@callback description(Configuration) :: String
@callback perform(Configuration, String) :: nil
end
defmodule Webhook do
@behaviour Action
View a.exs
defmodule KV.Bucket do
@doc """
Starts a new bucket.
"""
def start_link do
Agent.start_link(fn -> %{} end)
end
@doc """
Gets a value from the `bucket` by `key`.
View kv.exs
defmodule KV do
def start_link do
Task.start_link(fn -> loop(%{}) end)
end
defp loop(map) do
receive do
{:get, key, caller} ->
send caller, Map.get(map, key)
loop(map)
View zero.exs
defmodule Math do
def zero_a?(0) do
true
end
def zero_a?(_) do
false
end
def zero_b?(x) do
View async_mock_or_lambda.py
class EventDispatcher:
def __init__(self, loop, input_handler, output_handler):
self.loop = loop
self.input_handler = input_handler
self.output_handler = output_handler
async def __call__(self, event):
# Generic stuff (logging, benchmarking, ...)
message = await self.input_handler(event)
await self.output_handler(message)
View gist:1233ad776f88f3c1c6e7dec26ea7b8d5
MATCH (root:RootObject), (u {name: 'Tom'})-[:HAS_PERMISSION]->(o),
p = shortestPath((root)-[*]-(o)) WHERE (r IN rels(p) WHERE type(r) = 'CONTAINS')
RETURN p
View types.markdown

Types

A type is a collection of possible values. An integer can have values 0, 1, 2, 3, etc.; a boolean can have values true and false. We can imagine any type we like: for example, a HighFive type that allows the values "hi" or 5, but nothing else. It's not a string and it's not an integer; it's its own, separate type.

Statically typed languages constrain variables' types: the programming language might know, for example, that x is an Integer. In that case, the programmer isn't allowed to say x = true; that would be an invalid program. The compiler will refuse to compile it, so we can't even run it.

View gist:6d675c7a9f0abaccfc8ab625606fa289
(dx-rtu)[fkochem@FK2] code/didactix/rtu (git)-[signal]$ pip install --upgrade pip
Traceback (most recent call last):
File "/Users/fkochem/workspace/instances/dx-rtu/bin/pip", line 7, in <module>
from pip import main
File "/Users/fkochem/workspace/instances/dx-rtu/lib/python3.5/site-packages/pip/__init__.py", line 13, in <module>
from pip.commands import commands, get_summaries, get_similar_commands
File "/Users/fkochem/workspace/instances/dx-rtu/lib/python3.5/site-packages/pip/commands/__init__.py", line 6, in <module>
from pip.commands.bundle import BundleCommand
File "/Users/fkochem/workspace/instances/dx-rtu/lib/python3.5/site-packages/pip/commands/bundle.py", line 6, in <module>
from pip.commands.install import InstallCommand
You can’t perform that action at this time.