Skip to content

Instantly share code, notes, and snippets.


Ben arkilis

View GitHub Profile
View dict_csharp.cs
using System.Collections.Generic;
// example of string key and value is string
Dictionary<string, string> openWith = new Dictionary<string, string>();
// example of int key and value is a list
Dictionary<int, string[]> OtherType = new Dictionary<int, string[]>();
View lay_objc.m
@interface ViewController ()
@property (nonatomic) float value;
@implementation ViewController
- (float)value {
View lazy.swift
class MyClass {
lazy var names: NSArray = {
let names = NSArray()
print("Only run at the first time access")
return names
View action.cs
// action with generic type
Action<Book> printBookTitle = delegate(Book book)
// action without generic type
Action printLog = delegate {
View preview_iphone_fix_size.swift
struct PurchaseButtonView_Previews: PreviewProvider {
static var previews: some View {
VStack {
PurchaseButtonView(title: "Buy") {
print("Buy button clicked")
PurchaseButtonView(title: "Sell") {
print("Buy button clicked")
View preview_iphone.swift
import SwiftUI
struct PurchaseButtonView: View {
var title: String
var callback: () -> Void
var body: some View {
action: { self.callback() },
label: {
View swiftlint.yml
disabled_rules: # rules you don't want to use
- trailing_comma
opt_in_rules: # rules you want to use
- array_init
- closure_body_length
- closure_end_indentation
included: # include directories
- Source
set -e
git diff --diff-filter=d --staged --name-only | grep -e '\(.*\).swift$' | while read line; do
swiftformat "${line}";
git add "$line";
swiftlint --quiet --strict
View compiler_directives_2.swift
#if os(OSX)
// compiles for OS X
#elseif os(iOS)
// compiles for iOS
#elseif os(tvOS)
// compiles for TV OS
#elseif os(watchOS)
// compiles for Apple watch
View compiler_directives.swift
var url = ""
// use localhost while under debug mode
url = "https://localhost"
// use production url while under release
url = "production url"
// You can negate the flag