Skip to content

Instantly share code, notes, and snippets.

@snipsnipsnip
snipsnipsnip / debug.h
Last active August 24, 2019 15:34
http://gist.github.com/141327 with SDL and SDL_image
#ifndef DEBUG_H_
#define DEBUG_H_
#ifdef _MSC_VER
#define PrintInfoFormatIntlIntl(p,line) \
stderr, __FILE__ ":" #line ":" __FUNCTION__ ": " p "\n"
#else
#define PrintInfoFormatIntlIntl(p,line) \
stderr, __FILE__ ":" #line ":%s: " p "\n", __func__
#endif
@snipsnipsnip
snipsnipsnip / example.hex
Last active February 7, 2024 02:35
intel_hex_record.rb: intel hex record parser
:10006000000102030405060708090A0B0C0D0E0F18
:10007000101112131415161718191A1B1C1D1E1F08
:10008000202122000000000000000000000000000D
:100090000000000000000000000000000000000060
:1000A0000000000000000000000000000000000050
:1000B0000000000000000000000000000000000040
:1000C0000000000000000000000000000000000030
:1000D0000000000000000000000000000000002000
:00000001FF
@snipsnipsnip
snipsnipsnip / mt19937ar.c
Last active August 24, 2019 15:35
mt19937ar.c wrapped in a struct
/*
A C-program for MT19937, with initialization improved 2002/1/26.
Coded by Takuji Nishimura and Makoto Matsumoto.
Before using, initialize the state by using init_genrand(seed)
or init_by_array(init_key, key_length).
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
All rights reserved.
Copyright (C) 2005, Mutsuo Saito,
@snipsnipsnip
snipsnipsnip / .gitignore
Last active August 30, 2015 13:44
mukumufu
*.gem
*.rbc
.bundle
.config
coverage
InstalledFiles
lib/bundler/man
pkg
rdoc
spec/reports
@snipsnipsnip
snipsnipsnip / dll2lib.bat
Last active August 24, 2019 15:36
dll2lib: make lib file from dll using msvc's dumpbin and lib (requires ruby)
@ruby -x "%~f0" %*
@exit /b
#!ruby
def dumpbin(filename)
`dumpbin /exports #{filename}`
end
def extract_function_names(exports)
exports[/^\s+ordinal.*^\s+Summary/m].scan(/\s+[A-Z\d+]{8}\s+(\w+)$/)
ER=sfx_ready.exe
E=sfx.exe
OBJS=sfx.obj
TEXT=text.txt
all: $(ER)
clean:
del $(OBJS) $(E) $(ER)
@snipsnipsnip
snipsnipsnip / book.cgi
Last active August 24, 2019 15:37
book.cgi (requires ruby)
#!/usr/local/bin/ruby
require 'webrick/cgi'
BookFile = 'book.txt'
class Book
attr_reader :page
def initialize(io, page)
@snipsnipsnip
snipsnipsnip / repl.lua
Last active August 24, 2019 15:38
repl.lua
local function print_if_not_nil(...)
if ... ~= nil then
print("-> ", ...)
end
end
local function try_to_print(line)
local compiled, errmes = loadstring("return " .. line)
if compiled then
print("=> ", compiled())
// Meeting Cost Clock
// 12 Aug 2009 Keijiro Takahashi
/* standard definition */
#include <iostream>
namespace Arduino
{
typedef unsigned char uint8_t;
@snipsnipsnip
snipsnipsnip / gc_ptr.hpp
Created August 29, 2009 16:29
gc_ptr: (not) smart pointer using boehm gc
#ifndef GC_PTR_HPP_
#define GC_PTR_HPP_
class gc_cleanup;
template <typename T>
class gc_ptr : public gc_cleanup
{
T *ptr;
const P<T> &operator =(T *);