Skip to content

Instantly share code, notes, and snippets.

Avatar

Eric O'Connell drd

View GitHub Profile
@drd
drd / BETA notice.md
Last active May 27, 2019 15:05
Hilights Beta
View BETA notice.md

Beta

You are invited to participate in the Hilights Beta. This means, at this point, you are one of three people, two of which are the developers of Hilights. Therefore, you know how to get in touch with us.

Privacy Policy

All information uploaded to the initial beta of Hilights is visible to the developers. We will know who you are, but we already do. <3

@drd
drd / a-tangled-miasma.md
Last active April 15, 2019 07:57
A tangled miasma of hacks that somehow manage to launch stetho
View a-tangled-miasma.md

So I got annoyed at always having to reconnect to Stetho, and I figured there would be some better way to do this in Android Studio ... and maybe there is, but this is the best I've gotten so far. Putting this together in a gist was inspired by a question on reddit: https://www.reddit.com/r/androiddev/comments/7hz3xy/stetho_anyone_know_of_a_convenient_way_to/

How does this work?

  • Use Android Studio custom Run configuration to call a new gradle task :app:launchStetho before the app launches
  • The gradle task uses launchctl (docs) to start an out-of-band AppleScript automation open-stetho.applescript
  • The AppleScript waits a few seconds, then controls Chrome to open chrome://inspect and loops until the "Inspect" action is available, and then executes a click() against that DOM element

Setup

  1. Choose a location for the applescript and ensure that it's executable `chmo
@drd
drd / transform.js
Created March 4, 2016 19:34
transform jsx with babel
View transform.js
const babel = require('babel-core');
const transformJsx = require('babel-plugin-transform-react-jsx');
const transformObjectRestSpread = require('babel-plugin-transform-object-rest-spread');
export function transformJsx(source) {
return babel.transform(source, { plugins: [transformJsx] });
}
@drd
drd / plugin.js
Last active September 23, 2015 17:43
Fun with builder
View plugin.js
const babel = require('babel');
const ast = require('./ast');
const extraction = require('./extraction');
const freeVariables = require('./free-variables');
module.exports = function({Plugin, types: t}) {
return new Plugin('transformation', {
visitor: {
@drd
drd / compiler.js
Created September 16, 2015 18:34
A caching babel compiler for require extensions, with optional preprocessor
View compiler.js
var babel = require('babel');
var extend = require('underscore').extend;
var path = require("path");
var os = require("os");
var fs = require("fs-ext");
var merge = require('lodash').merge;
View stuff-on-yr-gist.js
let isObject = o => toString.call(o) === '[object Object]'
let consume = i => {
let iterator = i && i.keys;
if (!iterator) return;
let arr = [];
while (res = iterator.next(), !res.isDone) arr.push(res.value);
return res;
}
@drd
drd / gist:cd591e52442a25bbb010
Created June 3, 2015 22:11
Coverage with babel/require
View gist:cd591e52442a25bbb010
--------------------------------|-----------|-----------|-----------|-----------|
File | % Stmts |% Branches | % Funcs | % Lines |
--------------------------------|-----------|-----------|-----------|-----------|
src/ | 80.32 | 71.93 | 70.42 | 80.95 |
FormController.js | 76.92 | 65 | 72.22 | 72.22 |
PageComponentLoader.jsx | 33.33 | 100 | 0 | 33.33 |
Router.jsx | 89.47 | 70 | 86.67 | 89.47 |
Wish.jsx | 66.67 | 92.31 | 50 | 65.91 |
World.jsx | 91.84 | 64.29 | 92.31 | 97.83 |
config.js | 100 | 100 | 100 | 100 |
@drd
drd / does-not-work
Created October 10, 2014 18:29
Help me figure out why the path of the bundle affects npm module resolution?
View does-not-work
# browserifying a bundle from the exact same working directory but where the
# target is elsewhere (the package i'm trying to build for release)
# fails to find the reactify module;
[eric@lxc000 app-ido-i3 (develop *)]$ bash -c "source develop; /Users/eric/work/app-ido-i3/front-end/blue-1/../../node_modules/.bin/browserify -t reactify /idealist/releases/permastatic-v0.0/resource/blue-1/js/abc.bundle.jsx"
Ready.
Error: Cannot find module 'reactify' from '/idealist/releases/permastatic-v0.0/resource/blue-1/js'
at /Users/eric/work/app-ido-i3/node_modules/browserify/node_modules/resolve/lib/async.js:50:17
at process (/Users/eric/work/app-ido-i3/node_modules/browserify/node_modules/resolve/lib/async.js:119:43)
at /Users/eric/work/app-ido-i3/node_modules/browserify/node_modules/resolve/lib/async.js:128:21
at load (/Users/eric/work/app-ido-i3/node_modules/browserify/node_modules/resolve/lib/async.js:60:43)
@drd
drd / fail.swift
Created September 1, 2014 06:09
where is the bug?
View fail.swift
func testOMGWTF() {
var err: NSError?
let plist = [
"a": "c",
// note that 1 is a String
"b": "1"
]
let data = NSPropertyListSerialization.dataWithPropertyList(
plist,
format: NSPropertyListFormat.BinaryFormat_v1_0,
View gist:e6548a57a44620634165
struct ControlGrid {
var buttons : Dictionary<String, NSButton>
let mapping = [
"e": (1, 0.5),
"se": (1, 1),
"s": (0.5, 1),
"sw": (0, 1),
"w": (0, 0.5),
"nw": (0, 0),