Skip to content

Instantly share code, notes, and snippets.

khia

Block or report user

Report or block khia

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
@khia
khia / Caddyfile
Last active Aug 6, 2019
Tiddlywiki with Bob on android
View Caddyfile
cat etc/Caddyfile
# entrypoint for accessing from PC
phone.local:8080 {
tls /data/data/com.termux/files/home/etc/phone.crt /data/data/com.termux/files/home/etc/phone.key
basicauth /wiki "username" password
proxy /wiki 127.0.0.1:8090 {
websocket
}
}
# entrypoint for accessing locally from phone
@khia
khia / .bash_profile
Created May 18, 2018
How to run TW5 on andriod
View .bash_profile
cat data/data/com.termux/files/home/.bash_profile
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
export SVDIR="$HOME/etc/sv"
mkdir -p $PREFIX/var/run
mkdir -p ~/.log
daemonize -c $PREFIX -l $PREFIX/var/run/runsvdir.lock -p $PREFIX/var/run/runsvdir.pid $PREFIX/bin/applets/runsvdir $SVDIR 2>/dev/null||:
View gist:9441b0be8f8ccd8328517230c81347b3
cat priv/spec/db.yml
swagger: '2.0'
info:
title: CouchDB API
description: CouchDB API to define bindings
version: "2.0"
# the domain of the service
host: couchdb.org
# array of all schemes that your API supports
schemes:
@khia
khia / README.txt
Created Nov 20, 2013
mix compile macro from different app
View README.txt
$ mix
==> common
Compiled lib/classes.ex
Generated common.app
==> macro
Compiled lib/method.ex
Generated macro.app
$ touch apps/common/lib/classes.ex
$ mix
==> common
View gist:5398228
def project do
your_options = []
[
...
elixirc_options: your_options ++ options(Mix.env)
]
end
defp options(env) when env in [:dev, :test] do
[exlager_level: 7]
@khia
khia / dsl.exs
Last active Dec 12, 2015
Demo of simple DSL
View dsl.exs
#!/usr/bin/env elixir
defmodule DSL do
defmacro action(match, [do: body]) do
quote do
def handle_info(unquote(match) = arg, state) do
unquote(body)
{:ok, state}
end
end
end
View gist:4312157
'/Users/some_user/dev/myproject/apps/myapp/ebin',
'/Users/some_user/dev/myproject/apps/myapp/deps/gen_leader/ebin',
'/Users/some_user/dev/myproject/apps/myapp/deps/edown/ebin',
'/Users/some_user/dev/myproject/apps/myapp/deps/gproc/ebin',
'/Users/some_user/dev/myproject/apps/myapp/deps/genx/ebin',
'.',
'/usr/local/dev/erlang/R15B02/lib/erlang/lib/kernel-2.15.2/ebin',
'/usr/local/dev/erlang/R15B02/lib/erlang/lib/stdlib-1.18.2/ebin',
'/Users/some_user/dev/myproject/deps/elixir/bin/../lib/mix/ebin',
'/Users/some_user/dev/myproject/deps/elixir/bin/../lib/iex/ebin',
View gist:3960612
defmacrop _pid(args) do
[_self|rest] = Enum.reverse(args)
session_pid = quote do: unquote(_self).session_pid
element = quote do: unquote(_self).element
[session_pid,element|Enum.reverse(rest)]
end
delegate [element(strategy, value, _self)],
to: :htse_session, as: :element_element, with: _pid
View gist:3960633
delegate [
capabilities(_self),
delete(_self),
url(_self), url(url, _self),
forward(_self), back(_self),
],
to: :htse_session, with: _pid
View gist:3900083
```
Performance:
| asymptotic | length |
| | 10 | 100 | 1000 | 10000 |
| |min med max avg|min med max avg|min med max avg|min med max avg|
cons | | 0, 0, 537, 0 | 0, 0, 572, 0 | 0, 0, 223, 0 | 0, 0, 431, 0 |
drop | | 0, 0, 204, 0 | 0, 1, 356, 1 | 1, 1, 204, 1 | 1, 1, 450, 2 |
drop_tail | | 2, 3, 393, 3 | 1, 2, 588, 2 |294,302,501,306|2627,2768,9390,2812|
drop_tail_r| | 1, 2, 588, 2 | 16,17,404,17 |156,165,385,167|1364,1486,3650,1498|
from_list_r| | 0, 1, 405, 1 | 9,10,519,10 |112,114,879,116| 996,1037,3104,1060|
You can’t perform that action at this time.