Skip to content

Instantly share code, notes, and snippets.

Eric Kidd emk

Block or report user

Report or block emk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@emk
emk / phase.ks
Created Feb 18, 2018
Kerbal Space Program satellite orbit phasing using kOS and MechJeb
View phase.ks
// Change the phase of your orbit, that is, advance yourself a certain
// amount of time along the same orbit path.
//
// See https://en.wikipedia.org/wiki/Orbit_phasing for the math and lots
// of explanations.
//
// AUTHOR: Eric Kidd.
//
// REQUIREMENTS: To run this, you'll need Kerbel Space Program, the kOS mod,
// and a computer on your craft.
@emk
emk / nginx-proxy-taskdef-draft.json
Created May 14, 2017
nginx-proxy ECS config (untested)
View nginx-proxy-taskdef-draft.json
{
"containerDefinitions": [
{
"name": "nginx-proxy",
"image": "771600087445.dkr.ecr.us-east-1.amazonaws.com/nginx-proxy:latest",
"memory": "128",
"essential": true,
"portMappings": [
{
"hostPort": "443",
@emk
emk / Application.elm
Created Dec 1, 2015
Elm case matching on complex records?
View Application.elm
type alias Model =
{ errorMessage: Maybe String -- This is what Rails would call a "flash": we just show it.
, video: Maybe Video.Model -- Information about a video and subtitles.
, player: Maybe VideoPlayer.Model -- Player state: URL, playing/paused, time.
}
type Action
= VideoLoaded Video.Model
| VideoPlayerAction VideoPlayer.Action
@emk
emk / fn_trait.rs
Last active Aug 29, 2015
Implementing traits for function types?
View fn_trait.rs
// Based on:
// https://github.com/emk/jit.rs/blob/master/src/macros.rs#L41-L64
// https://github.com/emk/jit.rs/blob/master/src/compile.rs#L105-L109
// https://github.com/emk/jit.rs/blob/master/examples/hello_world.rs#L22
// Build on branch:
// https://github.com/emk/jit.rs/tree/rust-beta-updates
trait Foo {}
impl Foo for fn() {}
@emk
emk / gist:51dee73348e2cc5f4077
Created Apr 29, 2015
Vault's GitHub auth module doesn't explain its config options
View gist:51dee73348e2cc5f4077
$ vault help auth/github/config
Error reading help: Error making API request.
URL: GET http://127.0.0.1:8200/v1/auth/github/config?help=1
Code: 500. Errors:
* unsupported operation
View keybase.md

Keybase proof

I hereby claim:

  • I am emk on github.
  • I am emk (https://keybase.io/emk) on keybase.
  • I have a public key whose fingerprint is C641 D85B 8218 678E 41F5 7961 5533 ABC9 38D4 BE26

To claim this, I am signing this object:

@emk
emk / csv2pbo
Created Dec 23, 2014
Convert CSV files to PBO parallel bilingual books
View csv2pbo
#!/usr/bin/env ruby
#
# Usage:
# csv2pbo book.csv > book.pbo
require 'csv'
path = ARGV[0]
# PBO format _looks_ like XML, but the parser is very fragile. So we
@emk
emk / multithreaded-traits.rs
Created Dec 15, 2014
Multithreaded trait access
View multithreaded-traits.rs
use std::sync::Arc;
use std::sync::RWLock;
use std::task::spawn;
trait Common : Sized + Send + Sync {
fn munge(&mut self);
}
#[deriving(Show)]
struct Foo { i: int }
@emk
emk / call.rs
Created Dec 12, 2014
Can't call through trait
View call.rs
/// Call the global JavaScript function named `fn_name` with `args`, and
/// return the result.
pub fn call<'a>(&mut self, fn_name: &str,
args: &[&Encodable<Encoder<'a>, DuktapeError>]) ->
DuktapeResult<Value<'static>>
{
unsafe {
assert_stack_height_unchanged!(self, {
duk_push_global_object(self.ptr);
fn_name.with_c_str(|c_str| {
@emk
emk / context_error.rs
Created Dec 10, 2014
Having trouble with Rust encoder lifetime & trait
View context_error.rs
// Try this on http://play.rust-lang.org/
extern crate libc;
extern crate serialize;
use std::ptr::null_mut;
use libc::c_void;
// This needs to be mutable in practice.
pub struct Context;
You can’t perform that action at this time.