Skip to content

Instantly share code, notes, and snippets.

Avatar

Jason Milkins jasonm23

View GitHub Profile
View NSScreen+currentScreenForMouseLocation.swift
//
// NSScreen+currentScreenForMouseLocation.swift
// CutBox
//
import Cocoa
extension NSScreen {
static func currentScreenForMouseLocation() -> NSScreen? {
let mouseLocation = NSEvent.mouseLocation
View .CutBox_BitBar.md

CutBox - BitBar

CutBox developer bitbar

@jasonm23
jasonm23 / ec
Last active Nov 29, 2018
shell function for Mac to open file(s) in emacs via Emacsclient or start a new Emacs app.
View ec
ec() {
emacsclient -n $@ 2> /dev/null
if [[ $? == 1 ]]; then
open -a Emacs.app -- $@
fi
}
@jasonm23
jasonm23 / String+Localized.swift
Last active Apr 3, 2018
String+Localized.swift
View String+Localized.swift
import Foundation
extension String {
var localized : String {
set {}
get {
guard let localizedString = NSLocalizedString(self, comment: "") else {
fatalError("\(self) - not available as localized")
}
return NSLocalizedString(self, comment: "")
View NSColor+RGB_A.swift
import Cocoa
// Bitshifting example
// (NOTE: Don't use, use color literals and shared palettes in a real project.)
extension NSColor {
// NSColor(rgb: 0xFFFFFF, a: 1.0) == NSColor.white
convenience init(rgb: Int, a: CGFloat) {
let r = (rgb >> 0b11000) & 0b11111111
let g = (rgb >> 0b10000) & 0b11111111
View get-nested.el
;;; get-nested --- Fetch nodes from nested structures made by json.el
;;; Version: 0.1.0
;;; Author: Jason Milkins jasonm23@gmail.com
;;
;;; Commentary:
;;
;; The alist/vector payload generated by json.el is very
;; handy, but Emacs Lisp doesn't (afaik?!) have nice ways to drill
;; down and cherry pick specific values from the tree.
;;
@jasonm23
jasonm23 / oxford-dict-complex.json
Created Nov 26, 2017
JSON response for the word 'complex'
View oxford-dict-complex.json
{
"metadata": {
"provider": "Oxford University Press"
},
"results": [
{
"id": "complex",
"language": "en",
"lexicalEntries": [
{
@jasonm23
jasonm23 / git-whitespace-cleanup
Last active Oct 13, 2017
Scrub trailing whitespace from your changed files under git
View git-whitespace-cleanup
#!/bin/sh
git status -s | cut -c3- | while read filename
do
sed -ibak 's/ *$//' "$filename"
done
echo "trailing whitespace cleaned"
git clean -fd **/*bak
View theme.css
.console-output {
font-family: menlo, monospaced;
padding: 1.5em;
background-color: black;
color: white;
}
.console-output a:link {
color: #b088ff;
}
View gist:9ba2af14927c6684c492ea69acf8a31c
// update LED
if (led_status != host_keyboard_leds()) {
led_status = host_keyboard_leds();
keyboard_set_leds(led_status);
}