Skip to content

Instantly share code, notes, and snippets.

Avatar

Sidharth Juyal chunkyguy

View GitHub Profile
@chunkyguy
chunkyguy / UIColorPickerViewControllerDemo.swift
Created Dec 23, 2020
Use UIColorPickerViewController to pick color from the selected image
View UIColorPickerViewControllerDemo.swift
class ViewController: UIViewController {
private let imagePicker = UIImagePickerController()
private let colorPicker = UIColorPickerViewController()
private let imageView = UIImageView(image: nil)
private let colorView = UIView()
private let isSetUp = false
override func viewDidLayoutSubviews() {
if !isSetUp {
@chunkyguy
chunkyguy / clang-format
Created Aug 23, 2020
objective-c clang format
View clang-format
---
BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: false
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
@chunkyguy
chunkyguy / RxArraySource.h
Created Feb 21, 2020
Rx with ObjectiveC using NSInvocation
View RxArraySource.h
#import "RxObservable.h"
@interface RxArraySource : RxObservable
+ (instancetype)createWithElements: (NSArray *)array;
- (void)subscribe:(NSInvocation *)invocation;
@end
@chunkyguy
chunkyguy / main.swift
Created Nov 26, 2019
A minimal iOS 13 app with no storyboard or xib
View main.swift
import UIKit
// MARK: - ViewController
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .red
}
}
@chunkyguy
chunkyguy / ServiceLocator.swift
Last active Nov 19, 2019
Service Locator Pattern with GameplayKit
View ServiceLocator.swift
private class ServiceWrapper<T>: GKComponent {
let service: T
init(service: T) {
self.service = service
super.init()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
View cornell_box_scenekit.swift
import Foundation
import SceneKit
import GLKit
class World {
let scene = SCNScene()
func setUp() {
let worldNode = scene.rootNode
addLights(to: worldNode)
View KeyboardHackViewController.swift
//
// ViewController.swift
// KeyboardTransitionBug
//
// Created by Sid on 07/12/2017.
// Copyright © 2017 Picnic. All rights reserved.
//
import UIKit
View Sid.dvtcolortheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0 0 0 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Bold - 11.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0 0 0 1</string>
@chunkyguy
chunkyguy / AudioManagerController.h
Last active Oct 27, 2020
How to cross fade between AVAudioPlayers
View AudioManagerController.h
/*
* Hedgewars-iOS, a Hedgewars port for iOS devices
* Copyright (c) 2009-2011 Vittorio Giovara <vittorio.giovara@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
View mvvm_tableView.swift
import UIKit
struct Album {
let title: String
}
class SwiftAlbumsTableViewController: UITableViewController {
@IBOutlet weak private var activityIndicator: UIActivityIndicatorView!