Skip to content

Instantly share code, notes, and snippets.

View eterps's full-sized avatar

Erik Terpstra eterps

View GitHub Profile
@eterps
eterps / sequel_playground.rb
Created April 6, 2016 15:17
Sequel playground
#!/usr/bin/env ruby
require 'sequel'
require 'logger'
require 'awesome_print'
DB = Sequel.sqlite
DB.create_table :people do
primary_key :id
String :name
@eterps
eterps / cuke2json.rb
Created May 16, 2016 14:36
Converts a Gherkin file to JSON
#!/usr/bin/env ruby
require 'json'
require 'gherkin/parser'
filename = ARGV[0]
src = open(filename).read
parser = Gherkin::Parser.new
gherkin_document = parser.parse(src)
scenarios = gherkin_document[:feature][:children].select{|n| n[:type] == :Scenario}
line = gherkin_document[:feature][:location][:line]
# Inverting Dependencies: Hexagonal Architecture
# A Blog post
class Post
def self.write_new_from(title, content)
new(title, content)
end
private
@eterps
eterps / 0_reuse_code.js
Created March 7, 2017 19:46
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@eterps
eterps / example1.json
Last active March 21, 2017 16:33
json-ld example
{
"@context": "https://schema.org",
"@type": "Person",
"familyName": "Simpson"
}
@eterps
eterps / GoldenScheme.js
Created April 30, 2017 14:26
gist of GoldenScheme.js
// License of this source is BSD License.
var GoldenScheme = function() {
// Get debug DOM
this.debugDom = document.getElementById("debug");
if (this.debugDom == null) {
this.debugDom = document.body;
}
// Firefox 莉・螟門ッセ遲�
if(typeof(console) == "undefined") {
console = {
Error in event handler for (unknown): TypeError: Cannot read property 'resp' of undefined
at chrome-extension://pnhplgjpclknigjpccbcnmicgcieojbh/js/content/diigolet.js:129:425
@eterps
eterps / Dockerfile
Created August 27, 2018 08:24
ruby-llvm on recent ubuntu with recent llvm version
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y build-essential git ruby-dev llvm-5.0-dev
RUN gem install bundler rake
RUN /bin/echo -e "source 'https://rubygems.org'\ngem 'ruby-llvm', git: 'https://github.com/ruby-llvm/ruby-llvm', ref: '889e97d'" >Gemfile
RUN bundle install
CMD bundle exec ruby /var/lib/gems/*/bundler/gems/ruby-llvm*/samples/hello.rb
@eterps
eterps / Dockerfile
Created August 27, 2018 08:53
ruby-llvm on ubuntu 16.04 with recent llvm version 3.5
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y build-essential ruby-dev llvm-3.5 wget
RUN gem install bundler rake
RUN /bin/echo -e "source 'https://rubygems.org'\ngem 'ruby-llvm'" >Gemfile
RUN bundle install
RUN wget -nv https://raw.githubusercontent.com/ruby-llvm/ruby-llvm/master/samples/hello.rb
CMD bundle exec ruby hello.rb
@eterps
eterps / Gfx.c
Created September 9, 2018 17:35
obnc input focus issue
#include <obnc/OBNC.h>
#include ".obnc/Gfx.h"
#include <stdbool.h>
#include "SDL.h"
SDL_Surface *screen;
SDL_Event event;
void Gfx_Do_(void) {
SDL_Init(SDL_INIT_VIDEO);