Skip to content

Instantly share code, notes, and snippets.

View vitonzhangtt's full-sized avatar
😴
Be sleeping in the winter

vitonzhangtt

😴
Be sleeping in the winter
View GitHub Profile
@vitonzhangtt
vitonzhangtt / TTCounter.c
Last active January 5, 2018 03:14
Static variable definition in Header file
#include "TTCounter.h"
#include "TTDislikeCounter.h"
#include "TTLikeCounter.h"
void printTotalCounter() {
printf("total counter: %d", totalCounter);
}
int main(int argc, char *argv[]) {
addDislikeToTotalCounter();
@vitonzhangtt
vitonzhangtt / TTUserObject.h
Last active January 5, 2018 03:56
NSNotification
#import <Foundation/Foundation.h>
@interface TTUserObject : NSObject
- (void)postNicknameDidChangedNotification;
@end
@class TTUserObject;
@interface TTFriendsCollection : NSObject
- (void)addFriend:(TTUserObject *)user;
- (void)removeFriend:(TTUserObject *)user;
@end
@vitonzhangtt
vitonzhangtt / GCD_group.m
Last active August 20, 2018 15:08
How to use GCD group?
- (void)test_group {
dispatch_queue_t queue = dispatch_queue_create("diamond-queue", DISPATCH_QUEUE_CONCURRENT);
dispatch_group_t group = dispatch_group_create();
for (int i = 0; i < 10; i++) {
// dispatch_group_enter(group);
dispatch_sync(queue, ^{
dispatch_group_enter(group);
NSLog(@"i: [%@]__LINE__: %@", @(i), @(__LINE__));
@vitonzhangtt
vitonzhangtt / openssl-build.sh
Created November 9, 2018 10:21 — forked from foozmeat/openssl-build.sh
A shell script to build openssl for iOS and Mac. It currently builds: Mac -> i386 & x86_64 // iOS -> armv7, arm64 // iOS Simulator -> i386 & x86_64.
#!/bin/bash
# This script builds the iOS and Mac openSSL libraries
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
@vitonzhangtt
vitonzhangtt / find-string.sh
Created November 12, 2018 07:00
Find target string from the files that name match the expression.
#!/bin/bash
if [ $# -ne 3 ]; then
echo "The number of arguments must be 3"
exit 1
else
echo "Finding..."
fi
DIRECTORY=$1
@vitonzhangtt
vitonzhangtt / setupEnvForGoWorkspace.sh
Created August 25, 2019 09:25
Setup environment variables for Go Workspace
#! /bin/bash
###############################################
# Export env via shell script: source ./setupEnvShellScript.sh
# $source ./setupEnvForGoWorkspace.sh
#
################################################
################ Export GOPATH ##############
PWD=`pwd`
@vitonzhangtt
vitonzhangtt / DelegateProxyInternals.swift
Last active April 21, 2021 17:50
RxSwift Internals Serials: DelegateProxy
/// RxSwift/RxCocoa: 5.1.1
/// DelegateProxyType.swift
public protocol DelegateProxyType: class {
associatedtype ParentObject: AnyObject
associatedtype Delegate
/// ... ...
}
// default implementations
@vitonzhangtt
vitonzhangtt / BuildLog.md
Last active June 17, 2021 08:14
Build swift following the GettingStarted.md file

The log for building https://github.com/apple/swift

Commands

$ mkdir swift-project
$ cd swift-project/
$ ls -lt
$ git clone https://github.com/apple/swift.git swift
$ ls
@vitonzhangtt
vitonzhangtt / Options.inc
Created September 13, 2021 02:20
Options.inc for swift compiler
/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|* *|
|* Option Parsing Definitions *|
|* *|
|* Automatically generated file, do not edit! *|
|* *|
\*===----------------------------------------------------------------------===*/
/////////
// Prefixes