Skip to content

Instantly share code, notes, and snippets.

View alco's full-sized avatar
🇺🇦

Oleksii Sholik alco

🇺🇦
View GitHub Profile
17:33:08.213 [error] Process #PID<0.263.0> terminating
Initial Call: Toad.Session.TaskList.init/1
Ancestors: [Toad.SessionSup, Toad.Supervisor, #PID<0.246.0>]
Messages: [:next_task]
Links: [#PID<0.248.0>]
Dictionary: []
Trapping Exits: false
Status: :running
Heap Size: 610
Stack Size: 27
17:19:48.654 [error] GenEvent handler Logger.ErrorHandler installed at :error_logger
** (exit) an exception was raised:
** (FunctionClauseError) no function clause matching in Exception.format_arity/1
(elixir) lib/exception.ex:431: Exception.format_arity(:undefined)
(elixir) lib/exception.ex:427: Exception.format_mfa/3
(logger) lib/logger/translator.ex:165: Logger.Translator.child_info/2
(logger) lib/logger/translator.ex:90: Logger.Translator.translate_supervisor/2
(logger) lib/logger/error_handler.ex:116: Logger.ErrorHandler.translate/6
(logger) lib/logger/error_handler.ex:62: Logger.ErrorHandler.log_event/5
(logger) lib/logger/error_handler.ex:27: Logger.ErrorHandler.handle_event/2
@alco
alco / private.xml
Created April 2, 2015 12:38
Remap LShift+Space to underscore (_) on OS X in Karabiner's private.xml
<?xml version="1.0"?>
<root>
<item>
<name>Remap Shift_L-Space to Underscore (_)</name>
<appendix>Easier to type this way.</appendix>
<identifier>shift_space_to_underscore</identifier>
<autogen>
--KeyToKey--
" Use s to replace the first match of a search
" while search highlighting is enabled
function! KillNextHighlighted()
if &hlsearch == 1
call feedkeys("cgn")
endif
endfunction
nmap s :call KillNextHighlighted()<CR>
# OK
case [1,2,3]
|> Enum.reverse
do
_ -> :ok
end
# Syntax error
case
[1,2,3]
17:45:58.452 [info] GET /
17:45:58.453 [info] Sent 404 in 1ms
17:46:01.817 [info] GET /hello
17:46:01.817 [info] Sent 200 in 29µs
iex(8)> :calendar.time_to_seconds(:os.timestamp)
9985742
iex(9)> :calendar.time_to_seconds(:os.timestamp)
9546163
iex(10)> :calendar.time_to_seconds(:os.timestamp)
10073013
iex(11)> :calendar.time_to_seconds(:os.timestamp)
9545154
iex(12)> :calendar.time_to_seconds(:os.timestamp)
9889845
## API
This module provides 3 main APIs for you to use:
1. Evaluate a string (`eval_string`) or a file (`eval_file`)
directly. This is the simplest API to use but also the
slowest, since the code is evaluated and not compiled before.
2. Define a function from a string (`function_from_string`)
or a file (`function_from_file`). This allows you to embed
@alco
alco / sieve.ex
Last active August 29, 2015 14:11
defmodule SieveStream do
def primes do
Stream.iterate(2, & &1 + 1)
|> Stream.transform([], fn nat, primes ->
if has_multiple(primes, nat) do
{[], primes}
else
{[nat], [nat | primes]}
end
end)
defprotocol Addition do
@fallback_to_any true
def a + b
end
defimpl Addition, for: Any do
def a + b do
Kernel.+(a, b)
end
end