Skip to content

Instantly share code, notes, and snippets.

@tj
tj / remap.sh
Created March 4, 2020 13:31
Remap tilde and left shift on a UK keyboard
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x7000000E1}, {"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035}]}'
cat << 'EOF' > ~/.keymappings && chmod +x ~/.keymappings
hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x7000000E1}, {"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035}]}'
EOF
sudo /usr/bin/env bash -c "cat > /Library/LaunchDaemons/org.custom.keymappings.plist" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@tj
tj / Connector.js
Last active November 26, 2019 15:43
import React from 'react'
const bgStyles = {
strokeWidth: 3,
strokeLinejoin: 'round',
strokeLinecap: 'round',
fill: 'none',
stroke: '#c3fdff'
}
@tj
tj / batch.js
Created December 6, 2011 04:43
/**
* Expose `Batch`.
*/
module.exports = Batch;
/**
* Create a new Batch.
*/
@tj
tj / rgba.c
Created November 5, 2010 16:08
#include <stdio.h>
#include <stdint.h>
#include <string.h>
/*
* Consume whitespace.
*/
#define WHITESPACE \
// grab time spent
sum := Agg("duration_sum", Sum("duration"))
// grab time spent per label
labels := Agg("labels",
Terms("issue.labels.keyword", 100),
Aggs(sum))
// grab time spent per day, and per label
@tj
tj / css.js
Created August 28, 2011 23:05
/**
* Module dependencies.
*/
var fs = require('fs');
var css = fs.readFileSync('style.css', 'utf8');
function scan(buf) {
@tj
tj / bind.js
Created December 17, 2010 17:34
function FunctionBind(this_arg) { // Length is 1.
if (!IS_FUNCTION(this)) {
throw new $TypeError('Bind must be called on a function');
}
// this_arg is not an argument that should be bound.
var argc_bound = (%_ArgumentsLength() || 1) - 1;
if (argc_bound > 0) {
var bound_args = new $Array(argc_bound);
for(var i = 0; i < argc_bound; i++) {
bound_args[i] = %_Arguments(i+1);
@tj
tj / foo.js
Created October 6, 2010 17:14
function InstantiateFunction(data, name) {
// We need a reference to kApiFunctionCache in the stack frame
// if we need to bail out from a stack overflow.
var cache = kApiFunctionCache;
var serialNumber = %GetTemplateField(data, kApiSerialNumberOffset);
var isFunctionCached =
(serialNumber in cache) && (cache[serialNumber] != kUninitialized);
if (!isFunctionCached) {
try {
cache[serialNumber] = null;
obj = {
a : function(){
print('im a')
},
b : function(){
var self = this
print('im b')
function c(){
self.a()
@tj
tj / client.go
Last active October 30, 2018 13:08
package main
import "github.com/segmentio/rpc"
import "fmt"
type Args struct {
A int
B int
}