Skip to content

Instantly share code, notes, and snippets.

@yllan
yllan / nginx.conf
Created February 5, 2013 07:55
設定 nginx 使用 server sent event
location xxxx {
proxy_pass http://localhost:9000;
proxy_buffering off;
proxy_cache off;
proxy_redirect off;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
//
// Signer.swift
// Sign
//
// Created by Yung-Luen Lan on 2018/8/17.
// Copyright © 2018 yllan. All rights reserved.
//
import Foundation
This file has been truncated, but you can view the full file.
2 1
4 1
6 2
8 1
12 3
16 1
24 4
30 6
32 1
36 6
@yllan
yllan / merge.cpp
Created May 16, 2022 14:22
merge two lists
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };
*/
@yllan
yllan / im.txt
Created December 24, 2021 02:44
Inside Macintosh URL
https://developer.apple.com/library/archive/documentation/mac/pdf/Text.pdf
https://developer.apple.com/library/archive/documentation/mac/pdf/MoreMacintoshToolbox.pdf
https://developer.apple.com/library/archive/documentation/mac/pdf/MacintoshToolboxEssentials.pdf
https://developer.apple.com/library/archive/documentation/mac/pdf/ResEditReference.pdf
https://developer.apple.com/library/archive/documentation/mac/pdf/ImagingWithQuickDraw.pdf
https://developer.apple.com/library/archive/documentation/mac/pdf/MacOS_RT_Architectures.pdf
https://developer.apple.com/library/archive/documentation/mac/pdf/Processes/Vertical_Retrace_Mgr.pdf
https://developer.apple.com/library/archive/documentation/mac/pdf/Sound/Sound_Input_Manager.pdf
https://developer.apple.com/library/archive/documentation/mac/pdf/Networking/DDP.pdf
https://developer.apple.com/library/archive/documentation/mac/pdf/Operating_System_Utilities/PRAM_Utilities.pdf
@yllan
yllan / machine.js
Last active November 5, 2021 06:28
Generated by XState Viz: https://xstate.js.org/viz
const IDX = {
VHS: { P2: 6, P3: 7, P4: 8, P5: 9, P6: 10 }
}
const nudgePoints = (elementIndexes) => assign((ctx, evt) => {
const [x, y] = [evt.clientX, evt.clientY]
const [sx, sy] = ctx.lastClientPoint
const [dx, dy] = [x - sx, y - sy]
const paths = elementIndexes.map(idx => [0, ctx.groupIndex, idx])
ctx.editorMethods.nudgeElementsAtPath(dx, dy, paths)
return { ...ctx, lastClientPoint: [x, y] }
@yllan
yllan / machine.js
Created October 12, 2021 09:54
Generated by XState Viz: https://xstate.js.org/viz
const pinchMachine = Machine({
id: 'pinch',
initial: 'idle',
context: {
onPinch: () => {},
onPan: ([dx, dy]) => {},
finishPinch: () => {},
onSingleTouch: {
touchStart: (currentPoint) => {},
touchMove: (currentPoint) => {},
@yllan
yllan / std-variant.md
Last active February 17, 2021 04:00
std::variant

std::variant 是 C++ 的 sum type

在 C++17 後要 sum type 可以這樣用:

#include<variant>

// data Solution = Surface Vector3 Double |
//                 Line Vector3 Vector3 |
// Copyright (c) the JPEG XL Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@yllan
yllan / main.swift
Created May 14, 2020 14:43
ShitWeb
//
// main.swift
// ShitWeb
//
// Created by Yung-Luen Lan on 2020/5/14.
// Copyright © 2020 Yung-Luen Lan. All rights reserved.
//
import Foundation
import Network