Skip to content

Instantly share code, notes, and snippets.

@Ziewvater
Ziewvater / gist:0cf56b85a1764dd0ea1bfe88425f8787
Created July 10, 2023 12:00
Mask view created with the negative space within a stroked path
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
class StrokedPathFillMaskView: UIView {
var path: UIBezierPath? {
didSet {
setNeedsDisplay()
}
@Ziewvater
Ziewvater / SomeView.swift
Created November 29, 2016 21:43
closure property declaration
class SomeView {
// Declare property as a closure that's lazily executed on evaluation
let label: UILabel = {
// Create view within closure
let view = UILabel()
// Do whatever kind of configuration you want on it
view.font = .systemFont(ofSize: 14)
view.textColor = .blue
@Ziewvater
Ziewvater / PFErrorHelper.swift
Created August 18, 2015 22:24
Grabbing correct PFErrorCode for an error returned in a Parse cloud code response
// Class that can retrieve nested error messages from Parse cloud code responses
//
// If you've got cloud code that does something like
//
// thing.save().then(function(savedThing) {
// response.success();
// }, function(error) {
// response.error(error);
// });
//
@Ziewvater
Ziewvater / badIB
Last active August 29, 2015 14:19
Bash script for getting rid of bad Interface Builder state that can occur in Xcode 6.3.
#!/usr/bin/env bash
WORKSPACE=`find . -name "*.xcworkspace" | grep -v "project.xcworkspace"`
if [[ -n $WORKSPACE ]]; then
$(rm $WORKSPACE/xcuserdata/$USER.xcuserdatad/UserInterfaceState.xcuserstate)
else
PROJECT=`find . -name "*.xcodeproj"`
$(rm $PROJECT/xcuserdata/$USER.xcuserdatad/UserInterfaceState.xcuserstate)
fi
@Ziewvater
Ziewvater / gist:998b5806b0d12e4cf35b
Created March 27, 2015 00:25
Determining if swift string contains emoji character
func containsEmoji(text: String) -> Bool {
var containsEmoji = false
for scalar in text.unicodeScalars {
switch scalar.value {
case 0x1F600...0x1F64F:
// Emoticons
containsEmoji = true
case 0x1F300...0x1F5FF:
// Misc Symbols and Pictographs
containsEmoji = true
@Ziewvater
Ziewvater / GfycatHandler
Created March 14, 2015 17:00
Uploading to Gfycat using AFNetworking in Swift
import UIKit
let GfycatPOSTURL = "https://gifaffe.s3.amazonaws.com/"
let GfycatPolicy = "eyAiZXhwaXJhdGlvbiI6ICIyMDIwLTEyLTAxVDEyOjAwOjAwLjAwMFoiLAogICAgICAgICAgICAiY29uZGl0aW9ucyI6IFsKICAgICAgICAgICAgeyJidWNrZXQiOiAiZ2lmYWZmZSJ9LAogICAgICAgICAgICBbInN0YXJ0cy13aXRoIiwgIiRrZXkiLCAiIl0sCiAgICAgICAgICAgIHsiYWNsIjogInByaXZhdGUifSwKCSAgICB7InN1Y2Nlc3NfYWN0aW9uX3N0YXR1cyI6ICIyMDAifSwKICAgICAgICAgICAgWyJzdGFydHMtd2l0aCIsICIkQ29udGVudC1UeXBlIiwgIiJdLAogICAgICAgICAgICBbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwgMCwgNTI0Mjg4MDAwXQogICAgICAgICAgICBdCiAgICAgICAgICB9"
let GfycatAWSAccessKeyId = "AKIAIT4VU4B7G2LQYKZQ"
let GfycatSignature = "mk9t/U/wRN4/uU01mXfeTe2Kcoc="
let GfycatTranscodeURL = "http://upload.gfycat.com/transcode/"
class GfycatHandler: NSObject {