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
class ColorPrinter: | |
""" | |
print message to terminal with colored header | |
""" | |
def __init__(self, header=''): | |
self.__header = header | |
self.__levels = { | |
'log': '\033[0m', # terminal color header | |
'info': '\033[1;32;40m', # green header | |
'warn': '\033[1;33;40m', # yellow header |
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 sieve(n) { | |
const a = new Int8Array(n + 1); | |
const max = Math.floor(Math.sqrt(n)); | |
let p = 2; | |
while (p <= max) { | |
for (let i = 2 * p; i <= n; i += p) { | |
a[i] = 1; | |
} |
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
/** | |
* | |
* @fileOverview create route/controller/model by CLI | |
* | |
* usage: `npm run generate module` | |
* `module` in the form of hyphen-separated | |
* three files will be generated: | |
* | |
* app/routes/module.js | |
* app/controllers/Module.js |
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
/** | |
* npm install webpack css-loader extract-text-webpack-plugin file-loader html-loader style-loader html-webpack-plugin -S -E | |
* | |
* build | |
└── app.js | |
build | |
├── bundle.css | |
├── bundle.js | |
└── fonts |
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
/* eslint-disable no-console */ | |
const webpack = require('webpack'); | |
const WebpackDevServer = require('webpack-dev-server'); | |
const ProgressBarPlugin = require('progress-bar-webpack-plugin'); | |
const LogPlugin = require('./webpack-plugins/bundling-lifecycle-log-plugin'); | |
const config = require('./webpack.config.js'); | |
const WEB_PORT = 7002; |
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
# Sublime Text 2/3 plugin | |
# Transform seletion containing JavaScript ES6 `import ... from ...` to `const ... = require(...)`. | |
# | |
# @example | |
# import react from 'react'; | |
# // => const react = require('react'); | |
# | |
# import { foo } from 'react'; | |
# // => const { foo } = require('react'); | |
# |
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
import re | |
def to_require(import_str): | |
''' Transform form JavaScript's ES6 `import` to `require`. | |
>>> to_require("import webpack from 'webpack'") | |
"const webpack = require('webpack')" | |
>>> to_require('import webpack from "webpack"') | |
'const webpack = require("webpack")' |
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
/* eslint-disable no-console */ | |
// | |
// Bundle start at: 10/13/2016, 5:35:37 PM | |
// Bundle stop at: 10/13/2016, 5:35:43 PM | |
// | |
const colors = require('colors'); | |
colors.setTheme({ | |
info: 'green', |
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
/* eslint-disable no-console */ | |
const fs = require('fs'); | |
function updateRouteEntry(routePath, modules) { | |
if (modules.length === 0) return; | |
fs.readFile(routePath, (err, data) => { | |
if (err) { | |
throw err; | |
} |
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
Here is a list of scopes to use in Sublime Text 2 snippets - | |
ActionScript: source.actionscript.2 | |
AppleScript: source.applescript | |
ASP: source.asp | |
Batch FIle: source.dosbatch | |
C#: source.cs | |
C++: source.c++ | |
Clojure: source.clojure | |
CoffeeScript: source.coffee |
OlderNewer