Skip to content

Instantly share code, notes, and snippets.

View dorentus's full-sized avatar
🎲
🌎🌍🌏

ZHANG Yi dorentus

🎲
🌎🌍🌏
View GitHub Profile
#!/usr/bin/arch -x86_64 /bin/sh
exec $SHELL --login
@dorentus
dorentus / webview.m
Last active May 27, 2021 06:16
Bypass Apple's UIWebView deprecation detection
#import <Foundation/Foundation.h>
#import <dlfcn.h>
@interface UIWebView : NSObject
@end
@implementation UIWebView
+ (id)alloc
{
@dorentus
dorentus / dynamic_cast.mm
Created August 30, 2016 02:23 — forked from bdash/dynamic_cast.mm
Excerpt from Hopper pseudocode from __dynamic_cast in libc++abi.dylib
if ((*(int8_t *)guard variable for __dynamic_cast::use_strcmp == 0x0) && (___cxa_guard_acquire(guard variable for __dynamic_cast::use_strcmp, rsi, rdx, rcx, r8, r9) != 0x0)) {
rsi = *_NSGetProgname();
rcx = 0x1;
if (strcmp("Adobe Illustrator", rsi) != 0x0) {
rsi = *_NSGetProgname();
rdx = 0x13;
rcx = strncmp("Adobe Photoshop CS5", rsi, rdx) == 0x0 ? 0x1 : 0x0;
}
*(int8_t *)__dynamic_cast::use_strcmp = rcx;
___cxa_guard_release(guard variable for __dynamic_cast::use_strcmp, rsi, rdx, rcx, r8, r9);

Keybase proof

I hereby claim:

  • I am dorentus on github.
  • I am dorentus (https://keybase.io/dorentus) on keybase.
  • I have a public key whose fingerprint is 32DD 649A 9F71 F018 1561 5167 34A8 0D0F 6825 922C

To claim this, I am signing this object:

import Foundation
final class Worker {
let timeout = 5
let notify: Void -> Void
init(notify: Void -> Void) {
self.notify = notify
}
#!/usr/bin/env ruby
require "tmpdir"
version = ARGV[0].to_s
abort("Usage: swift-install <VERSION> <DESTINATION>") if version.empty?
dest = ARGV[1].to_s
abort("Usage: swift-install <VERSION> <DESTINATION>") if dest.empty?
dest = File.expand_path dest, Dir.pwd
# global env
set -gx LC_TIME 'ja_JP.UTF-8'
set -gx LC_MESSAGES 'en_US.UTF-8'
set -gx PATH $HOME/bin /usr/local/sbin /usr/local/bin $PATH
set -gx EDITOR vim
# swiftenv
#setenv SWIFTENV_ROOT "$HOME/.swiftenv"
#setenv PATH "$SWIFTENV_ROOT/bin" $PATH
#status --is-interactive; and . (swiftenv init -|psub)
//
// JSON.swift
//
//
// Created by ZHANG Yi on 2015-9-1.
//
// The MIT License (MIT)
//
// Copyright (c) 2015 ZHANG Yi <zhangyi.cn@gmail.com>
//
//
// Reachability.swift
//
// Created by Zhang Yi on 15/7/29.
// Copyright (c) 2015 Zhang Yi <zhangyi.cn@gmail.com>. All rights reserved.
//
// Licence: MIT
//
import Foundation
extension NSDate {
var color: UIColor {
let components = NSCalendar.currentCalendar().components(.CalendarUnitHour | .CalendarUnitMinute | .CalendarUnitSecond, fromDate: self)
let rgb = [components.hour, components.minute, components.second].map {
CGFloat(strtoul(String($0, radix: 10), nil, 16)) / 255
}
return UIColor(red: rgb[0], green: rgb[1], blue: rgb[2], alpha: 1)
}
}