Most popular words on Headline Smasher
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 ExiftoolPatched < MiniExiftool | |
def initialize_from_hash hash | |
@@separator = ', ' | |
super | |
end | |
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
public Color GetInterpolatedPixel(float x, float y, float z) { | |
x = Mathf.Clamp(x, 0, size - 1); | |
y = Mathf.Clamp(y, 0, size - 1); | |
z = Mathf.Clamp(z, 0, size - 1); | |
int lowerX = Mathf.Clamp(Mathf.FloorToInt(x), 0, size - 1); | |
int upperX = Mathf.Clamp(lowerX + 1, 0, size - 1); | |
int lowerY = Mathf.Clamp(Mathf.FloorToInt(y), 0, size - 1); | |
int upperY = Mathf.Clamp(lowerY + 1, 0, size - 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
const React = require('react'); | |
const ReactDOM = require ('react-dom'); | |
const Render = require('react-emoji-render'); | |
// try swapping the commented lines below and hit "Run Code" in the top right | |
// to see another rendering style! | |
const Emoji = Render.Emojione; | |
//const Emoji = Render.Twemoji; |
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
// ESON is like JSON. | |
// ESON files should use the `.eson` file extension and the `application/eson` MIME type. | |
// This is meant to be as close to JSON as possible (and backwards compatible), but having learned a few lessons. | |
{ | |
// It's backwards compatible with JSON. | |
"key": "value", | |
// Obviously, the big feature is it supports comments: |
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
/// `asyncMap` helps you with error propagation for asynchronous tasks. | |
/// - Parameters: | |
/// - onFailure: A closure that will be called in an error condition if in an error state. | |
/// - onSuccess: A closure that will be called with your success value if succesful. | |
/// - Returns: A closure that will call `onError` if it is passed a failing result, and that will execute `onSuccess` if it is successful. | |
func asyncMap<Success, NeverSuccess, Error: Swift.Error>( | |
_ onFailure: @escaping ((Result<NeverSuccess, Error>) -> Void), | |
_ onSuccess: @escaping (Success) -> Void | |
) -> ((Result<Success, Error>) -> Void) { | |
return { result in |
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 Task where Success == Void, Failure == Error { | |
@discardableResult | |
/// A task that performs a non-throwing `operation`. | |
static func strict<S>(priority: TaskPriority? = nil, operation: @escaping @Sendable () async -> S) -> Self { | |
Task(priority: priority, operation: { | |
_ = await operation() | |
}) | |
} | |
} |
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
using System.Collections.Generic; | |
using System.Linq; | |
using UnityEngine; | |
#nullable enable | |
public static class ShuffleExtensions { | |
// Returns a random element from the list. | |
public static T? RandomElement<T>(this IList<T> list) { | |
if (list.Count == 0) { |
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
{ | |
"FormattingOptions": { | |
"NewLine": "\n", | |
"IndentationSize": 4, | |
"NewLinesForBracesInMethods": false, | |
"NewLinesForBracesInAccessors": false, | |
"NewLinesForBracesInAnonymousMethods": false, | |
"NewLinesForBracesInAnonymousTypes": false, | |
"NewLinesForBracesInControlBlocks": false, | |
"NewLinesForBracesInLambdaExpressionBody": false, |
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 Foundation | |
// https://gist.github.com/DougGregor/92a2e4f6e11f6d733fb5065e9d1c880f | |
extension Collection { | |
func parallelMap<T>( | |
parallelism requestedParallelism: Int? = nil, | |
_ transform: @escaping (Element) async throws -> T | |
) async rethrows -> [T] { | |
let defaultParallelism = 2 | |
let parallelism = requestedParallelism ?? defaultParallelism |
OlderNewer