Skip to content

Instantly share code, notes, and snippets.

@implementation CalendarView: CPView
{
}
-(id)init {
self = [super initWithFrame:CGRectMake(0, 0, 200, 200)];
if (self) {
[self loadData];
}
return self;
@ztmr
ztmr / ns_exec.c
Last active December 28, 2015 22:19
Spawn a new Linux process by inheriting all the kernel namespaces of the existing process specified by PID
/*
* Module : ns_exec
* Created : 20-NOV-2013 20:50
* Author : Tomas Morstein (www.IDEA.cz)
* Description : Spawn a new process by inheriting all the kernel
* namespaces of the existing process specified by PID
* Prereqs : Linux >=3.8 built with kernel namespace support;
* Older kernels does not implement all the namespaces
* and even the 3.8 shipped by Ubuntu does not come
* with CONFIG_USER_NS enabled:
@ztmr
ztmr / cluster_bootserver.erl
Last active December 19, 2015 01:19
Erlang network boot example
tmr@dev:~$ erl -sname boot
Erlang R15B (erts-5.9) [source] [64-bit] [smp:2:2] [async-threads:0] [kernel-poll:false]
Eshell V5.9 (abort with ^G)
(boot@dev)1>
(boot@dev)1>
(boot@dev)1> erlang:get_cookie().
'HAKAZNCDECSZGWFBJSGC'
(boot@dev)2>
(boot@dev)2>
@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) ->
@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 / 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 / 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 / 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 / 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 / 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/>...