Skip to content

Instantly share code, notes, and snippets.

View harryworld's full-sized avatar
🏠
Working from home

Harry Ng harryworld

🏠
Working from home
  • Hong Kong
View GitHub Profile
//
// Regex.swift
//
extension String {
public var byStrippingFormatCharacters: String {
var result = self
// #H1, #H2
Regex.headerRegex.matches(in: result, options: [], range: NSMakeRange(0, result.count)).forEach {
@harryworld
harryworld / CityGuideWeb.md
Last active January 22, 2018 09:50
Overview of City Guide Website

City Guide Website

Summary

City Guide is a navigation map for Art Events and Spaces around the World. User can subscribe

Aim of this Project

Extend City Guide to web-based environment, where event organizers can post events to this platform.

@harryworld
harryworld / NSCollectionView.swift
Created August 17, 2016 14:26
Animate NSCollectionViewItem during dragging
func collectionView(collectionView: NSCollectionView, draggingSession session: NSDraggingSession, willBeginAtPoint screenPoint: NSPoint, forItemsAtIndexPaths indexPaths: Set<NSIndexPath>) {
if let indexPath = draggingIndexPaths.first,
item = collectionView.itemAtIndexPath(indexPath) {
draggingItem = item // draggingItem is temporary instance variable of NSCollectionViewItem
}
}
func collectionView(collectionView: NSCollectionView, draggingSession session: NSDraggingSession, endedAtPoint screenPoint: NSPoint, dragOperation operation: NSDragOperation) {
draggingItem = nil
@harryworld
harryworld / CABasicAnimation.swift
Last active August 10, 2016 14:21
Comparing iOS vs macOS animation
func animateView() {
CATransaction.begin()
CATransaction.setCompletionBlock { [unowned self] in
self.removeFromSuperview()
}
let rotationAtStart = view.layer?.valueForKeyPath("transform.rotation.x") as? NSNumber
let rotate = CABasicAnimation(keyPath: "transform.rotation.x")
rotate.duration = 0.3
#if os(iOS)
import Cocoa
public struct HNColor {
public static var DarkGray: UIColor = UIColor(white: 36/255, alpha: 1)
public static var DeepGray: UIColor = UIColor(white: 27/255, alpha: 1)
}
#endif
#if os(OSX)
import Cocoa
#endif
#if os(iOS)
import UIKit
#endif
# Uncomment this line to define a global platform for your project
platform :osx, '10.11'
use_frameworks!
target 'AppName' do
end
target 'AppNameTests' do
//
// ShiftClickGestureRecognizer.swift
//
// Created by Harry Ng on 27/1/2016.
// Copyright © 2016 STAY REAL. All rights reserved.
//
import Cocoa
class ShiftClickGestureRecognizer: NSClickGestureRecognizer {
@harryworld
harryworld / sorting.md
Last active August 29, 2015 14:10
Sorting Algorithm

Sort the following sequence

[69,81,30,38,9,2,47,61,32,79]

Some common sorting algorithms