Skip to content

Instantly share code, notes, and snippets.

Hiroki Nagasawa pixyzehn

Block or report user

Report or block pixyzehn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pixyzehn
pixyzehn / swift-format.swift
Created Dec 30, 2017 — forked from harlanhaskins/swift-format.swift
Simple Swift Formatter using SwiftSyntax
View swift-format.swift
import Foundation
import SwiftSyntax
func main() throws {
guard CommandLine.arguments.count > 1 else {
print("usage: swift-format [file]")
exit(-1)
}
let url = URL(fileURLWithPath: CommandLine.arguments[1])
View Pattern for Swift Errors.swift
// Swift's untyped errors are a goddam PiTA. Here's the pattern I use to try to work around this.
// The goal is basically to try to guarantee that every throwing function in the app throws an
// ApplicationError instead of some unknown error type. We can't actually enforce this statically
// But by following this convention we can simplify error handling
enum ApplicationError: Error, CustomStringConvertible {
// These are application-specific errors that may need special treatment
case specificError1
case specificError2(SomeType)
@pixyzehn
pixyzehn / GIF-Screencast-OSX.md
Created Mar 5, 2017 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF
View GIF-Screencast-OSX.md

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@pixyzehn
pixyzehn / Autoclosure.swift
Created Jan 21, 2017 — forked from JohnSundell/Autoclosure.swift
Simple Dictionary extension to avoid the if let-dance when retrieving values
View Autoclosure.swift
extension Dictionary {
mutating func value(for key: Key, orAdd closure: @autoclosure () -> Value) -> Value {
if let value = self[key] {
return value
}
let value = closure()
self[key] = value
return value
}
@pixyzehn
pixyzehn / SampleViewController.swift
Created Jan 14, 2017 — forked from JaviSoto/SampleViewController.swift
Init based Storyboard View Controller Instantiation
View SampleViewController.swift
final class SampleViewController: StoryboardBackedViewController {
// Unfortunately this must be an IUO var, so that we can set the value after super.init
private var member: Foo!
// Proper dependency injection in a storyboard backed VC!
init(foo: Foo) {
super.init(storyboardIdentifier: "SampleViewControllerIdentifier")
// We have to set the members *after* calling super.init, since it changes the instance of `self`.
self.member = foo
@pixyzehn
pixyzehn / The Technical Interview Cheat Sheet.md
Created Dec 31, 2016 — forked from TSiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.
View The Technical Interview Cheat Sheet.md

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
View libyaml.swift
// gem install cocoapods-playgrounds
// pod playgrounds LibYAML
// Update: @floriankugler had a great idea to use UnsafeBufferPointer
// Paste in the following:
import LibYAML
public struct YAMLError: ErrorType {
View unwrap.md

Better Unwrapping

Introduction

This proposal redesigns common unwrapping tasks:

@pixyzehn
pixyzehn / Fresh macOS Setup.md
Created Nov 27, 2016 — forked from ashfurrow/Fresh macOS Setup.md
All the stuff I do on a fresh macOS Installation
View Fresh macOS Setup.md

Apps to install from macOS App Store:

  • Tweetbot
  • CopyClip 2
  • GIF Brewery
  • Slack
  • Deckset
  • Keynote/Pages/Numbers
  • 1Password
  • OmniFocus 2
View keybase.md

Keybase proof

I hereby claim:

  • I am pixyzehn on github.
  • I am pixyzehn (https://keybase.io/pixyzehn) on keybase.
  • I have a public key whose fingerprint is 921D 8F2A 639B 8429 C68D 25C0 018D 15DC 56E3 5E3B

To claim this, I am signing this object:

You can’t perform that action at this time.