Skip to content

Instantly share code, notes, and snippets.

Avatar

Erik Terpstra eterps

View GitHub Profile
View sequel_playground.rb
#!/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
Converts a Gherkin file to JSON
View cuke2json.rb
#!/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]
View ddd_example.rb
# 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 Mar 7, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// 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 Mar 21, 2017
json-ld example
View example1.json
{
"@context": "https://schema.org",
"@type": "Person",
"familyName": "Simpson"
}
@eterps
eterps / GoldenScheme.js
Created Apr 30, 2017
gist of GoldenScheme.js
View 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 = {
View diigo_crash.js
Error in event handler for (unknown): TypeError: Cannot read property 'resp' of undefined
at chrome-extension://pnhplgjpclknigjpccbcnmicgcieojbh/js/content/diigolet.js:129:425
View cs.md

Why I barely read SF these days By Charlie Stross Being a guy who writes science fiction, people expect me to be well-informed about the current state of the field—as if I'm a book reviewer who reads everything published in my own approximate area.

(This is a little like expecting a bus driver to have an informed opinion on every other form of four-wheeled road-going transport.)

Similarly, marketing folks keep sending me SF novels in the hope I'll read them and volunteer a cover quote. But over the past decade I've found myself increasingly reluctant to read the stuff they send me: I have a vague sense of dyspepsia, as if I've just eaten a seven course banquet and the waiter is approaching me with a wafer-thin mint.

This isn't to say that I haven't read a lot of SF over the past several decades. While I'm an autodidact—there are holes in my background—I've read most of the classics of the field, at least prior to the 1990s. But about a decade ago I stopped reading SF short stories, and this past decade I'v

@eterps
eterps / Dockerfile
Created Aug 27, 2018
ruby-llvm on recent ubuntu with recent llvm version
View Dockerfile
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 Aug 27, 2018
ruby-llvm on ubuntu 16.04 with recent llvm version 3.5
View Dockerfile
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