Skip to content

Instantly share code, notes, and snippets.

Avatar

Carlos Johnson callemo

View GitHub Profile
@callemo
callemo / Makefile
Last active Mar 29, 2020
Makefile for java projects
View Makefile
artifactId = a
directory = build
outputDirectory = $(directory)/classes/java/main
sourceDirectory = src/main/java
sources = $(shell find $(sourceDirectory) -name \*.java)
objects = $(sources:$(sourceDirectory)/%.java=$(outputDirectory)/%.class)
package = $(directory)/libs/$(artifactId).jar
JAR = jar
JAR_FLAGS = cvf
@callemo
callemo / .tmux.conf
Last active Mar 28, 2020
Simple vim and tmux configuration
View .tmux.conf
set-option -g prefix C-a
bind-key C-a send-prefix
set-option -g default-terminal "screen-256color"
set-option -g escape-time 50
set-option -g focus-events on
set-option -g history-limit 10000
set-option -g mouse on
set-option -g status-bg default
set-option -g status-fg default
View trie.js
/* trie.js */
class TrieNode {
constructor(value) {
this.value = value;
this.children = new Map();
this.isEndOfWord = false;
}
}
View acmestart.sh
#!/bin/bash
#
# Using it with the Go fonts
# git clone https://go.googlesource.com/image
# sudo bash -c 'cp image/font/gofont/ttfs /usr/share/fonts/truetype/go && fc-cache -f -v'
# acmestart -f /mnt/font/GoRegular/11a/font -F /mnt/font/GoMono/11a/font
#
set -e
@callemo
callemo / install-userkeymap.sh
Last active Oct 13, 2019
Remapping Keys in macOS
View install-userkeymap.sh
#!/bin/bash
# Remapping Keys in macOS
# https://developer.apple.com/library/archive/technotes/tn2450/_index.html
set -e
userscript="$HOME/bin/userkeymap"
mkdir -p "$HOME"/bin
cat <<EOF > "$userscript"
#!/bin/bash
hidutil property --set '{"UserKeyMapping": [
{"HIDKeyboardModifierMappingSrc": 0x700000064, "HIDKeyboardModifierMappingDst": 0x700000035}
@callemo
callemo / Dockerfile
Created Feb 1, 2019
Cling environment
View Dockerfile
FROM debian:buster
ENV SHELL=/bin/bash
RUN apt-get update -y && apt-get install -y \
bash-completion \
build-essential \
cmake \
ctags \
curl \
git \
git-extras \
@callemo
callemo / kindle-clean.py
Created Jan 26, 2019
Clean up orphaned "sdr" directories from a Kindle
View kindle-clean.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import collections
import os
import shutil
parser = argparse.ArgumentParser()
parser.add_argument("dirpath")
@callemo
callemo / collection.sql
Last active Jul 11, 2018
Unstructured key-value storage for MySQL
View collection.sql
CREATE TABLE IF NOT EXISTS `collection` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`uuid` BINARY(16) NOT NULL,
`value` MEDIUMBLOB NOT NULL,
`version` BIGINT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'optimistic updates',
`format` ENUM ('R', 'J', 'M') NOT NULL DEFAULT 'J' COMMENT 'R: raw, J: json, M: msgpack',
`compression` ENUM ('N', 'Z') NOT NULL DEFAULT 'N' COMMENT 'N: none, Z: gzip',
`deleted_at` DATETIME NULL DEFAULT NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
@callemo
callemo / escapeHTML.js
Created Jul 5, 2018
Escape HTML text. Distilled from `handlebars/utils.js`.
View escapeHTML.js
const entity = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#x27;",
"`": "&#x60;",
"=": "&#x3D;"
};
@callemo
callemo / htag.js
Last active Jul 5, 2018
htag.js – A Bare bones interpretation of the Hyperscript syntax.
View htag.js
/*
htag.js
A Bare bones interpretation of the Hyperscript syntax.
*/
var h = function h(tag, attributes, ...children) {
const node = document.createElement(tag);
attributes = attributes || {};
Object.keys(attributes).forEach(attr => {
if (attr === "style" || attr === "dataset") {
const value = attributes[attr];