Skip to content

Instantly share code, notes, and snippets.

View dt's full-sized avatar

David Taylor dt

View GitHub Profile
import sublime, sublime_plugin
CLASSES = sublime.CLASS_WORD_START | sublime.CLASS_PUNCTUATION_START | sublime.CLASS_LINE_END
class ScalaAddImportLine(sublime_plugin.TextCommand):
def run(self, edit, sym):
end_of_imports = self.view.find_all('import .*\n\n')
if len(end_of_imports) != 1:
raise ValueError('where do i put this import?!')
else:
#!/bin/bash
set -e
if [ ! -d .pvenvs/onchange ]; then
mkdir -p .pvenvs
python2.7 -m virtualenv --quiet .pvenvs/onchange
if [ $(uname) = 'Darwin' ]; then
.pvenvs/onchange/bin/pip install --quiet MacFSEvents
else
@dt
dt / client.nut
Last active November 23, 2020 19:43
Coffee Monitor Imp
light <- hardware.pin8;
light.configure(ANALOG_IN);
was_brewing <- false;
brew_light <- 45000;
poll_time <- 30;
skip_updates <- 10;
until_heartbeat <- 0;
@dt
dt / python_repl.py
Created January 14, 2015 18:23
virtual env based pants py replacement
# coding=utf-8
# Copyright 2013 Foursquare Labs Inc. All Rights Reserved.
from __future__ import absolute_import
import os
import subprocess
from pants.backend.core.tasks.task import Task
from pants.backend.python.targets.python_binary import PythonBinary
@dt
dt / gist:1e55ab109f865d445823
Last active August 29, 2015 14:11
product product_type hack
class ProductiveJUnitRun(JUnitRun):
@classmethod
def product_types(cls):
return ['junit_tests_ran']
task(name='junit',
action=ProductiveJUnitRun,
dependencies=['bootstrap', 'compile']).install('test', replace=True).with_description('Test compiled code.')
@dt
dt / agent.nut
Created December 5, 2014 06:31
#coffeebot server
brew_light <- 55000;
brewing <- false;
slack_url <- "https://hooks.slack.com/services/BLAHBLAHBLAH";
function slack(msg) {
local body = "{\"text\": \""+msg+"\", \"username\": \"Coffeebot\", \"icon_emoji\": \":coffee:\"}";
local request = http.post(slack_url, {}, body);
local resp = request.sendsync();
server.log("Slack says ("+resp.statuscode + "): " + resp.body)
}
@dt
dt / gist:ba4dd0ce404fb83a49be
Created December 5, 2014 06:30
#coffeebot device
light <- hardware.pin8;
light.configure(ANALOG_IN);
function check() {
agent.send("lvl", light.read());
imp.wakeup(10, check);
}
check();
# def slow_identity_func(i):
# import time
# time.sleep(i[0])
# return i[1]
# def test_multiproc_map_timeout(self):
# context = create_context()
# msg = 'subproc_map result still not ready...'
# counting_log = MockLogger(count_messages_matching=set([msg]))
# context._log = counting_log
@dt
dt / gist:1cc0151bb3978eae1d25
Created October 31, 2014 05:32
10/31 ads build
[05:29] ~/code/fs/2 $ rm -rf .pants.d .local_artifact_cache/[^I]*
[05:29] ~/code/fs/2 $ time ./fs --pants-binary=../../pants/dist/pants.pex compile ads-api
Writing log files to disk in /tmp/davidt/goals
Begin: 2014-10-31 05:29:56.130135
Running: ../../pants/dist/pants.pex goal compile --compile-scala-missing-deps=fatal src/jvm/com/foursquare/ads/server/bin:foursquare.ads
Writing log files to disk in /tmp/davidt/goals
05:29:57 00:00 [main]
(To run a reporting server: ./pants goal server)
05:29:58 00:01 [bootstrap]
@dt
dt / tag.py
Last active August 29, 2015 14:06
BUILD graph rules
# Copyright 2014 Foursquare Labs Inc. All Rights Reserved.
from pants.backend.core.tasks.task import Task
class Tagger(Task):
@classmethod
def product_types(cls):
return ['tagged_build_graph']
def execute(self):