Skip to content

Instantly share code, notes, and snippets.

View jeonghwan-kim's full-sized avatar

김정환 jeonghwan-kim

View GitHub Profile
@jeonghwan-kim
jeonghwan-kim / index.html
Created May 21, 2022 08:34
react strict mode
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>React strict mode test</title>
</head>
<body>
<div id="app"></div>
@jeonghwan-kim
jeonghwan-kim / generateHashLikeId.ts
Last active May 18, 2022 00:33
Generate hash-like id
const createId = (text = Date.now().toString().substring(0, 10)) => {
const m = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]; // 0 ~ 9
let hash = "";
for (let i = 0; i < text.length; i++) {
if (i > 6) {
hash += text[i];
} else {
hash += m[Number(text[i])];
}
@jeonghwan-kim
jeonghwan-kim / is_installed.sh
Created February 16, 2017 02:09 — forked from JamieMason/is_installed.sh
Check if a program exists from a bash script. Thanks to twitter.com/joshnesbitt and twitter.com/mheap for the help with detecting npm packages.
#!/bin/bash
# Functions ==============================================
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1
@jeonghwan-kim
jeonghwan-kim / _service.md
Created June 20, 2016 02:19 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@jeonghwan-kim
jeonghwan-kim / jekyll-pagination-links.html
Created February 11, 2016 13:11
jekyll-pagination-links.html
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var mocha = require('gulp-mocha');
module.exports = {
up: function (queryInterface, Sequelize) {
return [
queryInterface.addColumn('User', 'name', {
type: Sequelize.STRING
}),
queryInterface.addColumn('User', 'nickname', {
type: Sequelize.STRING,
})
];
module.exports = {
up: function (queryInterface, Sequelize) {
// raw query
// add column and foreign key constrant
var sql = "ALTER TABLE `Friend`" +
" ADD COLUMN `UserId` BIGINT(20) UNSIGNED DEFAULT NULL" +
", ADD CONSTRAINT `fkUserIdInFriend` FOREIGN KEY (`UserId`) REFERENCES `User` (`id`) ON UPDATE CASCADE ON DELETE RESTRICT";
// run the query
return queryInterface.sequelize.query(sql, {
<?php
function sanitize_filename_on_upload($filename) {
$ext = end(explode('.', $filename));
// Replace all weird characters
$sanitized = preg_replace('/[^a-zA-Z0-9-_.]/', '_', substr($filename, 0, -(strlen($ext)+1)));
// Replace dots inside filename
$sanitized = str_replace('.', '-', $sanitized);
var morgan = require('morgan');
/**
* morgan wrapper
* @returns {morgan}
*/
module.exports = function setLogger() {
// http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
var red = '\x1B[31m',
green = '\x1B[32m',