Skip to content

Instantly share code, notes, and snippets.

@huyz
huyz / less.vim
Created July 3, 2011 07:51
less.vim debugging
" Vim script to work like "less"
" huyz 2011-07-03 Modified for better quit handling. See 'm' script.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2006 Dec 05
" Avoid loading this file twice, allow the user to define his own script.
if exists("loaded_less")
finish
endif
@huyz
huyz / wp-syntax.css
Created July 4, 2011 08:59
wp-syntax.css for Twenty-Ten WP theme
#content .wp_syntax {
color: #100;
background-color: #f9f9f9;
border: 1px solid silver;
margin: 0 0 1.5em 0;
overflow: auto;
}
/* IE FIX */
#content .wp_syntax {
@huyz
huyz / main_decompiled.js
Created September 6, 2011 12:32
Google+ Translate extension main.js decompiled
/* Copyright 2011 Google */
(function() {
var injectionScript = fillInTemplate("(function(){({{$code}})();})();", {
code: window.injection.toString()
}),
injectorScript = fillInTemplate("(function(){({{$code}})();})();", {
code: window.injector.toString()
});
delete window.injector;
delete window.injection;
#!/usr/bin/env ruby -E utf-8
# merge_asana_into_omnifocus.rb
# Hilton Lipschitz
# http://www.hiltmon.com
# Use and modify freely, attribution appreciated
# Script to import Asana projects and their tasks into
# OmniFocus and keep them up to date from Asana.
@huyz
huyz / keybase.md
Created September 25, 2017 05:41
Keybase proof

Keybase proof

I hereby claim:

  • I am huyz on github.
  • I am huyz (https://keybase.io/huyz) on keybase.
  • I have a public key ASCgkbXDeXXUtEJVuhp0RQHxFxkm7IDZR633ZjEZYvEVxwo

To claim this, I am signing this object:

@huyz
huyz / cardinalConstraints.js
Last active June 29, 2019 07:39
Uber interview question: cardinal constraints
// Problem description: https://interviewcache.com/blog/direction-validation/
function areCardinalConstraintsValid(rules) {
console.log(rules);
console.log(_areCardinalConstraintsValid(rules));
console.log();
}
function _areCardinalConstraintsValid(rules) {
// We choose N-S and E-W instead of S-N and W-E because of the English idioms "north to south" and "east to west",
@huyz
huyz / buildresticexcludes.sh
Last active March 6, 2022 03:43 — forked from Vartkat/buildresticexcludes.sh
Bash script to build a restic exclude list that mimics Apple TimeMachine exclude list
#!/bin/bash
# This script intend to mimic TimeMachine exclude list.
# As the exclude list can evolve between backups it has to be rebuilt before every backup
# Apple uses 5 types of excludes:
# - 4 `/System/Library/CoreServices/backupd.bundle/Contents/Resources/StdExclusions.plist`
# - and files from applications where metadata says to not backup, these can be found usinr
# `sudo mdfind "com_apple_backup_excludeItem = 'com.apple.backupd'"`
PLISTBUDDY=/usr/libexec/PlistBuddy
@huyz
huyz / sort-thunderbird-identities.py
Created November 23, 2022 08:10
Sort Thunderbird/Postbox identities
#!/usr/bin/env python
# For a given Thunderbird/Postbox account, this sorts the identities by email address.
# Only supports macOS (specific to macOS pgrep) right now, but could be easily tweaked for Linux.
# Prerequisites: pgrep, difft (difftastic)
from operator import itemgetter
from os import environ
from sys import platform, stderr
from typing import Dict
import re
@huyz
huyz / fix-signal-export-format1.pl
Last active March 13, 2024 14:50
Fix the Markdown in the old format v1 of signal-export
#!/usr/bin/env perl -w
# 2024-03-12 huy
# Retractively fixes past chats to confirm with current version of signal-export.
# This is important because signal-export detects duplicates only if the messages match exactly,
# and the format changes have created duplicates that aren't exactly the same
# and thus can't be automatically removed.
# Note this script cleans up entries so that the next run of export-signal should detect duplicates but
# this script doesn't itself remove duplicates.
#
# Details: