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 Combine | |
import SwiftUI | |
import UIKit | |
struct RemoteImage: View { | |
let url: URL | |
var placeholder: AnyView? | |
@StateObject var fetcher = RemoteImageFetcher() |
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
# Allows me to call Enum.map as a "pre-curried" func, kind of... | |
[1, 2, 3] | |
|> Enum.map(& &1 * 2) | |
# vs... | |
def my_map(list) do | |
fn transform -> | |
Enum.map(list, transform) | |
end |
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 String { | |
func javaScriptEscapedString() -> String { | |
// Because JSON is not a subset of JavaScript, the LINE_SEPARATOR and PARAGRAPH_SEPARATOR unicode | |
// characters embedded in (valid) JSON will cause the webview's JavaScript parser to error. So we | |
// must encode them first. See here: http://timelessrepo.com/json-isnt-a-javascript-subset | |
// Also here: http://media.giphy.com/media/wloGlwOXKijy8/giphy.gif | |
let str = self | |
.stringByReplacingOccurrencesOfString("\u{2028}", withString: "\\u2028") | |
.stringByReplacingOccurrencesOfString("\u{2029}", withString: "\\u2029") | |
// Because escaping JavaScript is a non-trivial task (https://github.com/johnezang/JSONKit/blob/master/JSONKit.m#L1423) |
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
class Locks { | |
private var queuedDocuments = [String:Document]() | |
private var inFlightDocuments = [String:Document]() | |
private let queuedQueue = dispatch_queue_create("com.lucidchart.DocumentStateStoreLocks.queued", DISPATCH_QUEUE_SERIAL) | |
private let inFlightQueue = dispatch_queue_create("com.lucidchart.DocumentStateStoreLocks.inFlight", DISPATCH_QUEUE_SERIAL) | |
func queued(block: [String:Document] -> [String:Document]) { | |
dispatch_sync(queuedQueue) { | |
self.queuedDocuments = block(self.queuedDocuments) |
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 | |
let userJSON = [ | |
"url": "https://example.com/users/123", | |
"name": "Jim", | |
"profile_url": "https://example.com/users/123/profile", | |
"posts_url": "https://example.com/users/123/posts" | |
] | |
// API resources, such as User, Profile, Post, etc. |
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
<a href="javascript:toggleChatWindow()">Chat With Us!</a> | |
<script> | |
function toggleChatWindow() { | |
if (FHChat.chatState == "minimized") { | |
FHChat.transitionTo("maximized"); | |
document.getElementById("fchat-message").focus(); | |
} else { | |
FHChat.transitionTo("minimized"); | |
} |
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
<a href="javascript:popOpenChatWindow()">Chat With Us!</a> | |
<script> | |
function popOpenChatWindow() { | |
FHChat.transitionTo("maximized"); | |
document.getElementById("fchat-message").focus(); | |
}; | |
</script> |
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
// Example Goal: find URLs embedded in arbitrary JSON | |
NSDictionary *JSON = @{ | |
@"some": @[ | |
@"arbitrary": @[ | |
@"json", | |
@"http://google.com", | |
@{ @"url": @"http://yahoo.com" } | |
] | |
] |
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
# post.rb | |
class Post | |
has_many :tags, :through => :post_tags | |
has_many :post_tags | |
end | |
# tag.rb | |
class Tag | |
has_many :posts, :through => :post_tags | |
has_many :post_tags |
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
(ns letterpress-solver.core | |
(:require [clojure.string :as string]) | |
(:require [multiset.core :as ms])) | |
(def board-letters "srrbtsdofaghvypksbkkbegnv") | |
(def letterpress-wordlist (string/split-lines (slurp "resources/wordlist.txt"))) | |
(defn -main [& args] | |
(println "Began...") |
NewerOlder