Skip to content

Instantly share code, notes, and snippets.

@anupnivargi
anupnivargi / gist:6652930
Created September 21, 2013 18:27
gem install debugger
gem install debugger
Fetching: debugger-ruby_core_source-1.2.3.gem (100%)
Successfully installed debugger-ruby_core_source-1.2.3
Fetching: debugger-1.6.1.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing debugger:
ERROR: Failed to build gem native extension.
/home/anup/.rvm/rubies/rbx-head/bin/rbx extconf.rb
checking for rb_method_entry_t.called_id in method.h... no
@anupnivargi
anupnivargi / gist:6554728
Created September 13, 2013 19:04
rake build error
rake build
/.rvm/rubies/ruby-2.0.0-p247/bin/ruby vm/codegen/field_extract.rb vm/builtin/basicobject.hpp vm/builtin/object.hpp vm/builtin/integer.hpp vm/builtin/fixnum.hpp vm/builtin/array.hpp vm/builtin/bignum.hpp vm/builtin/executable.hpp vm/builtin/access_variable.hpp vm/builtin/alias.hpp vm/builtin/block_environment.hpp vm/builtin/block_as_method.hpp vm/builtin/bytearray.hpp vm/builtin/io.hpp vm/builtin/channel.hpp vm/builtin/module.hpp vm/builtin/constant_table.hpp vm/builtin/class.hpp vm/builtin/compiledcode.hpp vm/builtin/data.hpp vm/builtin/dir.hpp vm/builtin/exception.hpp vm/builtin/float.hpp vm/builtin/immediates.hpp vm/builtin/iseq.hpp vm/builtin/list.hpp vm/builtin/lookuptable.hpp vm/builtin/ffi_pointer.hpp vm/builtin/methodtable.hpp vm/builtin/nativefunction.hpp vm/builtin/packed_object.hpp vm/builtin/randomizer.hpp vm/builtin/regexp.hpp vm/builtin/constantscope.hpp vm/builtin/encoding.hpp vm/builtin/string.hpp vm/builtin/symbol.hpp vm/builtin/thread.hpp vm/builtin/tuple.hpp vm/builtin/compactlook
@anupnivargi
anupnivargi / gist:6393086
Last active December 22, 2015 00:59
Encoding
#On IRB
"\xFEhi".ascii_only? # => false
#io19.rb +754
def check_invalid_bytes(data)
return if data.ascii_only? # => true
from_enc = data.encoding
to_enc = external_encoding
@anupnivargi
anupnivargi / gist:6388123
Created August 30, 2013 09:37
Encoding Issue
#MRI
```
"hi".encode(Encoding::UTF_16).length # => 6
"hi".encode(Encoding::UTF_16) # => "\uFEFFhi"
```
#RBX
```
"hi".encode(Encoding::UTF_16).length # => 6
@anupnivargi
anupnivargi / io.rb
Created August 30, 2013 08:01
IO#write discussion
def write(data)
data = String data
return 0 if data.length == 0
ensure_open_and_writable
data.encode!(external_encoding) if external_encoding
if @sync
prim_write(data)
else
@anupnivargi
anupnivargi / gist:6376792
Created August 29, 2013 11:12
File.expand_path encoding discussion
#MRI 2.0
```
Encoding.default_external = Encoding::US_ASCII
File.expand_path("./a").encoding # => #<Encoding:UTF-8>
File.expand_path("./a".encode(Encoding::SHIFT_JIS)).encoding # => #<Encoding:Shift_JIS>
```
@anupnivargi
anupnivargi / gist:6369136
Created August 28, 2013 17:58
Error log
vm/util/timing.c: In function ‘thread_cpu_usage’:
vm/util/timing.c:27:3: error: aggregate value used where an integer was expected
vm/util/timing.c:28:3: error: aggregate value used where an integer was expected
Error: gcc -Ivm -Ivm/test/cxxtest -I. -Ivendor/llvm/include -Ivendor/udis86 -Ivendor/libffi/include -Ivendor/double-conversion/src -DHAVE_CONFIG_H -I. -I../../vm/capi/19/include -Ivendor/oniguruma -Ivendor/libtommath -pipe -Wall -fno-omit-frame-pointer -g -I/usr/local/include -fPIC -O2 -DHAS_EXECINFO -DHAVE_SPT_REUSEARGV -DHAVE_CLOCK_GETTIME -DHAVE_NL_LANGINFO -DHAVE_POSIX_FADVISE -DHAVE_TM_GMTOFF -DHAVE_TM_ZONE -DHAVE_TIMEZONE -DHAVE_TZNAME -DHAVE_DAYLIGHT -DHAVE_ALLOCA_H -DHAVE_STRING_H -DHAVE_SYS_TIME_H -DHAVE_SYS_TIMES_H -DHAVE_SYS_TYPES_H -DHAVE_UNISTD_H -DHAVE_STDARG_H -DSTRERROR_R_CHAR_P -I/home/anup/code/github/rubinius/vendor/llvm/Release/include -D_GNU_SOURCE -fPIC -DENABLE_LLVM -Wno-unused-function -Werror -DRBX_PROFILER -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D_LARGEFILE_SOURCE -
@anupnivargi
anupnivargi / gist:6220364
Created August 13, 2013 11:51
Symbol Encoding
#Ruby 2.0
:"\xC3\x9Cber".encoding # => #<Encoding:UTF-8>
:a.encoding # => #<Encoding:US-ASCII>
#Rbx
:"\xC3\x9Cber".encoding # => #<Encoding:US-ASCII>
:a.encoding # => #<Encoding:US-ASCII>
diff --git a/kernel/common/regexp19.rb b/kernel/common/regexp19.rb
index 6af0dcf..07c03fd 100644
--- a/kernel/common/regexp19.rb
+++ b/kernel/common/regexp19.rb
@@ -116,12 +116,14 @@ class Regexp
source.encoding
end
- def self.convert(pattern)
- return pattern if pattern.kind_of? Regexp
@anupnivargi
anupnivargi / gist:6191939
Created August 9, 2013 08:06
Regexp Union
diff --git a/kernel/common/regexp19.rb b/kernel/common/regexp19.rb
index 8496d78..4459921 100644
--- a/kernel/common/regexp19.rb
+++ b/kernel/common/regexp19.rb
@@ -116,26 +116,6 @@ class Regexp
source.encoding
end
- def self.compatible_encodings(*patterns)
- ascii = []