Skip to content

Instantly share code, notes, and snippets.

@bolencki13
bolencki13 / WKWebView+Complete.h
Created March 26, 2017 16:28
WKWebView load request with completion block
//
// WKWebview+Complete.h
// partyface
//
// Created by Brian Olencki on 3/26/17.
// Copyright © 2017 Brian Olencki. All rights reserved.
//
#import <WebKit/WebKit.h>
@bolencki13
bolencki13 / colorChange.py
Created March 29, 2017 16:35
Change the color of an image file
from PIL import Image
import sys
import os
picture = None
picturePath = None
def validateColor(hex):
return (len(hex) == 7)
@bolencki13
bolencki13 / LogTrace.m
Last active December 16, 2019 15:27
Log Method Trace
#import <Foundation/Foundation.h>
#import <dlfcn.h>
void logTrace(BOOL on) {
typedef void functype(BOOL);
void *libobjc = dlopen("/usr/lib/libobjc.dylib", RTLD_LAZY);
functype *instrumentObjcMessageSends = dlsym(libobjc, "instrumentObjcMessageSends");
if (!instrumentObjcMessageSends) {
NSLog(@"Couldn't get instrumentObjcMessageSends");
exit(1);
@bolencki13
bolencki13 / gist:243420f68663664d06288dd8c6bf773f
Created August 11, 2017 15:26
Regex Password Validation
/*
Valid password condition:
• At least 8 characters long
• At least one upper-case letter
• At least one lower-case letter
• At least one numeric digit
*/
((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])){8,}
@bolencki13
bolencki13 / BTOTransparentViewController.h
Created October 31, 2017 20:16
Transparent View Controller
//
// BTOTransparentViewController.m
//
// Created by Brian Olencki on 10/31/17.
//
#import "BTOTransparentViewController.h"
@interface BTOTransparentViewController ()
@bolencki13
bolencki13 / Bash Shell
Created February 1, 2019 20:34
Remove all global npm packages
npm r -g $(node -e "console.log(process.argv.filter((e) => e !== '├──' && e !== '└──').filter((_, i) => i > 1).map((e) => e.split('@')[0]).filter((e) => e !== 'npm').join(' '))" $(npm list -g -depth 0))
@bolencki13
bolencki13 / change-author.sh
Created May 18, 2019 11:43
Change author information in a git repo
#!/bin/sh
#
# This was taken from [here](https://help.github.com/en/articles/changing-author-info)
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
@bolencki13
bolencki13 / DefaultValueDecorator.ts
Last active June 3, 2022 19:30
The purpose of this decorator is to re-assign the default value when the incoming value is null or undefined.
/**
* The purpose of this decorator is to re-assign the default value when the incoming value is null or undefined.
* This can be modified to ignore null or undefined as an incoming value.
*/
type UseDefaultOptions = {
whenNull?: boolean;
whenUndefined?: boolean;
};
@bolencki13
bolencki13 / PromiseBuilder.ts
Created June 10, 2022 19:08
Expose promise methods on a class that resolve type T
/**
* Exposes internal promise methods on the class that resolves a result of type T
*/
abstract class PromiseBuilder<T> implements Promise<T> {
/**
* Result to be returned when builder is resolved
*/
protected abstract _fetchResult(): Promise<T>
type CompareNumbers<
T extends number,
U extends number,
A extends any[] = [],
> = T extends U
? 0 : A['length'] extends T
? -1
: A['length'] extends U
? 1
: CompareNumbers<T, U, ['a', ...A]>