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;