Skip to content

Instantly share code, notes, and snippets.

View hayeah's full-sized avatar
🕳️
Focusing

blah blah hayeah

🕳️
Focusing
View GitHub Profile
@hayeah
hayeah / gist:dfd39e45dc933a98fb25
Created January 12, 2015 06:40
async example
var n; // a global counter of how many requests hand been processed
var a = [1,2,3,4,5,6,7];
// a handler that increments `n`, and print out each element in a.
function countHandler(req,res,next) {
// these are new for each request, don't need to protect them.
var a,b,c;
// an asynchronous loop that print out each element in an array
var i = 0; // this loop would break if you move it outside of the countHandler scope.
@hayeah
hayeah / objc-msg-x86_64.c
Last active October 27, 2018 13:17
objective C objc_msgSend assembly
/*
* Copyright (c) 1999-2007 Apple Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
@hayeah
hayeah / gist:38cee042d4dcb8c30dee
Last active August 29, 2015 14:06
Card model
//
// Card.swift
// MatchPairs
//
// Created by Howard Yeh on 2014-09-03.
// Copyright (c) 2014 Howard Yeh. All rights reserved.
//
import UIKit
@hayeah
hayeah / gist:3706990213771b344edd
Last active August 29, 2015 14:06
Layout patterns of PairsMatching Game
// Compiler/SourceKit Bug in [6A1052c]: Omit the `[[Int]]` type annotation seems to trigger polynomial/exponential run-time in the type analyzer.
// 9 elements takes about a minute to compile on my low-end MBP.
private let gameLayouts: [[Int]] = [
[0,0,0,0,
0,0,0,0,
0,1,1,0,
0,0,0,0,
0,0,0,0],
[0,0,0,0,
@hayeah
hayeah / gist:4c28d79329c3f534b2ae
Created September 15, 2014 06:05
set xcode windows dimensions
(*
Set xcode window dimension
*)
set theApp to "Xcode6-Beta6"
set width to 1400
set height to 900
@hayeah
hayeah / gist:a8d75339a61ae37ceb55
Last active August 29, 2015 14:02
NodeJS Bootcamp 抽奖程序
weibo = [...] # 所有转发的微博用户
email = [...] # 所有 v2ex 留帖的用户

all = weibo + email

# 随机选两个,打印
i = rand(all.length)
p all.delete_at(i)
i = rand(all.length)
@hayeah
hayeah / gist:8e98cb08d1a12e87159d
Last active July 13, 2021 06:57
NodeJS Express 训练营课程安排

暖身周 (可选)

  • 写一个简单的 NPM package
  • 用 mocha 写测试
  • 用 CoffeeScript 写 NPM package
  • 实现 JS 类 (练习原型链)

第一周 - Connect Middleware

@hayeah
hayeah / gist:319aa17754093c05002e
Created June 10, 2014 08:38
NodeSchool Chengdu Announcement

【成都社区活动】 NodeSchool Workshop 六月七号(周六)

NodeSchool

NodeJS 是现在最热门的 JavaScript 后端框架。你对 NodeJS 有兴趣但一直没机会深度接触吗?

  • 你是前端或者移动端开发,想学写简单的后台服务
  • 你是后台开发,想尝试用异步框架写高并发服务
  • 你是学生,想学些学校没教的新技术,想认识社区的一些牛人
@hayeah
hayeah / gotcha.go
Created May 26, 2014 12:02
Golang go Pointer Gotcha
package main
import (
"fmt"
"time"
)
type foo struct {
i int
}
@hayeah
hayeah / gist:9757971
Created March 25, 2014 09:22
coffeescript __extend helper for defining subclass
__extends = function(child, parent) {
for (var key in parent) {
if (__hasProp.call(parent, key)) child[key] = parent[key];
}
function ctor() {
// why set the prototype's constructor to child?
this.constructor = child;
}
ctor.prototype = parent.prototype;
child.prototype = new ctor;