Skip to content

Instantly share code, notes, and snippets.

View VincentSit's full-sized avatar

Vincent VincentSit

View GitHub Profile
@VincentSit
VincentSit / redis-expire.sh
Created April 15, 2020 14:47 — forked from fieg/redis-expire.sh
Set expire on large set of keys using pattern in Redis
#!/bin/bash
if [ $# -ne 4 ]
then
echo "Usage: $0 <host> <port> <pattern> <seconds>"
exit 1
fi
cursor=-1
keys=""
@VincentSit
VincentSit / X509.swift
Created June 8, 2019 14:15 — forked from bagpack/X509.swift
X.509/P12
enum X509Error: Error {
case certificateError(message: String)
case publicKeyError(message: String)
}
class X509 {
// A DER (Distinguished Encoding Rules) representation of an X.509 certificate.
let publicKey: SecKey
@VincentSit
VincentSit / iOS @3x assets script
Created May 11, 2019 03:33 — forked from rnystrom/iOS @3x assets script
Save this shell script to generate @2x and 1x PNG assets for your apps. Requires Imagemagick (http://www.imagemagick.org/). These will probably look shitty and blurred.
#!/bin/sh
# Example usage
# cd into directory that has @3x images
# ./whatever-you-name-this.sh
# Remember to chmod +x the script
resize () {
ls *@3x.png | awk '{print("convert "$1" -filter box -resize '$1' "$1)}' | sed 's/@3x/'$2'/2' | /bin/sh
}
@VincentSit
VincentSit / AutoHook.h
Created October 29, 2018 14:09 — forked from JohnCoates/AutoHook.h
Simple Objective-C Method Hooking
@protocol AutoHook <NSObject>
@required
+ (NSArray <NSString *> *)targetClasses;
@end
@VincentSit
VincentSit / Obfuscator.swift
Created January 14, 2018 13:02 — forked from DejanEnspyra/Obfuscator.swift
Obfuscation of hard-coded security-sensitive strings.
//
// Obfuscator.swift
//
// Created by Dejan Atanasov on 2017-05-31.
//
import Foundation
class Obfuscator: AnyObject {
@implementation UIFont (PSPDFAdditions)
// https://gist.github.com/nuthatch/7594460
static CGFloat PSPDFMultiplicatorForPreferredContentSize(void) {
CGFloat multiplicator = 1.f;
NSString *preferredTextStyle = UIApplication.sharedApplication.preferredContentSizeCategory;
if ([preferredTextStyle isEqualToString:UIContentSizeCategoryExtraSmall]) {
multiplicator = 0.9f;
}else if ([preferredTextStyle isEqualToString:UIContentSizeCategorySmall]) {
multiplicator = 0.95f;
@VincentSit
VincentSit / bcastpacket.m
Created December 26, 2016 08:19 — forked from chrishulbert/bcastpacket.m
Send a broadcast udp message using c / obj-c
#include <netinet/in.h>
#include <sys/socket.h>
#include <unistd.h>
#include <arpa/inet.h>
- (void)sendBroadcastPacket {
// Open a socket
int sd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sd<=0) {
NSLog(@"Error: Could not open socket");
#include <netinet/in.h>
#include <sys/socket.h>
#include <unistd.h>
#include <arpa/inet.h>
- (void)broadCast
{
int socketSD = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (socketSD <= 0) {
NSLog(@"Error: Could not open socket.");
@VincentSit
VincentSit / ViewController.swift
Created May 24, 2016 07:08 — forked from jonallured/ViewController.swift
In-App WAC with Swift and unsafeBitCast
import UIKit
import ExternalAccessory
class ViewController: UIViewController, EAWiFiUnconfiguredAccessoryBrowserDelegate {
var accessoryBrowser: EAWiFiUnconfiguredAccessoryBrowser?
override func viewDidLoad() {
super.viewDidLoad()
accessoryBrowser = EAWiFiUnconfiguredAccessoryBrowser.init(delegate: self, queue: nil)
accessoryBrowser?.startSearchingForUnconfiguredAccessoriesMatchingPredicate(nil)
@VincentSit
VincentSit / nanos.cpp
Created May 9, 2016 17:01 — forked from brysonian/nanos.cpp
get a nanosecond accurate counter for ios and os x
uint64_t nanos() {
static mach_timebase_info_data_t info;
mach_timebase_info(&info);
uint64_t now = mach_absolute_time();
now *= info.numer;
now /= info.denom;
return now;
}