Skip to content

Instantly share code, notes, and snippets.

@sata
sata / vznetcfg.custom
Created March 11, 2012 16:26
additional configuration for network in openvz, used primarly to be able to set up bridges between container and host node
#!/usr/bin/env bash
# /usr/sbin/vznetcfg.custom
# originally from: http://wiki.openvz.org/Using_private_IPs_for_Hardware_Nodes
# a script to bring up bridged network interfaces (veth's) in a container
# modified 2012-03-11 to work with dhcp configured containers
GLOBALCONFIGFILE=/etc/vz/vz.conf
CTCONFIGFILE=/etc/vz/conf/$VEID.conf
@sata
sata / vz
Created March 11, 2012 19:15
/etc/init.d/vz
#!/bin/bash
# Copyright (C) 2000-2009, Parallels, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
strace -c erl -noshell -eval "[erlang:now() || _X <- lists:seq(1, 1000000)], halt()."
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
100.00 0.000012 0 41 close
0.00 0.000000 0 42 read
0.00 0.000000 0 1 write
0.00 0.000000 0 30 open
0.00 0.000000 0 2 stat
0.00 0.000000 0 16 fstat
0.00 0.000000 0 147 lstat
strace -f -c erl -noshell -eval "[erlang:now() || _X <- lists:seq(1, 1000000)], halt()."
Process 8937 attached
Process 8938 attached
Process 8939 attached
Process 8940 attached
Process 8941 attached
Process 8942 attached
Process 8943 attached
Process 8944 attached
Process 8945 attached
(emacs@minibox)3> set_benchmark:bench(50000).
Base Case:
Operation Total (microsecs) Average (microsecs)
create 3407 0.068140
read_all 3 0.000060
part_of 1428 0.028560
delete 1590 0.031800
merge 3
ordsets:
#! /bin/sh
### BEGIN INIT INFO
# Provides: firewall
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: firewall for armitage vpn container
### END INIT INFO
@sata
sata / erlang.mk
Last active August 29, 2015 14:25
# Copyright (c) 2013-2015, Loïc Hoguin <essen@ninenines.eu>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
@sata
sata / gist:c1be3ccd92570459744b
Created October 1, 2015 17:40
ets:insert_new behavior
(emacs@mini)1> ets:new(foo, [protected, named_table, ordered_set, {keypos, 1}]).
foo
(emacs@mini)2> ets:insert_new(foo, [{1, a}, {1, b}, {2, c}, {3, d}]).
true
(emacs@mini)3> ets:tab2list(foo).
[{1,b},{2,c},{3,d}]
2> timer:tc(fun(A) -> A end, [1]).
{12,1}
3> timer:tc(fun(A) -> A end, 1).
** exception error: undefined function timer:tc/2
traceroute to 54.227.209.130 (54.227.209.130), 30 hops max, 60 byte packets
1 vl-3072.vbdc-pe2.glesys.net (5.178.78.65) 0.241 ms 0.879 ms 1.134 ms
2 193.108.196.60 (193.108.196.60) 0.705 ms 1.012 ms 1.261 ms
3 po-1.vbdc-cr1.glesys.net (193.108.196.54) 0.368 ms 0.877 ms 1.148 ms
4 be-1.vbdc-cr4.glesys.net (193.108.196.55) 1.355 ms * *
5 po-1.vbdc-cr1.glesys.net (193.108.196.54) 1.392 ms 1.621 ms 1.861 ms
6 * * *
7 po-1.vbdc-cr1.glesys.net (193.108.196.54) 0.417 ms 0.851 ms 1.199 ms
8 * * *
9 po-1.vbdc-cr1.glesys.net (193.108.196.54) 0.346 ms 0.655 ms 0.911 ms