Skip to content

Instantly share code, notes, and snippets.

@debarko
debarko / cowin_schedule_district_wise.js
Last active June 3, 2021 08:07
Get an update on console as soon as a slot opens up in https://selfregistration.cowin.gov.in/ . Login to the website and then run this script on Console.
// This script will alert you whenever some slot opens up on the given date within the given District IDs
// Change the districts to your needs as per your city
// Change the dateArr to add your convinent set of dates
// For further update do checkout http://twitter.com/debarko/
// How To setup Video -> https://www.youtube.com/watch?v=3_N5FFegtI4
// Steps to use
// 1. Update Config
[
"WAT": "Africa/Lagos",
"EAT": "Africa/Addis_Ababa",
"MDT": "America/Denver",
"ICT": "Asia/Bangkok",
"TRT": "Europe/Istanbul",
"PHT": "Asia/Manila",
"CAT": "Africa/Harare",
"EET": "Europe/Athens",
"SGT": "Asia/Singapore",
[
"Africa/Abidjan",
"Africa/Accra",
"Africa/Addis_Ababa",
"Africa/Algiers",
"Africa/Asmara",
"Africa/Bamako",
"Africa/Bangui",
"Africa/Banjul",
"Africa/Bissau",
@jkereako
jkereako / ReCAPTCHAViewController.swift
Created September 8, 2020 13:15
ReCAPTCHA v2 in Swift
import UIKit
import WebKit
final class ReCAPTCHAViewController: UIViewController {
private var webView: WKWebView!
private let viewModel: ReCAPTCHAViewModel
init(viewModel: ReCAPTCHAViewModel) {
self.viewModel = viewModel
@sharplet
sharplet / Example.swift
Created November 3, 2017 17:46
An improved wrapper for UIImagePickerController
// Here is a usage example. Refer to ImagePicker.swift below for the implementation!
// 1. Easily configure the picker
let cameraPicker = ImagePicker(sourceType: .camera)
let cropPicker = ImagePicker(sourceType: .photoLibrary, allowsEditing: true)
// Automatically includes both kUTTypeImage and kUTTypeLivePhoto
let livePhotoPicker = ImagePicker(sourceType: .photoLibrary, mediaTypes: [.livePhotos])
// 2. Use the picker
@darthpelo
darthpelo / DynamicBinding.swift
Last active August 9, 2022 07:56
ViewModel, binding and generic
// Ispired by http://rasic.info/bindings-generics-swift-and-mvvm/
class Dynamic<T> {
typealias Listener = (T) -> Void
var listener: Listener?
func bind(listener: Listener?) {
self.listener = listener
}
func bindAndFire(listener: Listener?) {
@abhimuralidharan
abhimuralidharan / ThemeManager.swift
Last active December 31, 2022 11:39
A guide on how to create a theme manager class in swift so that the code is flexible and the developer can change the theme colour anytime with ease.
//
// ThemeManager.swift
// ProjectThemeTest
//
// Copyright (c) 2017 Abhilash
//
import UIKit
import Foundation
import UIKit
import PlaygroundSupport
// https://gist.github.com/erica/6f13f3043a330359c035e7660f3fe7f5
// Original Video: https://www.youtube.com/watch?v=TTmWUSgNOHk
// Video: https://www.youtube.com/watch?v=hmAB3WJOQTU
// Video: https://www.youtube.com/watch?v=DWtavuvmKdw (with zoom and fade)
// String to animate and its attributes
var string = "Hello, playground"
let attributes: [String: Any] = [
@krin-san
krin-san / ToggleConstraint.m
Last active October 1, 2020 07:23
NSLayoutConstraint with a two possible states and a flag to toggle between them
#import <UIKit/UIKit.h>
/// This constraint could be toggled between two values (min/max) by `enlarged` flag
@interface ToggleConstraint : NSLayoutConstraint
/**
Max size of the height/width/offset/etc.
Think about it as some UI element can change it's size between min and max values.
*/
@property (nonatomic, assign) IBInspectable BOOL enlarged;
@quangtqag
quangtqag / AppDelegate.swift
Last active August 31, 2023 02:15
Make app always call applicationWillTerminate
func applicationDidEnterBackground(application: UIApplication) {
// Create a pseudo background task to system call applicationWillTerminate when app enter background
// Default system will not call applicationWillTerminate when app enter background
// applicationWillTerminate only called when user close app in app switcher or some special cases of system
bgTask = application.beginBackgroundTaskWithExpirationHandler({ () -> Void in
application.endBackgroundTask(self.bgTask)
self.bgTask = UIBackgroundTaskInvalid
})
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { () -> Void in