Skip to content

Instantly share code, notes, and snippets.

~ ▻ gem install --debug chef
NOTE: Debugging mode prints all exceptions even when rescued
Exception `ArgumentError' at /home/mediocregopher/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/resolv.rb:2318 - IPv6 address must be 16 bytes
ERROR: While executing gem ... (ArgumentError)
IPv6 address must be 16 bytes
/home/mediocregopher/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/resolv.rb:2318:in `initialize'
/home/mediocregopher/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/resolv.rb:2058:in `new'
/home/mediocregopher/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/resolv.rb:2058:in `decode_rdata'
/home/mediocregopher/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/resolv.rb:1556:in `block in get_rr'
/home/mediocregopher/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/resolv.rb:1457:in `get_length16'

Keybase proof

I hereby claim:

  • I am mediocregopher on github.
  • I am mediocregopher (https://keybase.io/mediocregopher) on keybase.
  • I have a public key whose fingerprint is 27AB 502A 9EA8 96F6 4A27 4970 95C4 6FA6 A411 48AC

To claim this, I am signing this object:

package main
import (
"fmt"
)
type Set map[interface{}]bool
func Intersection(s1, s2 Set) Set {
rs := Set{}
@mediocregopher
mediocregopher / deets.md
Last active December 28, 2015 22:59 — forked from MarcoPolo/deets.md

Cryptic's Crypto Details:

Registration

In-browser

  • The user chooses a username and password
  • A pub/priv key is generated and stored in a structure called the user blob. (A user will have the option to upload their own set of keys too)
  • The user blob also contains a file tree which will store uploaded files (with their encryption key) and folders (for organizing files).
  • The user blob is encrypted with the PBKDF2 hash of the user's password.
user> (def fiz (cycle [nil nil "Fiz"]))
#'user/fiz
user> (def buzz (cycle [nil nil nil nil "Buzz"]))
#'user/buzz
user> (take 15 (map (partial apply str) (map list fiz buzz)))
("" "" "Fiz" "" "Buzz" "Fiz" "" "" "Fiz" "Buzz" "" "Fiz" "" "" "FizBuzz")
@mediocregopher
mediocregopher / dir.php
Created October 2, 2013 01:57
I was using this as a directory index of sorts. It does all the things a normal directory index does, except that it also allows you to download a directory as a tar.gz. I don't remember how I set it up exactly, I remember there were some nginx rewrites needed
<?php
$dir = $_GET['request_filename'];
if (is_dir($dir)) {
if (!preg_match('/\/$/',$dir)) {
header("Location: ".$_SERVER['REQUEST_URI'].'/');
exit;
}
print "$dir<br/><br/>";
@mediocregopher
mediocregopher / ref.clj
Created April 25, 2013 04:39
Given either a numeric id or name, returns all the children of that reference from sql. If the numeric id is given a normal select is done, if the name is given a subselect to get the id is done.
(defn get-reference-children
[fn-id] ;fullname-or-id
(-> (select* reference)
(fields :id :fullname :isDir )
(#(if-not (string? fn-id)
(where %1 {:parent_id fn-id})
(where %1 {:parent_id (subselect reference
(fields :id)
(limit 1)
(where {:fullname fn-id}))} )))
@mediocregopher
mediocregopher / erl_node.c
Last active December 15, 2015 18:39
My attempt at making an erlang node
//To make gethostname be defined
#define _BSD_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
@mediocregopher
mediocregopher / json-gist.py
Created January 2, 2013 22:23
Reads in lines, interprets them as json, then recursively replaces all dictionary values with '...' and all lists with [ '...' ]. The idea is that you can use this to get the "gist" of the json struct, so if you have a lot of json structs you're analyzing to find similarities this may help. (Works on py2 and py3)
#!/usr/bin/env python
import sys
import json
def main():
for line in sys.stdin:
struct = json.loads(line)
clean_struct(struct)
clean_line = json.dumps(struct,sort_keys=True)
@mediocregopher
mediocregopher / pconn
Created November 12, 2012 22:39
Holds a connection to socketspam open. To use: make-connection initializes the connection and sets up recovery. send-data sends whatever string you give it to socketspam.
(ns socketspam.pconn
(:use lamina.core aleph.tcp aleph.formats))
(def socketspam-host "localhost")
(def socketspam-port 9000)
;Create an endpoint and ground it so messages don't get queued up
;if nothing is listening
(def endpoint (channel))
(ground endpoint)