Skip to content

Instantly share code, notes, and snippets.

View wan2land's full-sized avatar
๐Ÿ‘พ

Changwan Jun wan2land

๐Ÿ‘พ
View GitHub Profile
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Hello world!</h1>
<script src="script.js"></script>
function applyStrokeOptions(ctx, options = {}) {
ctx.setLineDash(options.dash || [])
ctx.lineWidth = options.width || 1
ctx.strokeStyle = options.color || '#000000'
}
function applyFillOptions(ctx, options = {}) {
ctx.fillStyle = options.color || '#000000'
}
export function average(...points) {
if (points.length === 0) {
return { x: 0, y: 0 }
}
return {
x: points.reduce((carry, p) => carry + p.x, 0) / points.length,
y: points.reduce((carry, p) => carry + p.y, 0) / points.length,
}
}
function stringify(value) {
if (value === null) {
return "null"
}
if (typeof value === "number") {
return `${value}`
}
if (typeof value === "boolean") {
return value ? "true" : "false"
}
@wan2land
wan2land / re-infinity-nan-stringify.js
Last active February 18, 2019 10:00
medium-json-parser-1
const obj = {
ย  isregexp: /email/,
ย  isinfinity: Infinity,
ย  isninfinity: -Infinity,
ย  isnan: NaN,
}
JSON.stringify(obj) // '{"isregexp": {}, "isinfinity":null,"isninfinity":null,"isnan":null}
@wan2land
wan2land / mixin.ts
Created August 1, 2018 02:41
Typescript mixin
type ConstructType<P> = {new (...args: any[]): P}
function mixer<P, L>(parentCtors: ConstructType<P>, childCtors: ConstructType<L>): ConstructType<P & L> {
const result: any = class extends (parentCtors as any) {}
Object.getOwnPropertyNames(childCtors.prototype)
.forEach(name => result.prototype[name] = childCtors.prototype[name])
return result
}
@wan2land
wan2land / markdown.md
Last active May 20, 2019 06:56
markdown.md

์–ด๋–ป๊ฒŒ ๋‚˜์˜ค์ง€

  1. ํ•˜ํ•˜ํ•˜
// ์˜ˆ์‹œ์ฝ”๋“œ์—์šค
  1. ํ˜ธํ˜ธํ˜ธ

Annotation (feat. Reflection)

๋ฌด์—‡์ธ๊ฐ€?

  1. ๋ฉ”ํƒ€ํ”„๋กœ๊ทธ๋ž˜๋ฐ ํ•  ๋•Œ ํ•„์š”ํ•œ ๊ทธ๊ฑฐ. ย  ย - ์ž์„ธํ•œ ์„ค๋ช…์€ ๊ฒ€์ƒ‰์„.. ์–ด๋””์— ํ™œ์šฉํ•˜๋ฉด ์ข‹์„์ง€๋Š” ํ•จ๊ป˜ ๊ณ ๋ฏผํ•ด๋ณด์•„์š”.
  2. ์ž๋ฐ”์— ์žˆ๋Š” ๊ทธ๊ฑฐ.
@wan2land
wan2land / faker-bash.php
Last active November 9, 2015 10:15
bash command record and play
#!/usr/bin/env php
<?php
if (!isset($argv[1])) {
$mode = 'record';
} else if (in_array($argv[1], ['record', 'play'])) {
$mode = $argv[1];
} else {
fwrite(\STDERR, "first parameter must be record or play.\n");
exit(-1);
}
@wan2land
wan2land / nginx-laravel.dev
Created November 1, 2015 11:33
Nginx laravel
server {
listen 8080;
server_name laravel.dev;
root /var/www;
access_log /usr/local/etc/nginx/logs/$host.access.log;
location / {
include /usr/local/etc/nginx/conf.d/php-fpm;
try_files $uri $uri/ /index.php?$query_string;