Skip to content

Instantly share code, notes, and snippets.

View dougbeal's full-sized avatar

Douglas Beal dougbeal

View GitHub Profile
@gfontenot
gfontenot / decodeDict.swift
Created February 19, 2015 15:38
example of decoding dictionary objects with Argo/FP
import Argo
import Runes
func +<T, V>(lhs: [T: V], rhs: [T: V]) -> [T: V] {
var dict = lhs
for (key, val) in rhs {
dict[key] = val
}
return dict
let view = ...
for case let label as UILabel in view.subviews {
...
}
@irace
irace / Optional+Empty.swift
Last active June 16, 2016 16:17
`UITextView` should really just have this by default.
protocol TextContaining {
var isEmpty: Bool { get }
}
extension String: TextContaining {
}
extension Optional where Wrapped: TextContaining {
var isEmpty: Bool {
switch self {
@lucholaf
lucholaf / gist:e37f4d26e406250a156a
Last active September 5, 2016 15:06
Xcode pre-action: generate Swift FAT file to reduce compilation time, since it's faster to recompile the whole source code in a single file
> $PROJECT_DIR/merge.swift; find $PROJECT_DIR/ -iname *.swift -not -name merge.swift -exec cat {} >> $PROJECT_DIR/merge.swift \;
/* Tweaks to post kinds */
#kind-all .svg-icon {
fill: currentColor;
padding-left: 2px;
padding-right: 2px;
width: 48px;
height: 48px;
vertical-align: middle;
top: -0.0625em;
color: grey;
<?php
/*
Default Template
* The Goal of this Template is to be a general all-purpose model that will be replaced by customization in other templates
*/
$kind = get_post_kind_slug( get_the_ID() );
$meta = new Kind_Meta( get_the_ID() );
$author = Kind_View::get_hcard( $meta->get_author() );
$cite = $meta->get_cite();
@miklb
miklb / Frankenstein.php
Last active May 19, 2017 06:01
facepiles for WP comments
/**
* Override core Walker_Comment for mf2 & Bulma.
*
* @method __construct
*/
class Independence_Walker_Comment extends Walker_Comment {
/**
* Start the element output.
*
* This opens the comment. Will check if the comment has children or is a stand-alone comment.
@miklb
miklb / UnspamWebmentions.php
Last active January 6, 2018 21:38
Unspam Webmentions in WordPress theme function
/**
* Unspam Webmentions
*
* @method unspam_webmentions
* @param [type] $approved [description].
* @param [type] $commentdata [description].
* @return [type] [description]
*/
function unspam_webmentions( $approved, $commentdata ) {
return $commentdata['comment_type'] == 'webmention' ? 1 : $approved;
@Zegnat
Zegnat / authdiag.php
Last active August 7, 2018 15:50
Upload to a web server on an accessible path. Navigate to it in the browser. Copy the URL from the address bar and paste it in the form. Run the test to see if your server gets Authorization headers!
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$auth = filter_input(
INPUT_POST,
'auth',
FILTER_VALIDATE_REGEXP,
array('options' => array('regexp' => '@^authtest_\d+$@'))

Using Swift Package Manager with iOS

Step 1:

File > New > Project...

Step 2:

Create a Package.swift file in your root project directory, add dependencies, then run swift package fetch on the command line in the same directory. We’re not going to run swift build because it will just complain.