Author: Chris Lattner
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
// | |
// Device.swift | |
// imHome | |
// | |
// Created by Kevin Xu on 2/9/15. Updated on 6/20/15. | |
// Copyright (c) 2015 Alpha Labs, Inc. 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
[ | |
{ | |
"timezones": [ | |
"America/Aruba" | |
], | |
"latlng": [ | |
12.5, | |
-69.96666666 | |
], | |
"name": "Aruba", |
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
func partial<A, B, T>(f: (A, B) -> T, a: A) -> (B) -> T { | |
return { f(a, $0) } | |
} | |
func bind2nd<A, B, T>(f: (A, B) -> T, b: B) -> (A) -> T { | |
return { f($0, b) } | |
} | |
func partial<A, B, C, T>(f: (A, B, C) -> T, a: A) -> (B, C) -> T { |
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
#Stack Overflow scraper script | |
#imports necessary modules | |
from urllib2 import urlopen | |
from BeautifulSoup import BeautifulSoup | |
import time | |
username = raw_input("Username: ") |
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
// How to use: | |
// 1. Open "Script Editor" (requires OS X 10.10 Yosemite) | |
// 2. Change the language from "AppleScript" to "JavaScript" | |
// 3. Paste the code below and replace the safari example. | |
// | |
// More info: | |
// https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/index.html | |
var sys_events = Application("System Events"); |
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
import UIKit | |
#if canImport(SwiftUI) && DEBUG | |
import SwiftUI | |
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable { | |
let viewController: ViewController | |
init(_ builder: @escaping () -> ViewController) { | |
viewController = builder() | |
} |
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
// See commentary below this gist. | |
import Foundation | |
import QuartzCore | |
// Implementation from https://talk.objc.io/episodes/S01E90-concurrent-map | |
public final class ThreadSafe<A> { | |
var _value: A | |
let queue = DispatchQueue(label: "ThreadSafe") | |
init(_ value: A) { self._value = value } |
- Author: Michel Fortin
This proposal introduces the concept of pure functions to Swift. A pure function is guarantied to allow only value semantics, even when dealing with classes.
I had fun building my own LISP (Slow Loris). The project was extremely easy to get off the ground, because there a ton of resources to do just this. I thought it might be handy to have a little links round-up, based on my research.
There are already several good projects out there on writing your own LISP in Python.
OlderNewer