Skip to content

Instantly share code, notes, and snippets.

View dacamp's full-sized avatar
🙊

David Campbell dacamp

🙊
View GitHub Profile
@dacamp
dacamp / fuzz
Created September 26, 2013 09:00
Obfuscated Fizz Buzz
#!/usr/bin/env ruby
# Fuzz you fizzbuzz
#
def method_missing(m, arg, &block)
[arg, m.to_s.split('_').select{|e|
(arg%(((e.to_s.bytes.
inject{ |sum, i| sum + i } % 15) / 3.0
).ceil + 2)).zero?
}.join()].join(' ')
@dacamp
dacamp / README.md
Last active May 23, 2016 20:02
GitHub Status Widget for Dashing
@dacamp
dacamp / ruby_18_geoip-c.rb
Last active August 29, 2015 13:58
Ruby 1.8 + GeoIP-C Benchmark
#!/usr/bin/env ruby
require 'rubygems'
require 'mysql2'
require 'geoip'
require 'benchmark'
[..]
@dacamp
dacamp / Ruby 1.8.7
Last active August 29, 2015 14:01
Ruby hex vs to_i(16) vs sprintf
user system total real
.hex 10^4 0.010000 0.000000 0.010000 ( 0.003354)
.to_i(16): 10^4 0.000000 0.000000 0.000000 ( 0.003762)
sprintf: 10^4 0.020000 0.000000 0.020000 ( 0.022379)
.hex: 10^5 0.030000 0.000000 0.030000 ( 0.028870)
.to_i(16): 10^5 0.030000 0.000000 0.030000 ( 0.031195)
sprintf: 10^5 0.210000 0.000000 0.210000 ( 0.212064)
.hex: 10^6 0.300000 0.000000 0.300000 ( 0.291441)
.to_i(16): 10^6 0.320000 0.000000 0.320000 ( 0.324304)
sprintf: 10^6 2.200000 0.010000 2.210000 ( 2.202667)
#!/usr/bin/env ruby
# api-auth (1.2.6)
# require 'api_auth'
# leishman/api_auth 2fe4df2319
#require_relative "api_auth/lib/api_auth.rb"
require 'api_auth'
require 'net/http'
@dacamp
dacamp / boom.c
Created October 27, 2015 21:03
generate x amount of artificial load
#define _BSD_SOURCE /* See feature_test_macros(7) */
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/prctl.h>
#include <signal.h>
int main (int argc, char** argv) {
prctl(PR_SET_PDEATHSIG, SIGHUP);
int load = atoi(argv[1]);
@dacamp
dacamp / HostNaming.md
Last active November 17, 2016 01:19
Host naming convention

Document Purpose

This document offers rules for choosing host names, so that Netops can better manage the hosts in production. View the rules below through the eyes of Netops. They need to know, from the host name, what the host does and where it fits in the big picture. No matter how familiar a name is to you, if it means nothing to Netops, there may be better choices for your host name.

The Naming Czar has the power to enforce these rules, and is the final authority for host names.

This document sets rules only for host names, that is, the part of a full domain name up to the first dot. For example, for the domain name app01.p001.us-west-1.aws.xyz.com, the rules cover the name app01. This document does not set rules for for anything else, such as network names, DNS subdomain names, or appliance names.

Status of this Document

This is a document currently under review. It is a draft document and may be updated, replaced, or obsoleted by other documents at any time.

@dacamp
dacamp / gh-35.sh
Last active March 3, 2016 22:30
Ruby-LDAP Ubuntu 14.04 ree-1.8.7-2011.03
dcam@trusty:~/git/ruby-ldap$ make clean
dcam@trusty:~/git/ruby-ldap$
dcam@trusty:~/git/ruby-ldap$ git checkout gh-35
Switched to branch 'gh-35'
Your branch is up-to-date with 'origin/gh-35'.
dcam@trusty:~/git/ruby-ldap$ ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2011.03
dcam@trusty:~/git/ruby-ldap$ ruby extconf.rb
--with-openldap2
checking for ldap.h... yes
@dacamp
dacamp / main.go
Last active November 17, 2016 01:18
Device block mount points in Go
package main
import (
"fmt"
)
func main() {
for i := 0; i < 596; i++ {
if i > 594 {
fmt.Printf("%v: ERROR\n", i)

Keybase proof

I hereby claim:

  • I am dacamp on github.
  • I am misfit_af (https://keybase.io/misfit_af) on keybase.
  • I have a public key ASBcxALw5j39HAao6mbt8WdOoHifqA9SuMBAS-oi9e4jHQo

To claim this, I am signing this object: