Skip to content

Instantly share code, notes, and snippets.

# kill all docker process
docker rm $(docker ps -a -q)
# remove untaged images
docker rmi $(docker images -a | grep "^<none>" | awk '{print $3}')
function docker-safe-rm {
(docker ps -a -q -f name=$1$ || echo :) | xargs docker rm -f
}
@morlay
morlay / gulp-twig.js
Created May 13, 2014 11:16
twig through gulp
var Twig = require('twig');
var es = require('event-stream');
var gutil = require('gulp-util');
var PluginError = gutil.PluginError;
var ext = gutil.replaceExtension;
module.exports = function (options) {
<?php
require_once(DRUPAL_ROOT . '/sites/all/libraries/Twig/lib/Twig/Autoloader.php');
Twig_Autoloader::register();
function twig_render_string($string, $array)
{
return ((new Twig_Environment(new Twig_Loader_String()))->render($string, $array));
}
  1. brew install docker && brew install boot2docker.
  2. boot2docker download to get the lastest server iso.
  3. boot2docker init to host it to VitualBox.
  4. boot2docker up to start the boot2docker-vm. follow console and set environment variables. if you have AnyConnect VPN, DOCKER_HOST should be set to tcp://127.0.0.1:2376 and run VBoxManage controlvm boot2docker-vm natpf1 "docker,tcp,127.0.0.1,2376,,2376"
  5. docker version to check anything is ok.
@morlay
morlay / watcher.js
Last active August 29, 2015 14:08
a gulp extend
var through = require('through');
var gutil = require('gulp-util');
var path = require('path');
module.exports = function() {
var gulp = this;
this.isWatching = false;
this.setWatcher = function() {
@morlay
morlay / gist:f3efae90cf7b21958520
Last active August 29, 2015 14:17
React 的一个参考结构
config/
  default.js
  production.js

components/
  button/
    styles/
  input/
import Immutable from 'immutable';
import _ from 'lodash'
import jsen from 'jsen'
import isTypeArray from './../libs/isTypeArray';
import updateData from './../libs/updateData';
import completeSchema from './../libs/completeSchema';
function SchemaRecord(schema = {}) {
import qs from 'qs'
import scriptjs from 'scriptjs'
const $schoolMap = document.getElementById('school-map');
const baiduMapUri = 'http://api.map.baidu.com/getscript';
const baiduMapConf = {
v: '2.0',
ak: 'YOUR_ACCESS_KEY'
};
import { createStore } from 'reflux';
import GalleryActions from '../actions/GalleryActions'
export default createStore({
init(){
this.galleryMap = {}
this.listenTo(GalleryActions.listGalleries.completed, 'onGalleryListUpdate')
this.listenTo(GalleryActions.getGallery.completed, 'onGalleryUpdate')