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
create or replace function audit.api_request() returns void | |
language plpgsql | |
as $$ | |
declare | |
_request_id text := coalesce(current_setting('request.header.x-request-id', true),''); | |
_role text := coalesce(current_setting('request.jwt.claim.role', true),''); | |
_user_id text := coalesce(current_setting('request.jwt.claim.id', true),''); | |
_resource text := coalesce(current_setting('request.header.x-path', true),''); | |
_verb text := coalesce(current_setting('request.header.x-verb', 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
-module(key_grouper). | |
%% You have to make sure that the journal bucket is set to allow siblings ({"props" : { "allow_mult":true}}. | |
%% Fetch the grouped keys using the Accept: multi/mixed header. | |
-define (JOURNAL, <<"test">>). | |
-export([ | |
store_per_month/1, | |
store_per_hour/1, | |
store_per_10min/1, | |
store_per_min/1]). | |
-export([log/1]). |
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
location /resize { | |
alias /tmp/nginx/resize; | |
set $width 150; | |
set $height 100; | |
set $dimens ""; | |
if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) { | |
set $width $1; | |
set $height $2; | |
set $image_path $3; |
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
#!/bin/bash | |
# | |
# Author: Brian Beck <[email protected]> | |
# Usage: watch PATH COMMAND... | |
# | |
# This script watches PATH and runs COMMAND whenever PATH or a descendent | |
# of PATH is modified. COMMAND is everything after the first argument. | |
# | |
# If PATH is "-", then the list of paths comes from standard input. | |
# |
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
-module (game). | |
-compile([export_all]). | |
go() -> | |
test(lists:seq(250,999)). | |
test([N|T]) -> | |
case match(parse(N), parse(4*N)) of | |
true -> io:format("~p~n", [N]); | |
false -> no |
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
-module(time). | |
-compile([export_all]). | |
time_to_words({0,0,_}) -> "now"; | |
time_to_words({0,1,_}) -> "1 minute"; | |
time_to_words({0,M,_}) -> integer_to_list(M) ++ " minutes"; | |
time_to_words({1,0,_}) -> "1 hour"; | |
time_to_words({H,0,_}) -> integer_to_list(H) ++ " hours"; | |
time_to_words({H,1,_}) -> integer_to_list(H) ++ "h " ++ "1min"; | |
time_to_words({H,M,_}) -> integer_to_list(H) ++ "h " ++ integer_to_list(M) ++ "mins". |
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
-module(fizz). | |
-compile(export_all). | |
play(Max)-> | |
Numbers = lists:seq(1, Max, 1), | |
[eval(N) || N <- Numbers]. | |
eval(Number) when Number rem 15 == 0 -> fizzbuzz; | |
eval(Number) when Number rem 5 == 0 -> buzz; | |
eval(Number) when Number rem 3 == 0 -> fizz; |
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
-module(neural). | |
-record(state, {id, pid, parentId, ppid, children=[]}). | |
-compile([export_all]). | |
test(N) -> | |
Nodes = [{Id, Id - 1} || Id <- lists:seq(1,N,1)], | |
Pids = [spawn(?MODULE, start, [Id, ParentId]) || {Id, ParentId} <- Nodes], | |
timer:sleep(1000), | |
Started = length([Pid ! {connect, Pids} || Pid <- Pids]), | |
Started. |