Skip to content

Instantly share code, notes, and snippets.

@bkyle
bkyle / find-file-in-project.el
Created February 25, 2009 16:07
find-file-in-project
(defun find-file-in-project ()
(interactive)
(let (files filename)
(visit-tags-table-buffer)
(setq files (tags-table-files))
(setq filename (ido-completing-read "Find File: " files nil))
(find-file (concat (file-name-directory tags-file-name) filename))))
var array = ['a', 'b'];
for (var i=0; i<array.length; i++) {
print(array[i]);
}
// a
// b
for (var k in array) {
print(array[k]);
var array = ['a', 'b'];
array.hello = "world";
for (var i=0; i<array.length; i++) {
print(array[i]);
}
// a
// b
for (var k in array) {
@bkyle
bkyle / NSOutlineView-DMExtensions.h
Created January 17, 2010 05:24
Wil Shipley's NSOutlineView (DMExtensions)
// NSOutlineView-DMExtensions.h
// Library
//
// Created by William Shipley on 3/10/06.
// Copyright 2006 Delicious Monster Software, LLC. Some rights reserved,
// see Creative Commons license on wilshipley.com
#import <Cocoa/Cocoa.h>
@interface NSOutlineView (DMExtensions)
@bkyle
bkyle / NSArray+Globbing.h
Created February 3, 2010 20:02
NSArray+Globbing
#import <Foundation/Foundation.h>
@interface NSArray (Globbing)
+ (NSArray*) arrayWithFilesMatchingPattern: (NSString*) pattern inDirectory: (NSString*) directory;
@end
/* Localized versions of Info.plist keys */
@bkyle
bkyle / jd.py
Created February 27, 2021 01:27
Alfred Script Filter to list Johnny.Decimal index
from __future__ import print_function
import json
import os
import subprocess
import sys
def ls(wd):
"""Returns a list of directories under ``wd`` that match the johnny.decimal
pattern. The directories returned will be related to the passed working directory."""
pattern = "[1234567890][1234567890]-*/[1234567890][1234567890]\ */[1234567890][1234567890].[1234567890][1234567890]*"
@bkyle
bkyle / jd.sh
Last active February 28, 2021 16:02
Functions for the bash shell to support johnny.decimal indexes
JOHNNY_ROOT="..."
function jfind() {
(cd "${JOHNNY_ROOT}"; find [1234567890][1234567890]* $@)
}
function jls() {
(cd "${JOHNNY_ROOT}"; ls -1d [1234567890][1234567890]-*/[1234567890][1234567890]\ */[1234567890][1234567890].[1234567890][1234567890]*)
}
@bkyle
bkyle / docker-backup.sh
Created March 8, 2021 15:13
Backup the contents of docker images
container=""
bindings=$(docker inspect ${container} | jq -r '.[].HostConfig.Binds[]')
echo ${bindings} | while read bind; do
volume=${bind/:*/}
mount_point=${bind/*:/}
echo "docker run --volumes-from ${CONTAINER} -it --rm -v $(pwd)/backups:/backups busybox tar -czvf /backups/${volume}.tar.gz \"${mount_point}\""
done
@bkyle
bkyle / .dir-locals.el
Created March 20, 2021 23:00
.dir-locals.el for Obsidian Vaults
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((markdown-mode . ((visual-fill-column-width . 100)
(mode . visual-fill-column)
(mode . visual-line)
(markdown-hide-markup . nil)
(markdown-header-scaling . t)
(markdown-wiki-link-search-parent-directories . t)
(markdown-wiki-link-search-subdirectories . t)