Skip to content

Instantly share code, notes, and snippets.

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

Nikhil Nigade dezinezync

🏠
Working from home
View GitHub Profile
@dezinezync
dezinezync / UISlider+MacCatalyst.h
Last active August 18, 2023 13:31
UISlider crashes the app when used in a Mac Catalyst app. Also applies to AVPlayerViewController. This category swizzles the methods with blank implementations.
//
// UISlider+MacCatalyst.m
// Elytra
//
// Created by Nikhil Nigade on 30/09/20.
//
/**
* USE AT YOUR OWN RISK!
* The only downside of using this category is that you end up with a slider with a comically larger tracking button.
@dezinezync
dezinezync / FourColumns.swift
Created June 24, 2020 08:04 — forked from douglashill/FourColumns.swift
A sample UIKit app that sets up a four column layout with new iOS 14 API on UISplitViewController.
import UIKit
class FourColumnsContainerViewController: UIViewController {
let outerSplitViewController = UISplitViewController(style: .tripleColumn)
let innerSplitViewController = UISplitViewController(style: .doubleColumn)
let primary = makeContentViewController("App")
let secondary = makeContentViewController("Files")
let mainContent = makeContentViewController("File Content")
let inspector = makeContentViewController("Inspector")
@dezinezync
dezinezync / xcpm.xml
Created November 15, 2019 07:10
Asus X99-A
<dict>
<key>Comment</key>
<string>_xcpm_SMT_scope_msrs 1 © Pike R. Alpha</string>
<key>Disabled</key>
<false/>
<key>Find</key>
<data>
vgsAAABd6QgAAAA=
</data>
<key>MatchOS</key>
@dezinezync
dezinezync / HookedGesturesForiOS13LinkTapBug.m
Last active October 1, 2019 04:24
Link Detection fires immediately in iOS 13.x on UITextView
/*
* The issue this whole time was the UITextView would not wait for the pan gesture of it's hosting UIScrollView to fail.
* Once we find out the correct gestures to hook into, we can ensure they don't get recognized simultaneously.
*/
@interface TextViewSubclass : UITextView <UIGestureRecognizerDelegate> {
BOOL _hasHookedGesturesForiOS13LinkTapBug;
}
- (void)_hookGestures;
@dezinezync
dezinezync / dark.html
Created September 20, 2019 11:56
Dark Mode <picture>
<picture id="theme-default" class="active">
<source srcset="/images/1.4/image-dark-414.png, /images/1.4/image-dark@2x.png 2x" media="(max-width: 414px) and (prefers-color-scheme: dark)" />
<source srcset="/images/1.4/image-dark-768.png, /images/1.4/image-dark@2x.png 2x" media="(max-width: 768px) and (prefers-color-scheme: dark)" />
<source srcset="/images/1.4/image-dark@3x.png" media="(min-width: 769px) and (prefers-color-scheme: dark)" />
<source srcset="/images/1.4/image-414.png, /images/1.4/image@2x.png 2x" media="(max-width: 414px)" />
<source srcset="/images/1.4/image-768.png, /images/1.4/image@2x.png 2x" media="(max-width: 768px)" />
<source srcset="/images/1.4/image@3x.png" media="(min-width: 769px)" />
<img src="/images/1.4/image@2x.png" alt="Elytra's Primary Interfaces" width="1041" />
</picture>
@dezinezync
dezinezync / pasteboard.m
Last active March 1, 2019 06:49
UIPasteboard Attributed Text Crash
- (void)copy:(id)sender {
// calling the following crashes the app instantly
// due to a possible bug in iOS 12.1.4.
// [super copy:sender];
NSRange range = self.selectedRange;
if (range.location != NSNotFound && range.length > 0) {
@dezinezync
dezinezync / gst.js
Last active August 16, 2018 09:36
[RegExp] GST Number Validation
/^
(0[0-9]|1[1-9]|2[0-9]|3[0-7]) // matches the first two digits. This needs to be within the 01-37 range
[A-Z]{3} // first three letters of the PAN Card
[CPHFATBLJG]{1} // PAN limited set control character
[A-Z]{1} // PAN non-limited set control character
\d{4} // PAN Identity numbers
[A-Z]{1} // PAN non-limited set control character
\d{1} // GST control number
[A-Z0-9]{2} // GST non-limited control characters
$/g
@dezinezync
dezinezync / chrome_install_headless.sh
Created May 2, 2017 08:59 — forked from Leotomas/chrome_install_headless.sh
Install Chrome headless on Ubuntu
export CHROME_BIN=/usr/bin/google-chrome
export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start
sudo apt-get update
sudo apt-get install -y libappindicator1 fonts-liberation
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb
@dezinezync
dezinezync / seqpromise.js
Created February 9, 2017 08:23
Run N Promises sequentially, irrespective of whether the previous promise passed or failed.
const run = () => +new Date()
let arr = Array.from({length: 100}, run)
arr.reduce((x, y) => {
x.then(result => {
console.log(x)
return y
}, err => {
console.error(err)
@dezinezync
dezinezync / reset.css
Created November 3, 2016 11:44
Modern CSS Reset (UA Style)
// the following is taken from the following tweet
// https://twitter.com/benfrain/status/794138525570580480
* {
all: unset;
}
head {
display: none;
}