Skip to content

Instantly share code, notes, and snippets.

@ztmr
ztmr / 191670d31eeefdf19d14127a5278f227e7cb7baf
Created July 23, 2012 07:11
ChicagoBoss: resource-specific access control in general purpose REST controller
diff --git a/src/boss/boss_web_controller.erl b/src/boss/boss_web_controller.erl
index 0d5a8f6..5473545 100644
--- a/src/boss/boss_web_controller.erl
+++ b/src/boss/boss_web_controller.erl
@@ -587,16 +587,19 @@ execute_action({Controller, Action, Tokens} = Location, AppInfo, Req, SessionID,
2 ->
Module:new(Req, SessionID)
end,
- AuthInfo = case lists:member({"before_", 2}, ExportStrings) of
- true ->
@ztmr
ztmr / _bug.m
Created July 29, 2012 15:31
GT.M Call-ins and (un)signed int/longint values
test(x) q -$g(x)
@ztmr
ztmr / dtrace4linux_unload_error.log
Created September 29, 2012 20:39
dtrace4linux lkm unload error
[1441627.192624] ------------[ cut here ]------------
[1441627.192631] WARNING: at /build/buildd/linux-2.6.38/kernel/trace/ftrace.c:1007 ftrace_bug+0x26c/0x2c0()
[1441627.192633] Hardware name: 43193BG
[1441627.192634] Modules linked in: dtracedrv(P+) cpuid pci_stub vboxpci vboxnetadp vboxnetflt vboxdrv ums_cypress usb_storage uas macvlan ipt_MASQUERADE iptable_nat xt_CHECKSUM iptable_mangle bridge stp hdaps thinkpad_ec vmnet vsock vmci vmmon rfcomm sco bnep l2cap kvm_intel kvm binfmt_misc decnet parport_pc ppdev sha256_generic cryptd aes_x86_64 aes_generic dm_crypt vesafb snd_hda_codec_hdmi btusb bluetooth arc4 ipt_REJECT xt_comment ipt_LOG nvidia(P) xt_limit xt_tcpudp ipt_addrtype snd_hda_codec_conexant xt_state ip6table_filter ip6_tables iwlagn iwlcore snd_hda_intel mac80211 snd_hda_codec nf_nat_irc nf_conntrack_irc snd_hwdep nf_nat_ftp nf_nat joydev nf_conntrack_ipv4 i7core_edac thinkpad_acpi psmouse nf_defrag_ipv4 nf_conntrack_ftp nf_conntrack snd_pcm iptable_filter edac_core serio_raw ip_tables x_tables
@ztmr
ztmr / eprof.log
Created September 29, 2012 21:45
Erlang, eprof and segmentation fault
$ gdberl
GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
@ztmr
ztmr / proc-dtrace.log
Created September 30, 2012 11:47
/proc/dtrace/{fasttrap,stats}
$ cat /proc/dtrace/fasttrap
tpoints=1024 procs=256 provs=256 total=10081
# TRCP: pid pc type size base index seg
# PROV: pid name marked retired rcount ccount mcount
# PROC: pid acount rcount
PROC 29066 1 1
$
$
$ cat /proc/dtrace/stats
probes=48081955
@ztmr
ztmr / a.erl
Created October 6, 2012 21:18
Strange parametrized modules vs inheritance behaviour in Erlang
-module (a).
-compile (export_all).
hello () -> "Hello!".
@ztmr
ztmr / demo_outgoing_mail_controller.erl
Created January 2, 2013 20:43
# ChicagoBoss outgoing mail controller versus localization, internalization, and unicode. When the mail view template is in Unicode, we have to override Content-Type by hand as well as we have to encode headers (especially Subject) to declare it's encoding and to be base64-encoded. Another problem is that since we "hardcode" the "text/html" cont…
-module (demo_outgoing_mail_controller).
-export ([register_confirm/2]).
-define (DEMO_MAIL_FROM, "[email protected]").
-define (DEMO_MAIL_NAME, "DEMO Application").
%% Lang is not neccessarily the same as User:lang (),
%% but rather the language of the sign-up form
register_confirm (User, Lang) ->
SubjOrig = ?DEMO_MAIL_NAME ++ "Sign-Up Confirmation",
@ztmr
ztmr / GDEINFO.m
Created January 23, 2013 11:38
Quick'n'dirty tailored version of GT.M's GDE utility. Useful for getting database parameters dynamically at runtime.
GDEINFO
i $$set^%LCLCOL(0)
s (debug,runtime)=0
s io=$io,useio="io",comlevel=0,combase=$zl,resume(0)=$zl_":INTERACT"
i $$set^%PATCODE("M")
d GDEINIT^GDEINIT,GDEMSGIN^GDEMSGIN,GDFIND^GDESETGD,CREATE^GDEGET:create,LOAD^GDEGET:'create
w " *** List of regions and their configuration *** ",!
n rid,parId s rid="" f s rid=$o(regs(rid)) q:rid="" d
. w !," Region: "_rid,!
. s parId="" f s parId=$o(regs(rid,parId)) q:parId="" d
@ztmr
ztmr / filecdt.pl
Created March 19, 2013 15:41
FIS PROFILE/DATA-QWIK's `filecdt' utility clone in Perl.
#!/usr/bin/env perl
use strict;
use warnings;
use POSIX qw(strftime);
my @st = stat ($ARGV [0]) or exit 1;
my @dt = gmtime ($st [9]);
@ztmr
ztmr / restricted_shell.erl
Created June 26, 2013 18:43
Erlang Restricted Shell Module -- as mentioned in [erlang-programming groups.](https://groups.google.com/d/msg/erlang-programming/LI3O8VwMbGc/LDPm6fkUEy0J)
-module (restricted_shell).
-export ([local_allowed/3, non_local_allowed/3]).
-export ([lock/0, unlock/0, is_locked/0]).
-define (APP, 'SuperCluster').
-define (IS_LOCKED, 'restricted.is_locked').
local_allowed (q, [], _State) ->
{not is_locked (), _State};
local_allowed ({init, stop}, [], _State) ->