Skip to content

Instantly share code, notes, and snippets.

View GUIEEN's full-sized avatar
💭
美しい未来に

Seung Kwak GUIEEN

💭
美しい未来に
  • tokyo
View GitHub Profile
@GUIEEN
GUIEEN / getAllFilesInDir.js
Last active January 3, 2019 13:59
Get all files recursively in the specific directory
import path from 'path'
import fs from 'fs'
let targetPath = path.resolve(__dirname, '../')
let files: string[] = []
const ignore = {
'src/copyFolder.ts': true,
'src/starter.ts': true,
'.git': true,
@GUIEEN
GUIEEN / animateLoading.js
Last active January 3, 2019 16:04
Animate loading message in console.log
const twirlTimer = function () {
let P = ['\\', '|', '/', '-']
let x = 0
return setInterval(function () {
process.stdout.write('\r' + P[x++])
x &= 3
}, 250)
}
const animateLoading = function (fullLength: number, current: number = 0) {
@GUIEEN
GUIEEN / colorConsoleMsg.js
Created January 3, 2019 16:12
Stdout message with color.
import colors from 'colors'
const log = (...args: Object[]) => {
args.forEach(e => {
if (typeof e === 'object') {
console.dir(e, { depth: null })
} else if (typeof e === 'boolean') {
console.log(colors.bgMagenta.white(` ${e} `))
} else {
console.log(colors.bgCyan.black(` ${e} `))
}
@GUIEEN
GUIEEN / copyFolder.js
Last active January 3, 2019 19:34
copy folder recursively
import fs from 'fs'
import path from 'path'
function copyFileSync (source, target) {
let targetFile = target
// if target is a directory a new file with the same name will be created
if (fs.existsSync(target)) {
if (fs.lstatSync(target).isDirectory()) {
@GUIEEN
GUIEEN / streamReader.js
Last active January 6, 2019 10:03
Use a stream to parse data
import fs from 'fs'
import Stream from 'stream'
import { StringDecoder } from 'string_decoder'
import through from 'through2'
const string = `
Bright Black 90 100 85,85,85 128,128,128 128,128,128 129,131,131 85,85,85 127,127,127 127,127,127 128,128,128
Bright Red 91 101 255,85,85 255,0,0 255,0,0 252,57,31 255,85,85 255,0,0 255,0,0 255,0,0
`
@GUIEEN
GUIEEN / GithubAPI_Repo.md
Last active January 13, 2019 20:04
GithubAPI_Repo

Github API

  1. Repository
    1. Get
      1. All
        1. /user/repos
          1. public && private Repositories of the authenticated user
          2. type= owner, public, private, member
          3. sort = created, updated, pushed, full_name
        2. /users/:username/repos
function uuid()
{
var seed = Date.now();
if (window.performance && typeof window.performance.now === "function") {
seed += performance.now();
}
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (seed + Math.random() * 16) % 16 | 0;
seed = Math.floor(seed/16);
@GUIEEN
GUIEEN / restart_bluetooth.sh
Created March 24, 2019 01:40 — forked from nicolasembleton/restart_bluetooth.sh
Restart Bluetooth Daemon on Mac OS X without restarting
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport