Skip to content

Instantly share code, notes, and snippets.

View jeonghwan-kim's full-sized avatar

김정환 jeonghwan-kim

View GitHub Profile
module.exports = {
up: function (queryInterface, Sequelize) {
return [
queryInterface.addColumn('User', 'name', {
type: Sequelize.STRING
}),
queryInterface.addColumn('User', 'nickname', {
type: Sequelize.STRING,
})
];
@jeonghwan-kim
jeonghwan-kim / detect-mobile-devices.php
Created October 14, 2013 01:48
Detect mobile devices such as iPhone, android phone.
<?php
//Detect devices
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
if ( $Android )
echo 'Android';
else if ( $iPod || $iPhone || $iPad )
@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 / delete-aws-s3.js
Created March 17, 2014 11:08
delete object in S3
var aws = require('aws-sdk');
var BUCKET = 'node-sdk-sample-7271';
aws.config.loadFromPath(require('path').join(__dirname, './aws-config.json'));
var s3 = new aws.S3();
var params = {
Bucket: 'node-sdk-sample-7271',
Delete: { // required
Objects: [ // required
{
@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 / my-winston.js
Last active May 2, 2018 09:59
usage of winston
// set timezone
process.env.TZ = 'Asia/Seoul';
// winston object
var winston = require('winston');
var logger = new (winston.Logger)({
transports: [
new (winston.transports.File)({
filename: 'error.log',
json: false,
@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 / gist:a3932b62d74cbcb452e2
Created April 2, 2015 08:31
$anchorScroll example
'use strict';
angular.module('myApp')
.controller('FaqCtrl', function ($scope, $location, $anchorScroll) {
$scope.scrollTo = function(id) {
$location.hash(id);
$anchorScroll();
}
});
@jeonghwan-kim
jeonghwan-kim / jekyll-pagination-links.html
Created February 11, 2016 13:11
jekyll-pagination-links.html