Skip to content

Instantly share code, notes, and snippets.

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

ZHANG Yi dorentus

🎲
🌎🌍🌏
View GitHub Profile
@return1
return1 / trim_enabler.txt
Last active May 26, 2024 11:01
TRIM Enabler for OS X Yosemite 10.10.3
#
# UPDATE for 10.10.4+: please consider this patch obsolete, as apple provides a tool called "trimforce" to enable trim support for 3rd party SSDs
# just run "sudo trimforce enable" to activate the trim support from now on!
#
# Original version by Grant Parnell is offline (http://digitaldj.net/2011/07/21/trim-enabler-for-lion/)
# Update July 2014: no longer offline, see https://digitaldj.net/blog/2011/11/17/trim-enabler-for-os-x-lion-mountain-lion-mavericks/
#
# Looks for "Apple" string in HD kext, changes it to a wildcard match for anything
#
# Alternative to http://www.groths.org/trim-enabler-3-0-released/
@jjgod
jjgod / my-setup.markdown
Last active May 22, 2024 22:52
My setup
@epitron
epitron / base64_fixed_point.rb
Last active December 12, 2015 07:28
Compute a Base64 fixed-point.
###########################################################################
# Base64 Fixed-point Calculator
###########################################################################
SEED = ":D" # The initial string to Base64 encode
AMOUNT = 1500 # How many bytes should the fixed point end up being?
###########################################################################
require 'base64'
@m2orris
m2orris / uncrustify_obj_c.cfg
Last active January 14, 2021 06:14
My uncrustify configuration file that I use for Objective-C.
# Uncrustify 0.60
newlines = auto
input_tab_size = 4
output_tab_size = 4
string_escape_char = 92
string_escape_char2 = 0
tok_split_gte = false
utf8_bom = ignore
utf8_byte = false
utf8_force = false
@likuku
likuku / backup.sh
Last active October 12, 2022 08:58
Build a package for your linux (building package on OS running),you can use it for backup or quick install. It was on debian and ubuntu work well. I haven't tested in other distribution.
#!/usr/bin/env bash
# Warning!
# if you DIY a stage package like this,
# you must use the Stage3`s /etc/udev/*
# or rm /etc/udev/rules.d/70*
# Warning!
# Update by likuku on Nov29,2016
readonly DATE=$(date +%Y_%m_%d_%H_%M_%S)
readonly ARCH=$(uname -m)
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active May 27, 2024 12:11
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
extern uint32_t dyld_get_program_sdk_version() WEAK_IMPORT_ATTRIBUTE;
extern BOOL DZApplicationUsesLegacyUI(void)
{
static dispatch_once_t onceToken;
static BOOL legacyUI = NO;
dispatch_once(&onceToken, ^{
uint32_t sdk = __IPHONE_OS_VERSION_MIN_REQUIRED;
if (dyld_get_program_sdk_version != NULL) {
sdk = dyld_get_program_sdk_version();
@steipete
steipete / UIKitLegacyDetector.m
Last active April 29, 2025 20:17
A simple way to detect at runtime if we're running in UIKit legacy mode or the new "flat" variant. Written for our PDF iOS SDK (http://pspdfkit.com), where the precompiled binary needs to detect at runtime in what variant it's running. Want more stuff like that? Follow me on Twitter: http://twitter.com/steipete
// Taken from http://PSPDFKit.com. This snippet is under public domain.
#define UIKitVersionNumber_iOS_7_0 0xB57
BOOL PSPDFIsUIKitFlatMode(void) {
static BOOL isUIKitFlatMode = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// We get the modern UIKit if system is running >= iOS 7 and we were linked with >= SDK 7.
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) {
isUIKitFlatMode = (NSVersionOfLinkTimeLibrary("UIKit") >> 16) >= UIKitVersionNumber_iOS_7_0;
}
@dorentus
dorentus / ramdish.sh
Last active February 9, 2017 08:19
ramdisk.sh
#!/bin/bash
RD=ramdisk
if [ ! -e "/Volumes/$RD" ]; then
diskutil erasevolume HFS+ "$RD" `hdiutil attach -nomount ram://16777216` # 8G
# ~/Library/Developer/Xcode
mkdir -p "/Volumes/$RD/Xcode"
@jazzsasori
jazzsasori / gist:9051537
Created February 17, 2014 14:27
BlocksKit 2.0
// 今までの書き方
#import <BlocksKit/BlocksKit.h>
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addEventHandler:^(id sender) {
// do something
} forControlEvents:UIControlEventTouchUpInside];
// 2.0の書き方