Skip to content

Instantly share code, notes, and snippets.

@masters3d
masters3d / json_storage.js
Created June 21, 2017 21:08 — forked from emanb29/json_storage.js
Getters and setters for localStorage allowing it to transparently store objects using es6's Proxy
/* json_storage.js
* @danott
* 26 APR 2011
*
* Building on a thread from Stack Overflow, override localStorage and sessionStorage's
* getter and setter functions to allow for storing objects and arrays.
*
* Original thread:
* http://stackoverflow.com/questions/2010892/storing-objects-in-html5-localstorage
*
@masters3d
masters3d / pggrep.swift
Created April 20, 2016 17:33 — forked from erica/pggrep.swift
Find files in playgrounds, which are otherwise not indexed by spotlight
//
// main.swift
// pggrep - updated 12/4/15
// Created by Erica Sadun on 6/17/15.
// Copyright © 2015 Erica Sadun. All rights reserved.
//
import Foundation
extension String {
@masters3d
masters3d / Queue.swift
Last active August 29, 2015 14:16 — forked from kareman/Queue.swift
//
// Queue.swift
// NTBSwift
//
// Created by Kåre Morstøl on 11/07/14.
//
// Using the "Two-Lock Concurrent Queue Algorithm" from http://www.cs.rochester.edu/research/synchronization/pseudocode/queues.html#tlq, without the locks.
// should be an inner class of Queue, but inner classes and generics crash the compiler, SourceKit (repeatedly) and occasionally XCode.
func fizzbuzz(i: Int) -> String {
let result = (i % 3, i % 5)
switch result {
case (0, _):
return "Fizz"
case (_, 0):
return "Buzz"
case (0, 0):
return "FizzBuzz"
default:
// Playground - noun: a place where people can play
import UIKit
// Setup the calendar object
let calendar = NSCalendar.currentCalendar()
// Set up date object
let date = NSDate()
// Public domain.
// Free to use.
// Use like this:
var world = "Hello, world!"
let convertedRange = world.convertRange(0..<5)
world.removeRange(convertedRange)
// Converts a regular range (0..5) to a proper String.Index range.
extension String {
#!/usr/bin/env python
#
# Extracts email addresses from one or more plain text files.
#
# Notes:
# - Does not save to file (pipe the output to a file if you want it saved).
# - Does not check for duplicates (which can easily be done in the terminal).
#
# (c) 2013 Dennis Ideler <ideler.dennis@gmail.com>
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=frame-nopass.pdf -c .setpdfwrite -f frame.pdf