Skip to content

Instantly share code, notes, and snippets.

🐱

Yoshimasa Niwa niw

🐱
Block or report user

Report or block niw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View READNE.md

Build V lang compiler

A patcg and how to build it from the V lang initial open source release files

Usage

Lie this. Asuume that the platform is macOS.

@niw
niw / extract_ttf_from_ttc.rb
Created Jun 16, 2019
Extract each font file from TTC font collection file
View extract_ttf_from_ttc.rb
# See <https://docs.microsoft.com/en-us/typography/opentype/spec/otff#font-collections>
ttc = ARGF
unless ttc.read(4) == "ttcf"
STDERR.puts "Not TTC file."
exit 1
end
major_version, minor_version = ttc.read(4).unpack("nn")
@niw
niw / .gitignore
Created Jun 6, 2019
Build openconnect
View .gitignore
.DS_Store
.dependencies
homebrew
src
usr
@niw
niw / how_to_extract_dylib_from_shared_cache.md
Last active May 23, 2019
How to extract dylib from shared cache
View how_to_extract_dylib_from_shared_cache.md

How to extract dylib from shared cache

To understand iOS behaviors, sometimes it’s important to disassemble iOS framework binaries.

Since recent iOS firmware, known as .ipsw file, contains non-encrypted root image, it’s easy to access these binaries. However, each framework binaries, dylib files, are placed in a shared cache file.

Thus, before disassembling it, we need to extract the one from the cache.

@niw
niw / dump_crashlytics_session.rb
Created Mar 20, 2019
A command line interface to find a single crash session stacktrace in Crashlytics.
View dump_crashlytics_session.rb
# A command line interface to find a single crash session stacktrace in Crashlytics.
# This is impossible by using their web dashboard interface.
#
# Usage: `ruby dump_crashlytics_session.rb BEARER_TOKEN PROJECT_ID SESSION_ID`
#
# The session ID is [`[CLSReport identifiter]`](https://docs.fabric.io/appledocs/Crashlytics/Classes/CLSReport.html#//api/name/identifier).
# The project ID is an unique ID for each application, you can find in Fabric settings page.
# The bearer token is an authentication token, you can find it in web browser inspector on Fabric pages.
require "net/https"
@niw
niw / RingerSwitchObserver.h
Last active Mar 14, 2019
Get current iPhone/iPad ringer switch (mute switch) state and change events
View RingerSwitchObserver.h
@import Foundation;
NS_ASSUME_NONNULL_BEGIN
FOUNDATION_EXTERN NSString * const RingerSwitchDidChangedNotification;
@interface RingerSwitchObserver : NSObject
@property (nonatomic, readonly, getter=isSlient) BOOL silent;
@niw
niw / a.m
Created Jan 17, 2019
`ascending` and `descending` are confusing.
View a.m
@import Foundation;
int main()
{
NSDate * const a = [[NSDate alloc] initWithTimeIntervalSince1970:0];
NSDate * const b = [[NSDate alloc] initWithTimeIntervalSince1970:1];
NSLog(@"%d", (int)[a compare:b]); // -1 = NSOrderedAscending
NSLog(@"%d", (int)[a compare:a]); // 0 = NSOrderedSame
NSLog(@"%d", (int)[b compare:a]); // 1 = NSOrderedDescending
@niw
niw / 44539428.md
Created Nov 16, 2018
Reply to rdar://44539428 from Apple
View 44539428.md

Problems

When install Command Line Tools (macOS High Sierra version 10.13) for Xcode version 10.0 released on 9/17.2018 on High Sierra 10.13, it is installing out of sync tbd file to each /Systems Framework. Because of this, every time when we link one of these Framework by ld shows warning like

ld: warning: text-based stub file /System/Library/Frameworks//Foundation.framework/Foundation.tbd and library file /System/Library/Frameworks//Foundation.framework/Foundation are out of sync. Falling back to library file for linking.

In fact, /System/Library/Frameworks/Foundation.framework/Foundation.tbd is current-version: 1452.23, but /System/Library/Frameworks/Foundation.framework/Foundation is 1454.90.0.

Reply from Apple

@niw
niw / test_unicode_normalize.rb
Last active Oct 22, 2018
Testing `unorm2_normalize` with problematic Unicode code points.
View test_unicode_normalize.rb
str = "\u0336\u0344\u0357\u0343\u0314\u0351\u0340\u0300\u0340\u0360\u0314\u0357\u0315\u0301\u0344a"
p str
p str.unpack("U*").map{|a| "U+%04X" % a}
out = str.unicode_normalize(:nfc)
p out
p out.unpack("U*").map{|a| "U+%04X" % a}
View a.m
@import Foundation;
int main() {
NSMutableString *s = [[NSMutableString alloc] initWithString:@"🐱"];
[s replaceCharactersInRange:NSMakeRange(1, 1) withString:@"a"];
NSLog(@"%@", [s dataUsingEncoding:NSUTF8StringEncoding]); // nil
return 0;
}
You can’t perform that action at this time.