This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var winston = require( 'winston' ), | |
fs = require( 'fs' ), | |
logDir = 'log', // Or read from a configuration | |
env = process.env.NODE_ENV || 'development', | |
logger; | |
winston.setLevels( winston.config.npm.levels ); | |
winston.addColors( winston.config.npm.colors ); | |
if ( !fs.existsSync( logDir ) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services.factory('socket', function ($rootScope) { | |
'use strict'; | |
var socket; | |
var connect = function(){ | |
if(!socket){ | |
socket = io.connect('http://localhost:3000/'); | |
} | |
}; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Intercept 401s and redirect you to login | |
$httpProvider.interceptors.push(['$q', '$location', function($q, $location) { | |
return { | |
'responseError': function(response) { | |
if(response.status === 401) { | |
$location.path('/login'); | |
return $q.reject(response); | |
} | |
else { | |
return $q.reject(response); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#AND | |
<b:if cond='data:blog.pageType == "index"'> | |
<b:if cond='data:blog.searchQuery'> | |
<!--search_page AND index_page--> | |
</b:if> | |
</b:if> | |
#OR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('testQDecorator', []) | |
.config(function($provide) { | |
$provide.decorator('$q', function($delegate) { | |
function decoratePromise(promise) { | |
var then = promise.then; | |
promise.resolved = false; | |
promise.finally(function() { | |
promise.resolved = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MONGO_DATABASE="your_db_name" | |
APP_NAME="your_app_name" | |
MONGO_HOST="127.0.0.1" | |
MONGO_PORT="27017" | |
TIMESTAMP=`date +%F-%H%M` | |
MONGODUMP_PATH="/usr/bin/mongodump" | |
BACKUPS_DIR="/home/username/backups/$APP_NAME" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var gulp = require('gulp'); | |
var $ = require('gulp-load-plugins')(); | |
var options = {}; | |
options.sass = { | |
errLogToConsole: true, | |
sourceMap: 'sass', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive('backButton', ['$window', function($window) { | |
return { | |
restrict: 'A', | |
link: function (scope, elem, attrs) { | |
elem.bind('click', function () { | |
$window.history.back(); | |
}); | |
} | |
}; | |
}]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function json_api_prepare_post( $post_response, $post, $context ) { | |
$field = get_fields($post['ID']); | |
$post_response['custom-fields'] = $field; | |
return $post_response; | |
} | |
add_filter( 'json_prepare_post', 'json_api_prepare_post', 10, 3 ); |