Skip to content

Instantly share code, notes, and snippets.

View djberg96's full-sized avatar

Daniel Berger djberg96

View GitHub Profile
@djberg96
djberg96 / gist:2945488
Created June 17, 2012 19:17
Weird ri output on Windows console
# What are these funky characters I'm seeing on my console?
c:\>ri File.read
←[0m←[1;32mFile.read←[m
(from ruby core)
←[32mImplementation from IO←[m
@djberg96
djberg96 / gist:2966965
Created June 21, 2012 16:51
Trouble installing pg gem on Windows
# I've got a have_library call failing when I tried to install the pg gem
c:\Users\djberge\Downloads\Ruby>gem install pg -- --with-pg-dir="c:\Program Files (x86)\PostgreSQL\9.1"
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
c:/usr/bin/ruby.exe extconf.rb --with-pg-dir=c:\Program Files (x86)\PostgreSQL\9.1
checking for pg_config... yes
@djberg96
djberg96 / gist:2967972
Created June 21, 2012 19:30
Trouble with RubyInline and VS++
Visual Studio 10
Windows 7
I installed RubyInline without (apparent) issue. Tried this code next:
# stuff.rb
require 'inline'
class Array
inline :C do |builder|
@djberg96
djberg96 / average.c
Created June 21, 2012 22:01
RubyInline generated C code
#include "ruby.h"
# line 6 "average.rb"
static VALUE stuff(VALUE self, VALUE _self) {
VALUE self = (_self);
return (INT2FIX(7));
}
@djberg96
djberg96 / gist:2975974
Created June 23, 2012 00:28
RubyInline example failure
# Chopped path
27) Failure:
test_accessor(TestInline::TestC) [c:/Users/djberge/Repositories/djberg96-rubyinline/test/t
est_inline.rb:152]:
--- expected
+++ actual
@@ -1,4 +1,4 @@
-["# line N \"c:/Users/djberge/Repositories/djberg96-rubyinline/lib/inline.rb\"
+["# line N \"c\"
@djberg96
djberg96 / gist:3012443
Created June 28, 2012 16:48
Trouble with JRuby and Rake::TestTask#loader option
C:\Users\djberge\Repositories\win32-sound>jruby -S rake --trace
** Invoke default (first_time)
** Invoke test (first_time)
** Execute test
c:/jruby/bin/jruby.exe -w -I"lib" "test/test*.rb"
Error opening script file: C:/Users/djberge/Repositories/win32-sound/test/test*.rb (The fi
lename, directory name, or volume label syntax is incorrect)
rake aborted!
Command failed with status (1): [c:/jruby/bin/jruby.exe -w -I"lib" "test/t...]
@djberg96
djberg96 / gist:3014206
Created June 28, 2012 21:53
socketpair on windows
c:\Users\djberge\Repositories\win32-sound>irb
irb(main):001:0> require 'socket'
=> true
irb(main):002:0> sockets = Socket.pair(Socket::AF_INET, Socket::SOCK_STREAM, 0)
=> [#<Socket:fd 4>, #<Socket:fd 5>]
@djberg96
djberg96 / gist:3014387
Created June 28, 2012 22:26
jruby windows command shell problem
c:\Users\djberge\Repositories\win32-sound>jruby -Ilib test/test*.rb
Error opening script file: c:/Users/djberge/Repositories/win32-sound/test/test*.rb (The filename, directory name, or volume label syntax is incorrect)
@djberg96
djberg96 / gist:3018498
Created June 29, 2012 15:11
Problem initializing array of union
# It seems this is the wrong way to create an array of union in FFI. What's the right way?
array = []
# FileSegmentElement is an FFI::Union, and :Alignment is a :uint64
for i in 0...page_num
segment = FileSegmentElement.new
segment[:Alignment] = base_address + page_size * i
array << segment
end
@djberg96
djberg96 / temp.rb
Created July 3, 2012 16:04
file-temp java
require 'java'
import java.lang.System
class File::Temp < File
VERSION = '1.2.2'
TMPDIR = System.getProperties["java.io.tmpdir"]
attr_reader :path