Skip to content

Instantly share code, notes, and snippets.

$ test1=foo
$ set -a
$ test2=foo
$ test3=foo
$ set +a
$ env | grep test
test2=foo
test3=foo
@jordansissel
jordansissel / Results.md
Created May 23, 2011 23:46
ruby ipaddr vs custom pure-ruby

Premise

I have some code that does acl checking; compares an client ip address against a list of addresses (or subnets) that permit or reject. This largely involves iterating across a set of IPAddr objects asking addr.include?(client_addr). Performance is terrible when I include this acl checking.

Why? IPAddr is really slow, so I implemented what I needed as "TubeAddress" and compared the speeds.

Data

 implementation |  platform     | duration | rate

ipaddr | rbx/ 1.8.7 | 18.96 | 2637.29

@jordansissel
jordansissel / DateTime#sec_fraction .md
Created February 9, 2011 06:41
Stuff that didn't need to change between ruby 1.8 and 1.9

This DateTime#sec_fraction change is not documented as far as I can tell, at time of writing (2011/02/08).

The change is that sec_fraction in 1.8.x returns "fraction of a day" where in 1.9.x it returns "fraction of a second"

snack(~) % rvm ruby -e 'require "date"; p [RUBY_VERSION, RUBY_PLATFORM] => DateTime.now.sec_fraction.to_f' | sort           
{["1.8.6", "x86_64-linux"]=>3.69974537037037e-06}
{["1.8.7", "java"]=>5.72916666666667e-06}

{["1.8.7", "x86_64-linux"]=>2.9518287037037e-06}

@jordansissel
jordansissel / caveats
Last active July 9, 2018 18:29
setcap to allow a program to listen on privileged ports
setcap grants root-like permissions, so there's additional constraints on the binary.
It ignores LD_PRELOAD and LD_LIBRARY_PATH environment variables, so if you used these, you'll have to find another way.
One option is to use the RPATH piece of the Dynamic section of an ELF binary.
@jordansissel
jordansissel / sincos.elm
Created January 16, 2018 08:43
Playing with Elm and SVG.
import Svg exposing (..)
import Svg.Attributes exposing (..)
import List
cycles = 2
yScale = 50
lineThickness = 20
i = List.range 0 (cycles * 360)
public class Main {
public static void main(String[] args) {
X x = new X();
Long value = 500L;
if (args.length != 1) {
System.out.println("Usage: Main <iterations>");
System.exit(1);
}
@jordansissel
jordansissel / site.pp
Created December 2, 2010 09:39
My site.pp
node default {
tag("deployment::$deployment")
include truth::enforcer
case $operatingsystem {
"Ubuntu": { include os::ubuntu }
default: { err("Unsupported operatingsystem: '$operatingsystem'") }
}
exec {
@jordansissel
jordansissel / output
Created December 17, 2010 22:02
iteration in puppet using defines
% puppet apply test.pp
notice: Scope(Apache::Instance::With_port[80]): Apache instance 'my instance' on port 80
notice: Scope(Apache::Instance::With_port[8000]): Apache instance 'my instance' on port 8000
public class Foo {
private static final int ITERATIONS = 10000000;
public static void main(String[] args) {
Foo foo = new Foo();
int i = Integer.parseInt(args[0]);
System.out.println(i);
if (args[1].equals("a")) {
System.out.println("a");