Skip to content

Instantly share code, notes, and snippets.

View caasi's full-sized avatar
🏝️
Spiritual Homeland

Isaac Huang caasi

🏝️
Spiritual Homeland
View GitHub Profile
@tomchentw
tomchentw / handleDoOnce.js
Last active August 29, 2015 14:23
handleDoOnce.js
// 可能可以改寫成這樣:
LocationsFetcher.fetchLastResult = null;
LocationsFetcher.fetch = () =>
if (LocationsFetcher.fetchLastResult) {
return Promise.reject(new AlreadyCalledError());
} else {
return LocationsFetcher.fetchLastResult = doFetchInternal();
}
};
大哉問,但是我覺得我沒辦法正面回答。
在《人月神話》裡面有提到軟體開發的一個現象,
就是軟體越大,維護越困難(廢話)。
這是因為初期的設計不可能考慮到後期的需求,
所以增加新功能,要顧慮到所有與原有設計接合的部份,
所以增加一個新功能的成本,跟這個軟體的規模成正比。
也就是說,當軟體規模是 10 的時候,加一個新功能成本的 10。
@kcwu
kcwu / pack.py
Last active December 21, 2015 12:09
pack strokes
"""
run: pack unpack diff
pack:
python pack.py pack > strokes.bin
gzip -kf strokes.bin
ls -l strokes.bin*
unpack:
gzip -dc < strokes.bin.gz | python pack.py unpack > strokes.unpacked
while (!targetUnit.IsDead()) {
actor.animation.Play("run");
while (Vector3.Distance(actor.transform.position, target.transform.position) > actorUnit.attackRange) {
actorUnit.MoveTo(target.transform.position);
yield return null;
}
while (Vector3.Angle(actor.transform.forward, target.transform.position - actor.transform.position) > 10) {
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
// JobManager is just a proxy object so we have a launcher for the coroutines
public class JobManager : Singleton<JobManager> {}
public class Job
{
public event System.Action<bool> jobComplete;
@statianzo
statianzo / current.js
Last active August 30, 2016 13:47
unknown props warning
const ContactBadge = (props) => (
<div className='Badge' {...props}>
<div>{props.user.name}</div>
<div>{props.contactMethod.type}</div>
</div>
);
export default connect((state, {userId, contactMethodId}) => ({
user: selectUser(state, userId),
contactMethod: selectContactMethod(state, contactMethodId)
@jlongster
jlongster / forms-with-react.js
Last active May 8, 2017 14:15
higher-order form components w/react
// Simple wrapper to use bootstrap's grid system to position elements side-by-side
var VerticalFieldsElement = React.createClass({
render: function() {
return dom.div(
{ className: 'clearfix' },
React.Children.map(this.props.children, function(child) {
if(!child) {
return child;
}

Requirements

  • hareware: GCE g1-small instance (1 vCPU, 1.7 GB memory), about $15/mo

  • software (Archlinux):

sudo pacman -Sy nginx certbot docker docker-compose

# optional tools
34. to/lo po/lo' i/ra ko se/pat.
Mi/sa/lof,
Mi/sa/nga’,
Mi/pa/la/sa/wad to
Ma/le/ka/ya/tay to/na Ri/ke/c
O ci/to/do/ngay a
mi/ko/wa/nay i,
i la/lo/ma’ no
to/lo a mih/ca/an
@PkmX
PkmX / loeb.md
Last active January 9, 2019 15:59
Löb with error handling

Löb with error handling

löb is a well-known function in Haskell for implementing spreadsheet-like behaviors and tying the knot. It is defined as:

loeb :: Functor f => f (f a -> a) -> f a
loeb fs = xs
  where xs = fmap ($ xs) fs