Skip to content

Instantly share code, notes, and snippets.


Ry Biesemeyer yaauie

View GitHub Profile
yaauie / hello.jscript.bat
Created May 6, 2011
A Polyglot for jscript in batch
View hello.jscript.bat
0</* :hello
@ECHO Hello, batch!
@cscript /nologo /E:jscript %~f0 %*
@goto :EOF
WScript.Echo('Hello, jscript!');
View gist:1072705
[-] Bootstrap
[X] Autoloading, etc.
[-] Logging functionality
[X] Log levels
[X] Linear/stream logs
[-] Template logs
[X] TypedArray class
[-] Common
View typed-arrays-in-ruby.rfc.markdown

Typed Arrays in Ruby RFC

NOTE: This RFC is closed; I went ahead and implemented. If you've got a problem with that, fork the project and make it better:

tl;dr: Ruby does not have an Array class that enforces the type of its members; such a class can be useful, so I have created one. I would like help in determining the interface for it.


View noisy_redis.rb
module NoisyRedis
module NoisyClient
def process(commands,&b)
r = super(commands,&b)
puts "#{}>>#{}\#process(#{commands.inspect}#{block_given? ? ' <&block>' : ''}) \#=> #{r.inspect}"
def self.extended(redis)
View gist:3298674

Given: this rspec file is in PROJECT_ROOT/spec

describe 'codebase' do
  let(:lines_with_more_than_80_characters) do
    Dir.glob( File.expand_path('../../lib/**/*.rb', __FILE__ ) ).map do |path| path ) do |file|
        idx = 0 do |line|
          idx += 1
View sparsify.rb
# Extend into a hash to provide sparse and unsparse methods.
# {'foo'=>{'bar'=>'bingo'}}.sparse #=> {''=>'bingo'}
# {''=>'bingo'}.unsparse => {'foo'=>{'bar'=>'bingo'}}
# options:
module Sparsify
def sparse(options={}) do |k,v|
prefix = (options.fetch(:prefix,[])+[k])
View range-split-usage.rb
require_relative 'range-split'
(1...1000).split(3) #=> [1...334, 334...667, 667...1000]
(1..1000).split(3) #=> [1...335, 335...669, 669..1000]
View find_transformed.rb
module FindTransformed
def find_transformed
self.each do |item|
result = yield(item)
return result if result

RFC: Range#empty?

Often times it is useful to know whether a Range is empty without iterating over it or converting it to an array, especially with large (read: potentially infinite) ranges. This RFC is an attempt to find an efficient, always-correct, simple implementation of Range#empty?.

Current Best Implementation

module Range::IsEmpty
  def empty?
yaauie / jason-voorhees.rb
Last active Jun 29, 2017
JSON-decode recursively until it isn't JSON anymore.
View jason-voorhees.rb
# encoding: utf-8
require 'json'
# For when someone puts JSON in your JSON
# (because MurderingRampage™)
class JasonVoorhees
def self.load(*args)*args)
You can’t perform that action at this time.