Skip to content

Instantly share code, notes, and snippets.

const _ = {
uniq: require("lodash/uniq"),
unzip: require("lodash/unzip")
};
module.exports.decompileRoutePath = function decompileRoutePath(paths, ids) {
const parsedPaths = paths.map(path =>
path.replace(/^\/+|\/+$/g, "").split("/")
);
if (
#!/bin/bash
git config --system alias.a "!git add . && git status" &&
git config --system alias.aa "!git add . && git add -u . && git status" &&
git config --system alias.ac "!git add . && git commit" &&
git config --system alias.acm "!git add . && git commit -m" &&
git config --system alias.alias "!git config --list | grep 'alias\.' | sed 's/alias\.\([^=]*\)=\(.*\)/\1\ => \2/' | sort" &&
git config --system alias.au "!git add -u . && git status" &&
git config --system alias.c "commit" &&
git config --system alias.ca "commit --amend" &&
git config --system alias.cm "commit -m" &&
export default new Proxy({}, {
set(target, property, value) {
if (property === 'render') {
target[property] = function (h, vm) {
return value(h, vm);
};
} else {
target[property] = value;
}
return value;
async function parseOrientation(blob) {
const APP1_MARKER = 0xffe1;
const EXIF_HEADER = Array.from("Exif")
.map((c) => c.charCodeAt())
.reverse()
.reduce(
(accumulator, charCode, index) =>
accumulator + charCode * 16 ** (index * 2)
);
const INTEL_BYTE_ALIGN = 0x4949;
polyfill();
const browser = (() => {
let cantRotate = null;
return {
get cantRotate() {
return new Promise(async (resolve, reject) => {
if (cantRotate === null) {
try {
const image = Object.assign(new Image(), {
export default {
bind,
update,
};
const debouncedAutoRowsHandler = debounce(autoRowsHandler);
function bind(el, binding) {
if (!(el instanceof HTMLTextAreaElement)) {
throw new TypeError("element should be instance of HTMLTextAreaElement");
@sungchuni
sungchuni / parseJasmineJestMatchers.js
Last active August 27, 2020 16:32
diff matchers of jasmine and jest
main();
async function main() {
const [jasmines, jests] = await Promise.all([parseJasmine(), parseJest()]);
[jasmines, jests].forEach(mutateSorted);
createTable({jasmines, jests});
}
async function parseJasmine() {
const results = await Promise.all(
function setMockDate() {
class MockedDate extends Date {
constructor(...args) {
const [firstArg, ...restArgs] = args;
firstArg === undefined
? super("2020-09-01T12:00:00.000+09:00", ...restArgs)
: super(...args);
}
}
const {Date: ProperDate} = globalThis;
@sungchuni
sungchuni / PostPositionPipe.ts
Last active December 22, 2020 06:16
for Angular
import { Pipe, PipeTransform } from "@angular/core";
@Pipe({name: "postPositionPipe"})
export class PostPositionPipe implements PipeTransform {
private readonly CHAR_CODE_가 = 44032;
private readonly CHAR_CODE_힣 = 55203;
private isKoreanCharCode(charCode: number): boolean {
return charCode >= this.CHAR_CODE_가 && charCode <= this.CHAR_CODE_힣;
}
function getSamples(length) {
const array = Array.from(this || []);
const sampleLength = Math.min(length, array.length);
const result = [];
while (result.length < sampleLength) {
const draw = Math.random() * array.length;
const sample = array.splice(draw, 1).shift();
result.push(sample);
}
return result;