Skip to content

Instantly share code, notes, and snippets.

김정환 jeonghwan-kim

Block or report user

Report or block jeonghwan-kim

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jeonghwan-kim
jeonghwan-kim / is_installed.sh
Created Feb 16, 2017 — 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.
View is_installed.sh
#!/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 Jun 20, 2016 — forked from naholyr/_service.md
Sample /etc/init.d script
View _service.md

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)
View jekyll-pagination-links.html
View Gulpfile for Mocha & Node.js
// 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');
View add-multiple-column-in-sequelize-migration.js
module.exports = {
up: function (queryInterface, Sequelize) {
return [
queryInterface.addColumn('User', 'name', {
type: Sequelize.STRING
}),
queryInterface.addColumn('User', 'nickname', {
type: Sequelize.STRING,
})
];
View addColumn-with-fk-by-sequelize.js
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, {
View sanitize_filename_on_upload.php
<?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);
View morgan-helper.js
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',
View ng-pluralize.html
<ng-pluralize
count="remainingCount"
when="{ 0: 'No item', one: 'a item', other: '{} items' }">
</ng-pluralize>
View .jshinrc
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
You can’t perform that action at this time.