Skip to content

Instantly share code, notes, and snippets.

Avatar
🧑‍🍳
baking bugs

Marko Cen MarkoCen

🧑‍🍳
baking bugs
View GitHub Profile
@MarkoCen
MarkoCen / nodejs-event-emitter-sample-1.js
Created Jan 5, 2018
[Markoenv.org Post] Nodejs Event Emitter Sample 1
View nodejs-event-emitter-sample-1.js
const EventEmitter = require('events');
const event = new EventEmitter();
// 添加一个事件监听器
event.on('bar', function() {
console.log('bar fired!');
})
// 触发一个事件
@MarkoCen
MarkoCen / .eslintrc.json
Created Sep 9, 2017
My ESLint Config for ES6 React Projects
View .eslintrc.json
{
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"es6": true,
@MarkoCen
MarkoCen / isPromise.js
Created Apr 24, 2017
Check if an object is a Promise
View isPromise.js
function isPromise(object){
if(Promise && Promise.resolve){
return Promise.resolve(object) == object;
}else{
throw "Promise not supported in your environment"
}
}
var i = 1;
var p = new Promise(function(resolve,reject){
@MarkoCen
MarkoCen / Gulp流程介绍.md
Created Jul 7, 2015
Gulp自动处理Angular发布流程介绍
View Gulp流程介绍.md

使用Gulp自动化处理发布流程

当Angular应用发布时,开发者需要考虑以下问题:

@MarkoCen
MarkoCen / convertImgToBase64.js
Last active May 5, 2021
Read Image (PNG/JPEG) From Disk and Convert it to base64-encoded string on Node Server
View convertImgToBase64.js
import * as express from 'express';
import * as fs from 'fs';
import * as path from 'path';
const app = express();
app.set('view engine', 'jade');
app.get('/readPNG', (req, res)=>{
View NBWatcherCount.js
(function () {
var root = angular.element(document.querySelectorAll("body"));
var totalWatchers = [];
//通过data()方法找到DOM对应的$scope, 轮询所有子$scope的$$watchers数量
var calcWatcher = function (element) {
angular.forEach(['$scope', '$isolateScope'], function (scope) {
if (element.data() && element.data().hasOwnProperty(scope)) {
angular.forEach(element.data()[scope].$$watchers, function (watcher) {