Skip to content

Instantly share code, notes, and snippets.

View Thermatix's full-sized avatar

Martin Becker Thermatix

View GitHub Profile
@Thermatix
Thermatix / whitespace-a-like.rb
Created August 25, 2017 13:22 — forked from Dan-Q/whitespace-a-like.rb
Encode a Ruby program into a version composed almost entirely of unicode whitespace characters. Decodes itself on the fly.
#!/usr/bin/env ruby
# encoding: utf-8
CHARS = %w{                       ​ ‌ ‍    }
def encode(string)
string.chars.map{|c|"#{CHARS[c[0]/16]}#{CHARS[c[0]%16]}"}.join
end
program = <<-EOF
@Thermatix
Thermatix / ObjectFetch.js
Last active October 7, 2016 15:09 — forked from sposmen/ObjectFetch.js
Equivalent to Ruby hash fetch in Javascript
Object.prototype.fetch = function (key, value,callback) {
return this.hasOwnProperty(key) ? this[key] : (value ? value : (callback ? callback.call : (function () {
throw new Error('key not found')
})()));
};
@Thermatix
Thermatix / .gitignore
Created July 20, 2016 08:49 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@Thermatix
Thermatix / chunked_file_uploads_to_remote_in_sinatra.rb
Last active November 11, 2015 14:38 — forked from sasimpson/gist:1112739
Ruby Net:HTTP chunked transfer
require 'uri'
require 'net/http'
class Chunked
def initialize(data, chunk_size)
@size = chunk_size
if data.respond_to? :read
@file = data
end
end
@Thermatix
Thermatix / apps.rb
Created October 21, 2015 16:08 — forked from achiurizo/apps.rb
sinatra hack to mount via padrino mount
# foo.rb
class Foo < ::Sinatra::Base
class << self
def dependencies; []; end
def setup_application!; end
end
get '/' do
'wubwub'