Skip to content

Instantly share code, notes, and snippets.

// 转换为 blob 直接传输 暂时无用
function dataURItoBlob(dataURI) {
// convert base64 to raw binary data held in a string
// doesn't handle URLEncoded DataURIs
var byteString = atob(dataURI.split(',')[1]);
// separate out the mime component
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
@morlay
morlay / stackEdit.transMode.preview.js
Last active January 2, 2016 02:28
stackEdit.transMode.preview.js
(function(userCustom, document, localStorage) {
userCustom.onReady = function() {
var styles = [];
styles.push('.trans-mode{width:50%!important;margin:0!important;}');
styles.push('p,h1,h2,h3,h4,h5,h6,li{position:relative;}');
styles.push('.trans-mode .zh{display:block;position:absolute;top:0;right:0;width:98%;margin-right: -100%;font-size:0.8em;font-family:"微软雅黑"}');
styles.push('.trans-mode pre,.trans-mode blockquote{width: 200%;}');
styles.push('.trans-mode blockquote p{width: 46%;}');
@morlay
morlay / ModularJavaScript.md
Created January 3, 2014 15:46
Writing Modular JavaScript With AMD, CommonJS & ES Harmony

Writing Modular JavaScript With AMD, CommonJS & ES Harmony 使用 AMD、CommonJS 及 ES Harmony 编写模块化的 JavaScript

本文的技术审阅是通过 Diigo(Google Chrome 版)进行的。Diigo 是一个让你能够在任意在线文档中加入评论与高亮的免费工具,如果你发现什么错误或是想建议什么扩展,请用 Diigo(或在 GitHub 上建个 gist),我会亲自做测试来处理任何你发过来的点子。

Modularity The Importance Of Decoupling Your Application 模块化 解耦应用程序的重要性

@morlay
morlay / StyleStyles.md
Last active January 3, 2016 05:09
StyleStyles.md
@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 = {}) {