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 SelectorWrapper<T> { | |
let selector: Selector | |
let closure: (T) -> Void | |
init(withClosure closure: @escaping (T) -> Void) { | |
self.selector = #selector(callClosure) | |
self.closure = closure | |
} | |
@objc |
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
$.fn.touchHover = function() { | |
return 'ontouchstart' in document.documentElement ? this.click(function() { | |
$(this).toggleClass('hover'); | |
}) : this; | |
}; | |
/* | |
Example: $('.button').touchHover(); | |
You also need to add .hover to your :hover CSS rules: | |
.button:hover -> .button:hover, .button.hover | |
*/ |
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
#!/bin/bash | |
# Created by Sindre Sorhus | |
# Magically retrieves a GitHub users email even though it's not publicly shown | |
[ "$1" = "" ] && echo "usage: $0 <GitHub username> [<repo>]" && exit 1 | |
[ "$2" = "" ] && repo=`curl "https://api.github.com/users/$1/repos?type=owner&sort=updated" -s | sed -En 's|"name": "(.+)",|\1|p' | tr -d ' ' | head -n 1` || repo=$2 | |
curl "https://api.github.com/repos/$1/$repo/commits" -s | sed -En 's|"(email\|name)": "(.+)",?|\2|p' | tr -s ' ' | paste - - | sort -u -k 1,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
/// Types that can be initialized without any parameters. | |
/// Useful if you need to accept an array of metatypes and then initialize them. | |
protocol EmptyInitializable { | |
init() | |
} | |
extension Int: EmptyInitializable {} | |
extension Int8: EmptyInitializable {} | |
extension Int16: EmptyInitializable {} | |
extension Int32: EmptyInitializable {} |
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 | |
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *) | |
@propertyWrapper | |
public struct Model<Value>: DynamicProperty { | |
private final class _Box: ObservableObject { | |
let objectWillChange = ObservableObjectPublisher() | |
var value: Value { |
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
{ | |
"name": "__name__", | |
"version": "0.0.0", | |
"description": "", | |
"license": "MIT", | |
"repository": "sindresorhus/__name__", | |
"author": { | |
"name": "Sindre Sorhus", | |
"email": "sindresorhus@gmail.com", | |
"url": "http://sindresorhus.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
enum AssociationPolicy { | |
case assign | |
case retainNonatomic | |
case copyNonatomic | |
case retain | |
case copy | |
var rawValue: objc_AssociationPolicy { | |
switch self { | |
case .assign: |
##Simply annoying Tweets
Annoyingly extended words (4+ of the same letter in a phrase): OOOOHHHHMMMMYYYYGGGGOOOODDDD
([a-z])/1{4}
Tweet w/ just a single hashtag: #omgthissucks
^ *#[^ ]+$