Simple select all.
SELECT * FROM users;
User.all
%% @doc A binary tree implementation in Erlang. | |
%% A binary tree stores keys and values. | |
-module(binary_tree). | |
-export([init/0, init/1, insert/3, lookup/2]). | |
-define(EMPTY_NODE, {node, 'empty'}). | |
%% @doc Initialize an empty binary tree node. | |
%% This is how the root of the tree should be established. | |
%% |
%% @doc Reverse Polish Notation Calculator. | |
%% | |
%% Parses expressions like "1 2 3 + -" = -4 | |
%% | |
%% This is an exercise in Learn You some Erlang for Great Good, | |
%% however I didn't read the text and just implemented it. | |
%% | |
%% I guess understanding stack-based parsing helps here. | |
-module(calc). | |
-export([rpn/1]). |
%% @doc This implements a kitchen fridge that you can put things into | |
%% and take them out. | |
%% | |
%% It is stateful, through the use of recursion. | |
%% I opted for the sets module only because I wanted to try it. | |
%% Using the sets module has the side-effect that you can only store | |
%% one of each food item in the fridge. | |
-module(kitchen). | |
-export([new/0, store/2, take/2]). |
# foldl() is fundamental. With a fold, you can do everything else. | |
def foldl(list, acc, &fn) | |
if list == [] # base case, return the accumulator | |
acc | |
else | |
head, *tail = list | |
foldl(tail, fn.call(acc, head), &fn) #recurse on the remainder | |
end | |
end |
(defun colorize-mode-line (&rest args) | |
(let ((color (cond ((evil-insert-state-p) "#fa4444") | |
((evil-emacs-state-p) "#fafa00") | |
((buffer-modified-p) "#22bff0")))) | |
(set-face-background 'mode-line (or color "#ffffff")))) | |
(add-to-list 'post-command-hook 'colorize-mode-line) |
;; vim-style increment/decrement numbers | |
(defun inc-number-at-point (n) | |
"Increment the number under the point, if present. | |
Called with a prefix argument, changes the number by N." | |
(interactive "p") | |
(let ((amt (or n 1)) | |
(word (thing-at-point 'word)) | |
(bounds (bounds-of-thing-at-point 'word))) | |
(when (string-match "^[0-9]+$" word) | |
(replace-string word |
(defmacro demo-> [val & fns] | |
(reduce (fn [acc fname] (list fname acc)) val fns)) | |
(macroexpand '(demo-> 42 inc dec inc)) ; (inc (dec (inc 42))) |
(defschedule app-schedule "Application tasks" | |
[:every "5 seconds" (println "Woohoo!")] | |
[:at "7am tomorrow" (wake-up!)]) |
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash |