Skip to content

Instantly share code, notes, and snippets.

@directionless
directionless / 1 set
Last active December 14, 2015 19:09
chef -- create an ssh key and store it in the attributes
# Create the ssh access key
#
# Something in the node.set lines happens at the *start* of the chef
# run. It might be the node.set, or it might be the File.read, but
# either way, it happens before the resource execution. To compensate
# for this, we need to shift the ssh key creation to the start of the
# run. http://docs.opscode.com/resource_common_compile.html
sshfile = "/home/runtime/id_rsa"
sshcomment = [
class Chef::Recipe
def find_nrpe_plugin(name)
return name if name.start_with?("/")
end
end
@directionless
directionless / recipe_example.rb
Created April 29, 2013 15:28
chef sneakyness for managed_directory
managed_directory nrpechef_dir do
action :nothing
notifies :restart, "service[nagios-nrpe-server]"
end
directory nrpechef_dir do
owner "root"
group "root"
mode "0755"
notifies :clean, "managed_directory[#{nrpechef_dir}]", :delayed
end
rindge:graphs seph$ ./test-irr.rb
-0.8461538461538315
-0.5233728905609968
-0.3055754160809478
-0.16941929133206396
-0.08153134104840357
-0.02240080635339052
0.018877821951107262
-1.7310946662195288
0.07055058069605046
@directionless
directionless / keybase.md
Created February 28, 2014 20:57
keybase.md

Keybase proof

I hereby claim:

  • I am directionless on github.
  • I am seph (https://keybase.io/seph) on keybase.
  • I have a public key whose fingerprint is 862F 624E 4D89 D0DD 5826 E89C 2590 35C7 4ACB 4497

To claim this, I am signing this object:

@directionless
directionless / output
Created July 30, 2014 06:59
Testing string conversion performance in python
Wed Jul 30 02:58:53 2014 /tmp/python.string.stats
2100004 function calls in 1.436 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
300000 0.500 0.000 0.529 0.000 random.py:173(randrange)
1 0.278 0.278 1.436 1.436 foo.py:24(main)
300000 0.154 0.000 0.683 0.000 random.py:237(randint)
@directionless
directionless / import test
Created August 14, 2014 02:09
Python WTF
#!/usr/bin/python
import random
import cProfile
import pstats
import math
from math import cos, sin, pi
def TESToverhead(a):
# This is just to check the call overhead
@directionless
directionless / octocat pagination
Created December 23, 2014 17:35
Octocat pagination
# WTF Octocat. This should be cleaner.
members = client.org_members(ORGNAME)
next_url = client.last_response.rels[:next]
while ! next_url.nil? do
page = next_url.href.gsub(/.*page=(\d+)/,'\1')
puts "Fetching page #{page}"
members.concat client.org_members(ORGNAME, :page => page)
next_url = client.last_response.rels[:next]
end
@directionless
directionless / ttc2ttf.py
Last active August 29, 2015 14:12 — forked from kayahr/ttc2ttf.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#First released as C++ program by Hiroyuki Tsutsumi as part of the free software suite "Beer"
#I thought porting it to Python could be both a challenge and useful
from sys import argv, exit, getsizeof
from struct import pack_into, unpack_from
def ceil4(n):
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define CANARY "in_the_coal_mine"
struct {
char buffer[1024];