Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Prototyping...

Marko Cen MarkoCen

:shipit:
Prototyping...
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 / 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 Jun 28, 2022
Read Image (PNG/JPEG) From Disk and Convert it to base64-encoded string on Node Server
View convertImgToBase64.js
import fs from 'fs';
import path from 'path';
const convert = (imgPath) => {
// read image file
fs.readFile(imgPath, (err, data)=>{
// error handle
if(err) {
throw err;
}
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) {