Skip to content

Instantly share code, notes, and snippets.

class Player
def initialize(name, health=100)
@name = name.capitalize
@health = health
end
def say_hello
puts "I'm #{@name} with a health of #{@health}."
end
@bnagy
bnagy / ntstatus.rb
Created June 13, 2013 13:08
ntstatus
NTSTATUS_ERRORS = {
'STATUS_SUCCESS' => "0x00000000",
'STATUS_SEVERITY_SUCCESS' => "0x00000000",
'STATUS_SEVERITY_INFORMATIONAL' => "0x00000001",
'STATUS_SEVERITY_WARNING' => "0x00000002",
'STATUS_SEVERITY_ERROR' => "0x00000003",
'STATUS_WAIT_0' => "0x00000000",
'STATUS_WAIT_1' => "0x00000001",
'STATUS_WAIT_2' => "0x00000002",
'STATUS_WAIT_3' => "0x00000003",
ARGF.each_line {|line|
begin
warn "Starting work on #{line.chomp}"
# expect a line like this:
# s3://commoncrawl-crawl-002/2010/09/24/9/1285380159663_9.arc.gz
proto,unused,bucket_name,*rest=line.chomp.split File::SEPARATOR
raise ArgumentError, "#{__FILE__}: Unknown S3 Protocol #{proto}" unless proto=~/^s3/
object_name=File.join rest
size=Integer( s3.buckets[bucket_name].objects[object_name].content_length )
warn "Reading from #{bucket_name.inspect}, #{object_name.inspect}, size #{size}"
class ArcFile
include Enumerable
def initialize( input_stream )
@handle=input_stream
end
def each
return self.to_enum unless block_given?
@bnagy
bnagy / gootool.go
Last active August 29, 2015 13:59
gootool
package main
import (
"bytes"
"container/list"
"debug/macho"
"encoding/hex"
"flag"
"fmt"
cs "github.com/bnagy/gapstone"
@bnagy
bnagy / srv2.rb
Created October 2, 2014 03:45
openssl issue
require 'openssl'
require 'socket'
# client.rb - minimal SSL client
# require 'openssl'
# require 'socket'
# include OpenSSL::SSL
# HOST = '::1'
@bnagy
bnagy / server.rb
Last active August 29, 2015 14:07
openssl issue
require 'openssl'
require 'socket'
# client.rb - minimal SSL client
# require 'openssl'
# require 'socket'
# include OpenSSL::SSL
# HOST = '::1'
# Abstract access to internal files in docx format. Right now this uses system
# zip and tempfiles because the available ruby zip libraries don't seem to be
# able to produce files that Word will read.
#
# Author: Ben Nagy
# Copyright: Copyright (c) Ben Nagy, 2006-2013.
# License: The MIT License
# (See http://www.opensource.org/licenses/mit-license.php for details.)
require 'tempfile'
@bnagy
bnagy / foo.h
Last active August 29, 2015 14:23
buildmode c-shared
/* Created by "go tool cgo" - DO NOT EDIT. */
/* package github.com/bnagy/cshared */
/* Start of preamble from import "C" comments. */
/* End of preamble from import "C" comments. */
@bnagy
bnagy / gpgmutt.md
Last active March 30, 2024 07:52
Mutt, Gmail and GPG

GPG / Mutt / Gmail

About

This is a collection of snippets, not a comprehensive guide. I suggest you start with Operational PGP.

Here is an incomplete list of things that are different from other approaches:

  • I don't use keyservers. Ever.
  • Yes, I use Gmail instead of some bespoke hipster freedom service