Skip to content

Instantly share code, notes, and snippets.

@xareelee
xareelee / DismissKeyboardWhenTappingContentView.md
Last active August 29, 2015 14:26
Dismiss keyboard when tapping table view (or content view) using ReactiveCocoa
- (void)viewDidLoad
{
  [super viewDidLoad];
  @weakify(self);
  
  // Add a gesture recognizer to a view
  UITapGestureRecognizer *tap = [UITapGestureRecognizer new];
  [tap.rac_gestureSignal subscribeNext:^(id x) {
 @strongify(self);
@xareelee
xareelee / UIButton+RACSupportForTitle.md
Last active November 25, 2016 03:56
Use RAC() macro for binding a UIButton title

You can't use RAC() directly on a UIButton because of the UIKit design:

RAC(self.button.titleLabel, text) = titleSignal;  // Don't do this.

One of the solutions is using dynamic property to support RAC() binding macro:

// .h
@xareelee
xareelee / DeallocTracker.m
Created August 4, 2015 03:01
Track deallocated object for specific classes using XAspect
// Just copy the fllowing code into a .m file, and include the XAspect to you project.
// Then you'll see console log messages when objects of specific classes were deallocated.
// The block `AspectPatch(-, void, dealloc)` will be invoked just before `-dealloc` aka 'before advise'.
// Using XAspect
#import <XAspect/XAspect.h>
// Headers for classes you want to track
#import <CMDPUserLogin/UAMLoginViewController.h>
#import <CMDPUserLogin/UAMLoginTableViewController.h>
@xareelee
xareelee / NSObject+PropertyName.h
Last active May 2, 2019 13:43
Objective-C property name to a string with autocompletion and compile-time check
// Release under MIT
// Copyright (C) 2015 Xaree Lee
#import <Foundation/Foundation.h>
/* Get property name for the class (C string or NSSting). */
#define keypathForClass(Klass, PropertyName) \
(((void)(NO && ((void)[Klass _nullObjectForCheckingPropertyName].PropertyName, NO)), # PropertyName))
#define keypathStringForClass(Klass, PropertyName) \
@keypathForClass(Klass, PropertyName)
@xareelee
xareelee / gist:6e6a2a466958286718f5a272379166f5
Last active May 27, 2016 08:21 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

參考並 fork saetia's gist 的工作安裝教學,更多內容可以參考 Awesome OSX

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
@xareelee
xareelee / sublime_steup.md
Last active June 17, 2016 05:50
Sublime setup for React Native

Sublime 是個簡單,強大,跨平台的編輯器。這邊介紹開發 ReactNative 時的設置。

Sublime Text 3

下載 Sublime Text 3

安裝 Package Controller (for Sublime)

@xareelee
xareelee / learn_meteor_phase_1.md
Last active June 9, 2023 17:05
如何學習 Meteor.js (第一階段)

如何學習 Meteor.js (第一階段)

Meteor 是一個 full-stack 的開發框架 (或者該說是平台),它可以利用一種語言 (JavaScript) 來輕鬆完成前後端的開發。是目前前景看好的選擇。

本階段的目標是:

  • 了解 Meteor 是什麼樣的平台,基本架構,可以做到什麼樣的事情 (2.5 hr)
  • 能夠自己獨立完成一個 Meteor 的 ToDo App (不斷的練習一樣的 App,直到完全熟悉,+10 hr)

這階段大約花 10-20 hr,可以利用一個週末的兩天時間,或是一個禮拜的晚上來完成。

@xareelee
xareelee / UCC_design_introduction.md
Last active September 11, 2018 20:13
A better async/reactive function design in JS (or any other languages) — the Universal Currying Callback (UCC) Design

A better async/reactive function design in JS (or any other languages) — the Universal Currying Callback (UCC) Design

For the principle "Don't call us, we'll call you", the modern function design uses callbacks, Promise, or monad/stream-based techniques (e.g. Rx) to let you subscribe the async results.

The following is a usual JS function implementation using the callback for async:

function register(username, password, email, callback) {
 // processing async work
[tool.poetry]
name = "pythonpro"
version = "0.1.0"
description = ""
authors = ["Hello <[email protected]>"]
[tool.poetry.dependencies]
python = "^3.10"
[tool.poetry.dev-dependencies]
@xareelee
xareelee / VSCode等寬中文字解決方案.md
Last active April 28, 2022 03:01
VSCode等寬中文字的問題

VSCode 想等個寬,太難了 (借用標題)

緣由 (是個古老的坑):

  • VSCode 的等寬字,在中英文會有排版不對齊的問題。這在寫 markdown Table 時,會有嚴重跑版的問題。
  • 問題是來自於 VSCode 是用 Electron 開發,也就是介面顯示是由 Chromium 渲染導致 (Chromium 對中文等寬字渲染不對齊的 bug)。
  • 目前沒看到有人修正這個根本性問題;目前的 workaround,就是改用能夠使中英文保持 2:1 等寬的字型。

來找個可用字型 (繼續排坑):