Skip to content

Instantly share code, notes, and snippets.

@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. */
# 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 / 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'
@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 / 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"
class ArcFile
include Enumerable
def initialize( input_stream )
@handle=input_stream
end
def each
return self.to_enum unless block_given?
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}"
@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",
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 / wintypes.rb
Created September 29, 2012 09:31
types
# This is mainly so that the rest of the code will appear consistent with
# Windows documentation, and allows me to quickly prototype new APIs by copying
# directly from MSDN.
#
# Author: Ben Nagy
# Copyright: Copyright (c) Ben Nagy, 2006-2012.
# License: The MIT License
# (See http://www.opensource.org/licenses/mit-license.php for details.)
require 'ffi'