Skip to content

Instantly share code, notes, and snippets.

View benhamill's full-sized avatar
💖

Ben Hamill benhamill

💖
View GitHub Profile
@benhamill
benhamill / kobolds.md
Last active May 22, 2020 20:45
My take on Kobolds: Nature's dog/bird/lizard friends.

Kobolds

Foreword

I have never, I'm pretty sure, read any official write-up of what a kobold is. Everything I know about kobolds is apocryphal and from various conflicting sources. That is, as far as I'm concerned, as it should be. I don't put much stock in official sources, anyway, because they mostly talk about how kobolds are inherently evil, which is garbage.

#!/usr/bin/env elixir
defmodule Listen do
use GenServer
## Client
def start_link(command, opts \\ []) do
GenServer.start_link(__MODULE__, command, opts)
end
Last login: Thu Feb 25 00:02:32 on ttys004
UALC02NJ0RCG3QR:~ bhamill$ bash --version
GNU bash, version 4.3.42(1)-release (x86_64-apple-darwin14.5.0)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
UALC02NJ0RCG3QR:~ bhamill$ cat ~/.bashrc
export HI=hi
@benhamill
benhamill / explanation.md
Last active February 15, 2016 03:01
Elixir Port Experiment

I'm trying to understand how Elixir's Port works. I'd like to interact with another command that's run and communicate over :stdio and detect when the other proccess ends in order to gracefully handle it. In my actual application, I'll send input to the other process, get the result and check it. If it's good, I'll repeat. However, if the other process exits after sending any result, my program should take some actions and then exit its self. This is meant to be normal behavior, not an error.

However, when I run the below toy script, I'm getting errors trying to deal with the other process exiting. The 3 other processes I wrote are meant to read one line, echo it back, then exit, while the toy script has 3 items to deal with (it should just do the first, then report exit and end).

Here's how it's running on my system:

@benhamill
benhamill / stub_service.rb
Created November 2, 2013 04:47
Just testing out ideas from this blog post: https://brandur.org/service-stubs
require 'webmock'
require 'sinatra/base'
require 'multi_json'
require 'pry'
require 'faraday'
WebMock.disable_net_connect!
class HalSinatra < Sinatra::Base
configure do
gem 'activesupport', '4.0.0'
require 'minitest/autorun'
require 'active_support/inflector'
class BugTest < MiniTest::Unit::TestCase
def test_underscore_knows_about_acronyms_in_directories
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'OAuth'
end
@benhamill
benhamill / wut.rb
Created August 6, 2013 04:46
includes + where + select Ignores Your select_values See [this repo](https://github.com/benhamill/ar_include_test#whats-up-with-includes) for an interactive explanation, which might aid investigation.
gem 'activerecord', '4.0.0'
require 'active_record'
require 'sqlite3'
require 'logger'
require 'minitest/autorun'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
def example_method
[1,2].map do |i|
puts i
puts 'whoa'
end
end
def new(first_name: 'Ben',
last_name: 'Hamill',
birthday: '1982/02/13',
title: 'Software Engineer')
@name = "#{first_name} #{last_name}"
@birthday = Date.parse(birthday)
@title = title
end
def new(
@benhamill
benhamill / rant.md
Created February 2, 2013 04:29
How I Want Ruby's `Object#method` To Work

How I Want Ruby's Object#method To Work

The simple case, is this guy:

> m = SecureRandom.method(:hex)
=> #<Method: SecureRandom.hex>
> m.call
=> "5928aab178404945fb560a249b67a000"
> m.call