Skip to content

Instantly share code, notes, and snippets.

View wongzigii's full-sized avatar
🎯
Focusing

W0n9 wongzigii

🎯
Focusing
  • Loopring
View GitHub Profile
@couchdeveloper
couchdeveloper / SimpleGetHTTPRequest.h
Last active December 18, 2015 09:58
SimpleGetHTTPRequest This is a simple Objective-C class which wraps a `NSURLConnection` and relevant state information. It's meant to give an idea how one can implement a more "real" and more versatile connection class. It's deliberately kept simple.
//
// SimpleGetHTTPRequest.h
//
#import <Foundation/Foundation.h>
typedef void (^completionHandler_t) (id result);
@modocache
modocache / CompilationPerformance.md
Last active November 24, 2016 10:17
Graydon Hoare's advice on diagnosing compile performance, from https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20161031/003410.html

Compilation performance

This document describes a systematic method for detection, isolation, correction and prevention of regression, on matters of compiler performance. The method focuses on the creation of small end-to-end scaling tests that characterize, and stand in for, larger codebases on which the compiler is seen to perform poorly. These scaling tests have a number of advantages over "full sized" performance-testing codebases:

@binho
binho / magicalrecord_reset_coredata.m
Created April 2, 2015 19:48
MagicalRecord remove and reset CoreData
- (void)resetCoreData {
DDLogInfo(@"[RESET-COREDATA] Started.");
[MagicalRecord cleanUp];
NSURL *storeURL = [NSPersistentStore MR_urlForStoreName:kMobilStoreName];
NSURL *walURL = [[storeURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-wal"];
NSURL *shmURL = [[storeURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-shm"];
@lolgear
lolgear / CoreDataDatabaseCleanup.m
Created March 17, 2017 16:26
Core data database cleanup
/*
For example, you use Core Data sqlite.
It is necessary, because sqlite database stores data in single file.
Whole database is single file.
Now you have two options.
1. Delete all data from all tables
2. Delete database sqlite file
Second option is clean but complex.
@sharplet
sharplet / Actor.swift
Last active April 5, 2017 07:54
Simple GCD-based actors in Swift
import Dispatch
/// Wraps some `Base` type so that all method calls become
/// "message sends", e.g., `async { $0.foo() }` or `sync { $0.bar() }`.
public final class Actor<Base> {
private var instance: Base
private let queue: DispatchQueue
public init(_ instance: Base, target: DispatchQueue? = nil) {
self.instance = instance
//
// Signal+Extensions.swift
// Khan Academy
//
// Created by Nacho Soto on 10/1/15.
// Copyright © 2015 Khan Academy. All rights reserved.
//
import ReactiveCocoa
#!/usr/bin/env bash
# Automatically installs swiftenv and run's swiftenv install.
# This script was designed for usage in CI systems.
git clone --depth 1 https://github.com/kylef/swiftenv.git ~/.swiftenv
export SWIFTENV_ROOT="$HOME/.swiftenv"
export PATH="$SWIFTENV_ROOT/bin:$SWIFTENV_ROOT/shims:$PATH"
if [ -f ".swift-version" ] || [ -n "$SWIFT_VERSION" ]; then
swiftenv install -s
This was nice and fast... but it takes up WAY TOO MUCH space. And it's annoying to write.
(I like the way I can just step into the function that calls the delegate for debugging)
What's a better way to not make me call respondsToSelector in the middle of my code? Some proxy?
struct {
unsigned int delegateWillDisplayDocument:1;
unsigned int delegateDidDisplayDocument:1;
unsigned int delegateDidShowPageView:1;
unsigned int delegateDidRenderPageView:1;
@justjavac
justjavac / getAddressList_QQ.js
Last active October 18, 2020 07:27
获取QQ群通讯录
var ids = document.querySelectorAll(".member_id");
var names = document.querySelectorAll(".member_name");
var output = "", length = ids.length;
for(var i=0; i<length; i++){
output += ids[i].innerHTML.slice(1,-1) + ":" + names[i].innerHTML + "\n";
}
console.log(output);
@natecook1000
natecook1000 / VulgarFraction.swift
Created August 28, 2014 03:08
Vulgar Fractions
// (c) 2014 Nate Cook, licensed under the MIT License
/**
Returns a tuple with the closest compound fraction possible with Unicode's built-in "vulgar fractions".
See here: http://www.unicode.org/charts/PDF/U2150.pdf
:param: number The floating point number to convert.
:returns: A tuple (String, Double): the string representation of the closest possible vulgar fraction and the value of that string