Skip to content

Instantly share code, notes, and snippets.

View Thermatix's full-sized avatar

Martin Becker Thermatix

View GitHub Profile
@Thermatix
Thermatix / Dockerfile
Created March 16, 2023 17:38
A set of files that can be used for the purposes of setting up a Rust based dev environment inside of a docker container.
FROM rust:latest AS build
WORKDIR /workspace
FROM build AS dev
@Thermatix
Thermatix / interface_entity.rs
Last active July 30, 2021 21:56
ruby interface DSL
//! This module defines the interface for describing entities in the ruby DSL
//! example:
//! ```ruby
//! entity_group 'basics' do # add new group to entity groups
//! kind :items # set default type
//! # set initial components that can be overridden later
//! components :pos, :loc, glyh: '$'
//!
//! entity 'sword' do # add entity to entity groyp
//! component :renderable do # add new component to entity
@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

about

These are just a bunch of random single file library's I wrote to use in various projects, some might eventually be turned into full gem based libraries.

random libs

  • node.rb - a library for creating node based trees
  • config_loader.rb - a library for loading a config from a file and ensuring it's written back to the file before the app exits
  • state_machine.rb - a library for creating state machines
  • country.rb - a libary for converting between country codes
  • curb_dsl.rb - a library for turning curb into a dsl
  • snake_case.rb - a lirbrary for monkeypatching a method to the String class that converts camel_case to SnakeCase
@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')
})()));
};
class Views_Base
def self.inherited(base)
base.extend Singleton_Methods
end
module Singleton_Methods
attr_accessor :views
@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 #
function ReplayableEventStore (settings) {
var self = this;
var config = {
warnings: def_value(settings.warns,true),
replayPre: def_value(settings.replayPre,true)
};
self.preSubscribeEvents = {};
#!/usr/bin/env ruby
Ticks = 5
Board_Size = 10
Board_Height = 0...Board_Size
Board_Width = 0...(Board_Size * 2)
def print_board board
board.each_with_index do |row,y|
row.each_with_index do |cell,x|
print cell == 1 ? '*' : ' '
require 'easy_set'
module Asset_Pipeline
class Mime_Types
include Easy_Set
set ".x3d", "application/vnd.hzn-3d-crossword"
set ".3gp", "video/3gpp"
set ".3g2", "video/3gpp2"