Skip to content

Instantly share code, notes, and snippets.

View ytlvy's full-sized avatar

Yt ytlvy

View GitHub Profile
@ytlvy
ytlvy / array.m
Created February 28, 2016 14:48 — forked from markd2/array.m
On-demand Objective-C message tracing
#import <Foundation/Foundation.h>
// clang -g -fobjc-arc -framework Foundation -o array array.m
void observeObject (id objectToWatch) {
// Just a stub to give DTrace something to hook in to.
}
int main (void) {
@autoreleasepool {
@ytlvy
ytlvy / The Technical Interview Cheat Sheet.md
Created February 16, 2016 08:12 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@ytlvy
ytlvy / iOS 技能图谱.md
Created February 16, 2016 06:02 — forked from tangqiaoboy/iOS 技能图谱.md
iOS 技能图谱

编程语言

  • Swift
  • Objective-C
  • C++/C
  • JavaScript

操作系统

  • Mac OSX
  • iOS
@ytlvy
ytlvy / UIButton+Block.h
Created February 1, 2016 07:07 — forked from joshdholtz/UIButton+Block.h
iOS - UIButton+Block
//
// UIButton+Block.h
// BoothTag
//
// Created by Josh Holtz on 4/22/12.
// Copyright (c) 2012 Josh Holtz. All rights reserved.
//
#define kUIButtonBlockTouchUpInside @"TouchInside"
@ytlvy
ytlvy / UIButton+EventBlocks.h
Created February 1, 2016 06:48 — forked from jancassio/UIButton+EventBlocks.h
Simple UIButton Category to Support Event Blocks
// The MIT License (MIT)
// Copyright (c) 2014 Jan Cássio
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@ytlvy
ytlvy / string_contains_emoji
Created January 25, 2016 02:34 — forked from cihancimen/string_contains_emoji
Check if an NSString contains an emoji character
- (BOOL)stringContainsEmoji:(NSString *)string {
__block BOOL returnValue = NO;
[string enumerateSubstringsInRange:NSMakeRange(0, [string length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:
^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
const unichar hs = [substring characterAtIndex:0];
// surrogate pair
if (0xd800 <= hs && hs <= 0xdbff) {
if (substring.length > 1) {
const unichar ls = [substring characterAtIndex:1];
@ytlvy
ytlvy / ArrowLayer.h
Created January 19, 2016 02:08 — forked from mayoff/ArrowLayer.h
A CALayer subclass that draws a very simple arrow
#import <QuartzCore/QuartzCore.h>
@interface ArrowLayer : CALayer
@property (nonatomic) CGFloat thickness;
@property (nonatomic) CGFloat startRadians;
@property (nonatomic) CGFloat lengthRadians;
@property (nonatomic) CGFloat headLengthRadians;
@property (nonatomic, strong) UIColor *fillColor;
@ytlvy
ytlvy / signals.d
Created January 5, 2016 04:37
Execnames in DTrace (and signal monitoring)
/* ps -axco "pid= comm=" | awk '{printf "pnames[%s]", $1; $1=""; sub(/^ /, "", $0); printf " = \x22%s\x22;\n", $0}' > /tmp/pnames.h; sudo dtrace -C -I/tmp -s signals.d */
#pragma D option quiet
dtrace:::BEGIN
{
#include "pnames.h"
snames[0] = "_QUERY_";
snames[1] = "SIGHUP";
.section __TEXT,__text,regular,pure_instructions
.globl _insert
.align 4, 0x90
_insert: ## @insert
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp2:
.cfi_def_cfa_offset 16
Ltmp3:
@ytlvy
ytlvy / gist:43ffa864bd72ce898c84
Created January 5, 2016 04:34
Example of copyfile() progress via COPYFILE_STATE_COPIED
#include "copyfile.h"
typedef enum {
_NotStarted = 0,
_InProgress,
_Finished,
} _State;
@implementation BAVAppDelegate
{