Skip to content

Instantly share code, notes, and snippets.

View dimfeld's full-sized avatar

Daniel Imfeld dimfeld

View GitHub Profile
@dimfeld
dimfeld / days_until_earnings
Created November 21, 2019 18:50
Thinkscript for Days until Earnings
input length = 60;
def xx = -GetEventOffset(Events.EARNINGS);
def yy = Sum(HasEarnings(type = EarningTime.AFTER_MARKET), length)[-length + 1] > 0;
plot x = xx + yy * .5;
x.AssignValueColor( if x <= 1 then Color.LIGHT_RED else Color.DARK_GRAY);
@dimfeld
dimfeld / slog-logging-middleware.rs
Last active August 27, 2021 04:50
Simple actix-web middleware for custom KV logging with slog
use actix_service::{Service, Transform};
use actix_web::{dev::ServiceRequest, dev::ServiceResponse, Error};
use futures::future::{ok, FutureResult};
use futures::{Future, Poll};
use slog::info;
// There are two step in middleware processing.
// 1. Middleware initialization, middleware factory get called with
// next service in chain as parameter.
// 2. Middleware's call method get called with normal request.
@dimfeld
dimfeld / index.js
Last active June 13, 2018 21:49
Typescript compiler crash on redundant export
import { abc } from './redundant_export';
abc(1, 2, 3);
@dimfeld
dimfeld / ssh-with-mouse-fix
Last active February 6, 2018 01:57
run ssh and then disable mouse reporting
#!/bin/bash
# Run ssh and then disable mouse reporting. This is so that mouse scrolling
# will work properly in the local session if a tmux session drops.
/usr/bin/ssh "$@"
EXITCODE=$?
if tty -s; then
printf '\e[?1000l'
fi
@dimfeld
dimfeld / capnp-build.rs
Last active January 10, 2018 02:33
A build.rs script that filters out directives for building capnp files with non-Rust targets.
/*
Go's Cap'n Proto code generator needs some extra directives, but I don't want to require that
my Rust build environment has the relevant Go include files available. The script below filters
out the Go directives before sending the resulting files to the compiler to make this work.
*/
extern crate capnpc;
use std::env;
use std::path::PathBuf;
@dimfeld
dimfeld / jsonize.js
Created March 23, 2016 15:15
Convert JS-style objects into proper JSON
#!/usr/bin/env node
"use strict";
var fs = require("fs");
var vm = require("vm");
var sandbox = { value: null };
var context = vm.createContext(sandbox);
function convert(contents) {
vm.runInContext('value = ' + contents, context);
// DO NOT EDIT!
// Code generated by ffjson <https://github.com/pquerna/ffjson>
// DO NOT EDIT!
package main
import (
importedinceptionpackage "bitbucket.org/freshmedicalleads/datafuse/writer"
"bitbucket.org/freshmedicalleads/datafuse/vendor/github.com/pquerna/ffjson/inception"
// "github.com/pquerna/ffjson/inception"
@dimfeld
dimfeld / DirectOutputCommitter.scala
Created September 24, 2015 20:37 — forked from aarondav/DirectOutputCommitter.scala
DirectOutputCommitter.scala
/*
* Copyright 2015 Databricks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software

Keybase proof

I hereby claim:

  • I am dimfeld on github.
  • I am dimfeld (https://keybase.io/dimfeld) on keybase.
  • I have a public key whose fingerprint is 2814 2D19 F06B 2C7D 752B F055 4CC5 2454 DC43 1235

To claim this, I am signing this object:

@dimfeld
dimfeld / lip.py
Last active August 29, 2015 14:24
Linode IP Lookup
#!/usr/bin/python
import sys
import os
import os.path
import argparse
import json
import linode.api
key = None