Skip to content

Instantly share code, notes, and snippets.

@jonforums
jonforums / dl_readfile.rb
Created March 16, 2011 13:03
Ruby 1.9.2 DL nested structs
require 'dl/import'
require 'dl/types'
module Win32FileAPI
extend DL::Importer
dlload 'kernel32.dll', 'user32.dll'
include DL::Win32Types
@jonforums
jonforums / gist:911713
Created April 9, 2011 19:50
Support thin source gem builds on Windows
diff --git a/lib/thin.rb b/lib/thin.rb
index 10b5ff3..83e96ba 100644
--- a/lib/thin.rb
+++ b/lib/thin.rb
@@ -41,8 +41,14 @@ require "#{Thin::ROOT}/rack/adapter/loader"
if Thin.win?
# Select proper binary under Windows
- major_ruby_version = RUBY_VERSION[/^(\d+\.\d+)/]
- require "#{Thin::ROOT}/#{major_ruby_version}/thin_parser"
@jonforums
jonforums / fail-fiddle-mkmf.log
Created April 25, 2011 13:53
Evaluating MinGW-w64 as toolchain for RI
package configuration for libffi is not found
have_header: checking for ffi.h... -------------------- yes
*** mkmf:try_do ENV={"!::"=>"::\\", "!EXITCODE"=>"00000000", "AR"=>"i686-w64-mingw32-ar",
"AS"=>"i686-w64-mingw32-as", "CC"=>"i686-w64-mingw32-gcc",
"CPATH"=>"C:\\projects\\rubyinstaller-git\\sandbox\\zlib\\include;C:\\projects\\rubyinstaller-git\\sandbox\\libffi\\include;",
"CPP"=>"i686-w64-mingw32-cpp", "CXX"=>"i686-w64-mingw32-g++", "DKVER"=>"mingw64-32-4.5.3",
"DLLTOOL"=>"i686-w64-mingw32-dlltool", "DLLWRAP"=>"i686-w64-mingw32-dllwrap --target=mingw32 --driver-name=\"i686-w64-mingw32-gcc\" -mno-cygwin",
"LIBRARY_PATH"=>"C:\\projects\\rubyinstaller-git\\sandbox\\zlib\\lib;C:\\projects\\rubyinstaller-git\\sandbox\\libffi\\lib;",
"LOCAL"=>"c:\\Users\\Jon\\Documents\\RubyDev\\ruby-git", "MAKEFLAGS"=>"", "MAKELEVEL"=>"1",
@jonforums
jonforums / predefs.c
Created May 12, 2011 13:48
CL and MinGW compiler predefs
/* build with:
* gcc -DNDEBUG -o predefs-mingw.exe predefs.c
* -or-
* cl /DNDEBUG /Fepredefs-msvc.exe predefs.c
*
* NOTE: can cause gcc to spew it's predefs with
* echo . | gcc -dM -E -
*/
#include <assert.h>
#include <string.h>
@jonforums
jonforums / gist:976923
Created May 17, 2011 17:32
RubyInstaller 1.8.7 rdiscount installation
C:\Users\Jon>gem list rdiscount
*** LOCAL GEMS ***
rdiscount (1.6.8)
C:\Users\Jon>ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('**Hello RubyInstaller**').to_html"
<p><strong>Hello RubyInstaller</strong></p>
@jonforums
jonforums / config-1.9.3.iss
Created June 1, 2011 15:51
Quick ugly hacks to build development installlers
; Ruby 1.9.3-p9999 Configuration File.
; TODO update to parse from source file/dir, potentially move to main script
#define RubyBuildPlatform "i386-mingw32"
[Setup]
AppId={{17E73B15-62D2-43FD-B851-ACF86A8C9D25}
DefaultDirName={sd}\Ruby193
[Files]
@jonforums
jonforums / gist:1075878
Created July 11, 2011 13:50
XML validation with external DTD in .NET experiment
/*
* Author: Jon Maken
* Creation Date: 5/24/2004 1:03 PM
* Version: 0.95, 7/2/2004
* License: Modified BSD License (3-clause)
*/
using System;
using System.IO;
using System.Text;
using System.Xml;
@jonforums
jonforums / add_ramdisk.bat
Created July 20, 2011 16:28
My imdisk RAMdisk helper script
@echo OFF
if "%1" == "" goto :EOS
if "%2" == "" goto :EOS
imdisk -a -t vm -m %1 -s %2 -o rw,hd -p "/fs:ntfs /q /y"
goto :eof
:EOS
echo usage: add_ramdisk MOUNT_POINT SIZE
echo.
echo add_ramdisk V: 1100M
@jonforums
jonforums / BINARY FILE READS (CRLF)
Created July 21, 2011 14:00
Investigating MRI 1.9.x file reading performance regressions
## microbenchmark for binary reading of file with CRLF endings
C:\projects\measurements-git>pik run rci bench core_brd_filelines_crlf
jruby 1.6.3 (ruby-1.8.7-p330) (2011-07-07 965162f) (Java HotSpot(TM) Client VM 1.6.0_26) [Windows 7-x86-java]
Rehearsal -----------------------------------------------------------
core_brd_filelines_crlf 2.139000 0.000000 2.139000 ( 2.109000)
-------------------------------------------------- total: 2.139000sec
user system total real
@jonforums
jonforums / 0001-albino-windows-refactor.patch
Created August 23, 2011 20:20
Make Jekyll play nice with Windows again post Albino + posix-spawn refactor
diff --git a/lib/albino.rb b/lib/albino.rb
index 387c8e9..b77d55e 100644
--- a/lib/albino.rb
+++ b/lib/albino.rb
@@ -1,4 +1,5 @@
require 'posix-spawn'
+require 'rbconfig'
##
# Wrapper for the Pygments command line tool, pygmentize.