Skip to content

Instantly share code, notes, and snippets.

vinhlh / bash_aliases
Last active August 29, 2015 14:20 — forked from frdmn/bash_aliases
View bash_aliases
alias nginx.start='sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.stop='sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.restart='nginx.stop && nginx.start'
alias php-fpm.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php54.plist"
alias php-fpm.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php54.plist"
alias php-fpm.restart='php-fpm.stop && php-fpm.start'
alias mysql.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
alias mysql.restart='mysql.stop && mysql.start'
alias nginx.logs.error='tail -250f /usr/local/etc/nginx/logs/error.log'
vinhlh /
Created May 22, 2016 07:26
Setup PDF.js web viewer from its github repository
# configs
echo "[INFO] Clone into 'temp'"
git clone -b gh-pages temp
echo "[INFO] Init pdf.js directories"
rm -rf $JS_DIR
rm -rf $CSS_DIR
vinhlh / draft.js
Created June 5, 2016 10:58
Convert Draftjs Mentions raw content to HTML
View draft.js
const renderMention = (entity) => {
const { link, name } =
return `<a href="${link}">${name}</a>`
const renderEntity = (entity) => {
if (entity.type === 'mention') {
return renderMention(entity)
vinhlh / CodeBlock.js
Created November 13, 2016 04:56
Minimal React Highlight.js component
View CodeBlock.js
import React, { Component, PropTypes } from 'react'
import hljs from 'highlight.js/lib/highlight'
import javascript from 'highlight.js/lib/languages/javascript'
import php from 'highlight.js/lib/languages/php'
import python from 'highlight.js/lib/languages/python'
import sql from 'highlight.js/lib/languages/sql'
import objectivec from 'highlight.js/lib/languages/objectivec'
import 'highlight.js/styles/tomorrow.css'
const propTypes = {
vinhlh / typeahead.twitter.js
Created November 18, 2016 10:27
Typehead twitter search implement
View typeahead.twitter.js
this.getRemoteSuggestions = function(a, b, c, d) {
if (!b || !this.needsRemoteRequest(b, d))
this.request[a] || (this.attr.useThrottle ?
this.request[a] = utils.throttle(this.splitRemoteRequests.bind(this), this.attr.remoteThrottleInterval) :
this.request[a] = utils.debounce(this.splitRemoteRequests.bind(this), this.attr.remoteDebounceInterval)),
b.query.indexOf("@") === 0 && b.typeaheadSrc === "COMPOSE" && (b.query = b.query.substring(1),
b.atSignRemoved = !0),
this.request[a](a, b, c, d)
vinhlh / debounce.underscore.js
Created November 18, 2016 10:39
View debounce.underscore.js
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
_.debounce = function(func, wait, immediate) {
var timeout, result;
var later = function(context, args) {
timeout = null;
if (args) result = func.apply(context, args);
vinhlh / throttle.underscore.js
Created November 18, 2016 10:40
View throttle.underscore.js
// Returns a function, that, when invoked, will only be triggered at most once
// during a given window of time. Normally, the throttled function will run
// as much as it can, without ever going more than once per `wait` duration;
// but if you'd like to disable the execution on the leading edge, pass
// `{leading: false}`. To disable execution on the trailing edge, ditto.
_.throttle = function(func, wait, options) {
var timeout, context, args, result;
var previous = 0;
if (!options) options = {};
vinhlh / vl.js
Created November 24, 2016 08:20
View vl.js
vinhlh /
Last active February 7, 2017 06:29
Managing Secrets for Amazon EC2 Container Service–Based Applications Raw
# Check that the environment variable has been set correctly
if [ -z "$SECRETS_BUCKET_NAME" ]; then
echo >&2 'error: missing SECRETS_BUCKET_NAME environment variable'
exit 1
# Containers that are running on your container instances
# have access to all of the permissions that are supplied to the container instance role.
vinhlh / Dockerfile
Last active February 7, 2017 06:31
Managing Secrets for Amazon EC2 Container Service–Based Applications
View Dockerfile
# s3 bucket for storing secrets
ENV SECRETS_BUCKET_NAME oms-services.secrets
# pull secrets data
RUN chmod +x /
# ./cyclops.conf is pulled from S3
CMD cyclops -c ./cyclops.conf -p 80