Skip to content

Instantly share code, notes, and snippets.

View MarkoCen's full-sized avatar
:shipit:
Prototyping...

Marko Cen MarkoCen

:shipit:
Prototyping...
View GitHub Profile
@MarkoCen
MarkoCen / nodejs-event-emitter-sample-1.js
Created January 5, 2018 23:26
[Markoenv.org Post] Nodejs Event Emitter Sample 1
const EventEmitter = require('events');
const event = new EventEmitter();
// 添加一个事件监听器
event.on('bar', function() {
console.log('bar fired!');
})
// 触发一个事件
@MarkoCen
MarkoCen / isPromise.js
Created April 24, 2017 19:27
Check if an object is a Promise
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 July 7, 2015 20:28
Gulp自动处理Angular发布流程介绍

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

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

@MarkoCen
MarkoCen / convertImgToBase64.js
Last active November 12, 2024 13:26
Read Image (PNG/JPEG) From Disk and Convert it to base64-encoded string on Node Server
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;
}
(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) {