Skip to content

Instantly share code, notes, and snippets.

View yhkaplan's full-sized avatar
⚙️

Joshua Kaplan yhkaplan

⚙️
View GitHub Profile
import UIKit
typealias Constraint = (UIView, UIView) -> NSLayoutConstraint
func equal<L, Axis>(_ to: KeyPath<UIView, L>, constant: CGFloat = 0, priority: UILayoutPriority? = nil) -> Constraint where L: NSLayoutAnchor<Axis> {
return equal(to, to, constant: constant, priority: priority)
}
func equal<L, Axis>(_ from: KeyPath<UIView, L>, _ to: KeyPath<UIView, L>, constant: CGFloat = 0, priority: UILayoutPriority? = nil) -> Constraint where L: NSLayoutAnchor<Axis> {
return { view1, view2 in
@rockname
rockname / update_carthage_libraries.rb
Created February 20, 2019 11:04
CarthageのライブラリをアップデートしてPullRequestを作成するFastlaneのlane
lane :update_carthage_libraries do |options|
outdateds = ""
Dir.chdir ".." do
outdateds += sh("carthage", "outdated")
end
current_branch = git_branch
outdateds.each_line do |line|
@nicklockwood
nicklockwood / Withable.swift
Created January 28, 2019 12:06
Withable.swift
/// Withable is a simple protocol to make constructing
/// and modifying objects with multiple properties
/// more pleasant (functional, chainable, point-free)
public protocol Withable {
init()
}
public extension Withable {
/// Construct a new instance, setting an arbitrary subset of properties
init(with config: (inout Self) -> Void) {
@udzura
udzura / yawaraka-docker.md
Last active June 16, 2022 23:34
やわらかDocker
@cellularmitosis
cellularmitosis / EmojiPointersDemo.swift
Created August 15, 2018 18:11
Representing pointer values as emoji can be useful for "visually" debugging certain issues, like cell reuse, etc.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let window = UIWindow(frame: UIScreen.main.bounds)
@manofearth
manofearth / delete-stale-branches.sh
Last active November 14, 2021 02:34
Delete Stale Branches
#!/usr/bin/env bash
while getopts "d" opt; do
case $opt in
d) dryRunOpt="--dry-run";;
esac
done
# prune local "cache" of remote branches first:
git fetch --prune origin
# delete merged to master branches:
@kakashysen
kakashysen / swift-for-vim.md
Created October 10, 2017 21:13
How to add Swift Syntax Highlighting in Vim

Enable Swift Highlighting Syntax for Vim

  1. Execute the given below commands

$mkdir -p ~/.vim/autoload ~/.vim/bundle

$curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

  1. Add the given below lines to ~/.vimrc
@simoncos
simoncos / golang_on_rpi.md
Last active March 7, 2025 06:21 — forked from konradko/golang_on_rpi.md
Install Golang 1.9 on Raspberry Pi

Install Golang 1.9:

wget https://storage.googleapis.com/golang/go1.9.linux-armv6l.tar.gz
sudo tar -C /usr/local -xzf go1.9.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin # put into ~/.profile

If already installed old golang with apt-get:

@Liquidsoul
Liquidsoul / AutoInit.stencil
Last active March 15, 2023 08:02
A Sourcery template to generate a default initializer in your `struct`s (working in version 0.8.0)
{% for type in types.structs %}
{% if type|annotated:"AutoInit" %}
{% set spacing %}{% if type.parentName %} {% endif %}{% endset %}
{% map type.storedVariables into parameters using var %}{{ var.name }}: {{ var.typeName }}{% endmap %}
// sourcery:inline:auto:{{ type.name }}.AutoInit
{{spacing}} {{ type.accessLevel }} init({{ parameters|join:", " }}) { // swiftlint:disable:this line_length
{{spacing}} {% for variable in type.storedVariables %}
{{spacing}} self.{{ variable.name }} = {{ variable.name }}
{{spacing}} {% endfor %}
{{spacing}} }
@ryboe
ryboe / .travis.yml
Last active June 11, 2025 03:12
Example .travis.yml for Golang
# use the latest ubuntu environment (18.04) available on travis
dist: bionic
language: go
# You don't need to test on very old versions of the Go compiler. It's the user's
# responsibility to keep their compiler up to date.
go:
- 1.16.x