This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _require_cache_ = {}; | |
function require(name) { | |
let local = FileManager.local(); | |
// look for script with the given name in iCloud documents | |
// and current directory adding .js to filename is not present | |
let resolve = function(name) { | |
var filename = name; | |
if(name.indexOf('.js') < 0) { | |
filename += '.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Promise.swift | |
// ShellFish | |
// | |
// Created by Anders Borum on 25/02/2019. | |
// Copyright © 2019 Anders Borum. All rights reserved. | |
// | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python2 | |
# coding: utf-8 | |
# | |
# This script is meant to be used from the Pythonista action extension when Safari is showing | |
# a GitHub Pull Request and will ask Working Copy to merge+pull the pull-request thus fullfulling it. | |
# You need to already have this repository cloned in Working Copy. | |
# | |
# It only works on public repositories, since the script lacks a way to authorize, but things | |
# happening in Working Copy can be fully authorized with either SSH Key or username / password. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// List all fonts on iPhone | |
for (NSString* family in [UIFont familyNames]) { | |
NSLog(@"Family name: %@", family); | |
for (NSString* name in [UIFont fontNamesForFamilyName: family]) { | |
NSLog(@" Font name: %@", name); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# include this from .bashrc, .zshrc or | |
# another shell startup file | |
# this script does nothing outside ShellFish | |
if [ "$LC_TERMINAL" = "ShellFish" ]; then | |
printURIComponent() { | |
awk 'BEGIN {while (y++ < 125) z[sprintf("%c", y)] = y | |
while (y = substr(ARGV[1], ++j, 1)) | |
q = y ~ /[a-zA-Z0-9]/ ? q y : q sprintf("%%%02X", z[y]) | |
printf("%s", q)}' "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"weather": { | |
"body": ["curl 'https://wttr.in/?0'\n"], | |
"description": "Weather from terminal" | |
}, | |
"external-ip": { | |
"body": ["dig @resolver4.opendns.com myip.opendns.com +short\n"], | |
"description": "Lookup external IP" | |
}, | |
"30-day-old-files": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Array where Element == UIImage { | |
func gifData(frameDelay: TimeInterval = 0.2) -> Data? { | |
let data = NSMutableData() | |
guard let destination = CGImageDestinationCreateWithData(data, kUTTypeGIF, self.count, nil) else { | |
return nil | |
} | |
let frameProperties: CFDictionary = [kCGImagePropertyGIFDictionary as String: [(kCGImagePropertyGIFDelayTime as String): frameDelay]] as CFDictionary | |
let fileProperties: CFDictionary = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: 0]] as CFDictionary | |
CGImageDestinationSetProperties(destination, fileProperties) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Keep polling the memory usage (through number of wired pages) every millisecond to discover if usage | |
// stays below some limit. | |
// | |
// let limit = MemoryGrowthLimit(megabytes: 5) | |
// hardWorkingMemoryConsumingMethodCall() | |
// XCTAssertFalse(limit.exceeded) | |
// | |
class MemoryGrowthLimit { | |
private let pollingInterval = 0.001 | |
NewerOlder