Skip to content

Instantly share code, notes, and snippets.

@pmbuko
pmbuko / syspref_handler.applescript
Created October 18, 2013 16:59
An applescript url handler that opens System Preference panes passed to it. (http://yourmacguy.wordpress.com/2013/07/17/make-your-own-url-handler/)
on open location this_URL
-- passed urls should be "syspref://[PaneName]
-- or "syspref://[Pane_Name]" -- no spaces
set x to the offset of ":" in this_URL
set sp to text from (x + 3) to -1 of this_URL
set pane to do shell script "echo \"" & sp & "\" | awk '{gsub(\"_\",\"\\\\ \"); print}'"
set h to path to home folder
set home to POSIX path of h
set path_heads to {"/System/", "/", home}
set pref_pane to text from (x + 3) to -1 of this_URL
@pmbuko
pmbuko / finder-file-handler.applescript
Last active August 3, 2018 07:56
Use this code in an Applescript to create a file handler that will allow you to click on urls of the form "finder://~/Dropbox/Project/Documents" to open that location in the Finder.
on open location this_URL
-- passed paths should be "finder://[/path/to/directory]
-- spaces in path names should be replaced with a url-friendly '%20'
set x to the offset of ":" in this_URL
set passed_path to text from (x + 3) to -1 of this_URL
set my_path to do shell script "echo \"" & passed_path & "\" | awk '{gsub(\"%20\",\"\\\\ \"); print}'"
do shell script "open " & my_path
end open location
@0xWDG
0xWDG / SHA1.swift
Last active December 1, 2019 00:51
SHA1 for Swift
//
// SHA1.swift
// Based on:
// https://raw.github.com/kvz/phpjs/master/functions/strings/sha1.js
import Foundation
extension String {
func charCodeAt(Char: Int) -> Int {
@fnky
fnky / ANSI.md
Last active July 26, 2024 02:14
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27