Skip to content

Instantly share code, notes, and snippets.

View bishalg's full-sized avatar
🏠
Working from home

Bishal Ghimire bishalg

🏠
Working from home
View GitHub Profile
@vinczebalazs
vinczebalazs / SheetModalPresentationController.swift
Last active July 21, 2024 15:36
A presentation controller to use for presenting a view controller modally, which can be dismissed by a pull down gesture. The presented view controller's height is also adjustable.
import UIKit
extension UIView {
var allSubviews: [UIView] {
subviews + subviews.flatMap { $0.allSubviews }
}
func firstSubview<T: UIView>(of type: T.Type) -> T? {
allSubviews.first { $0 is T } as? T
import Foundation
protocol PanpaDecodable: Decodable & Keyable { }
protocol Keyable {
static var codingKey: String { get }
}
import Foundation
import UIKit
struct ViewStyle<T> {
let style: (T) -> Void
}
let filled = ViewStyle<UIButton> {
$0.setTitleColor(.white, for: .normal)
$0.backgroundColor = .red
@TonsOfFun
TonsOfFun / docker-compose.yml
Created May 14, 2018 16:17
Crypto Smart Camera POC
version: '3'
services:
miner:
image: cryptotrust/rpi-cpuminer-multi
command: "cpuminer -u ${EMAIL} -a ${ALGO} -o stratum+tcp://${URL}:${PORT} -t ${THREADS}"
camera:
image: ricklon/rpi-opencv
command: python motion_capture.py
volumes:
- .:/greenthumb-rails
@damienlaughton
damienlaughton / UIAccessorizedTextField.swift
Created March 28, 2018 15:16
UIAccessorizedTextField is an iOS friendly alternative to the drop down list
//
// UIAccessorizedTextField.swift
// AccessorizedTextField
//
// Created by Damien Laughton on 28/03/2018.
// 2018 Mobilology Limited. No rights reserved.
//
import Foundation
import UIKit
@asmallteapot
asmallteapot / Dictionary.Value+RangeReplaceableCollection.swift
Last active March 28, 2023 07:40
Swift: Append an element to an array in a dictionary value, creating the array/value if needed
import Foundation
extension Dictionary where Value: RangeReplaceableCollection {
public mutating func append(element: Value.Iterator.Element, toValueOfKey key: Key) -> Value? {
var value: Value = self[key] ?? Value()
value.append(element)
self[key] = value
return value
}
}
# Merge Script
# 1
# Set bash script to exit immediately if any commands fail.
set -e
# 2
# Setup some constants for use later on.
FRAMEWORK_NAME="BrandingFramework"
@The0racle
The0racle / NSFetchedResultsController+SafeObjectAtIndexPath
Last active September 3, 2021 22:42
NSFetchedResultsController extension for safely retrieving objects without raising 'NSInternalInconsistencyException'.
//
// NSFetchedResultsController+SafeObjectAtIndexPath.swift
// This extension prevents the 'no object at index in section at index' exception.
//
// Copyright (c) 2016 Thiago Pereira
// MIT License, http://www.opensource.org/licenses/mit-license.php
import Foundation
extension NSFetchedResultsController{
@0xced
0xced / Emoji-iOS-10.0-14A5322e.json
Created August 8, 2016 22:38
Emoji from iOS beta 4 (14A5322e)
{
"People" : [
{
"Symbol" : "😀",
"Name" : "GRINNING FACE"
},
{
"Symbol" : "😬",
"Name" : "GRIMACING FACE"
},
@steipete
steipete / ios-xcode-device-support.sh
Last active October 14, 2024 16:35
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)