Skip to content

Instantly share code, notes, and snippets.

View ApoorvKhatreja's full-sized avatar

Apoorv Khatreja ApoorvKhatreja

  • Splitwise
  • Providence, RI
View GitHub Profile
@ApoorvKhatreja
ApoorvKhatreja / np.scpt
Created November 28, 2012 16:23
Now Playing script for Textual that works for both online radio streams and music library.
on textualcmd()
set nowPlaying to "I'm not currently playing anything."
# iTunes
if isRunning("iTunes") then
tell application "iTunes"
if player state is playing then
if current stream title is not missing value then
set nowPlaying to "/me is currently listening to '" & current stream title & "' on " & name of current track & "."
@ApoorvKhatreja
ApoorvKhatreja / JSONValue.swift
Last active December 22, 2022 19:26
A Swift enum that represents a valid JSON value, that is equatable and supports implicit type conversion. Instead of parsing to [String: Any], parse to [String: JSONValue], and enjoy type safety.
enum JSONValue: Equatable,
ExpressibleByStringLiteral,
ExpressibleByFloatLiteral,
ExpressibleByIntegerLiteral,
ExpressibleByDictionaryLiteral,
ExpressibleByArrayLiteral,
ExpressibleByBooleanLiteral,
ExpressibleByNilLiteral,
RawRepresentable {
typealias RawValue = Any