Skip to content

Instantly share code, notes, and snippets.

View AmrAbdulrahman's full-sized avatar

Amr Abdulrahman AmrAbdulrahman

View GitHub Profile
npm ERR! Error: EROFS, symlink '../strip-ansi/cli.js'
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-@googlegroups.com>
npm ERR! System Linux 3.13.0-32-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /home/amr/Awingu/smc-ui
npm ERR! node -v v0.10.25
goog.provide('sgo.manager.directives.port');
sgo.manager.directives.port = function() {
function link(scope, element, attrs, ctrl) {
var minPortValue = 0,
maxPortValue = 65535;
function validate(value) {
var isValid = true;
@AmrAbdulrahman
AmrAbdulrahman / promises-example.js
Last active January 26, 2016 10:18
sample desc
function func5() {} // depends on the results of async4() and
function async4() {} // depends on the results of async3() and
function async3() {} // depends on async2()
function async2() {} // depends on async1()
async1(function() {
// do some stuff
async2(function(inputsFromAsync1) {
// do stuff that depends on inputsFromAsync1
async3(function(inputsFromAsync2) {
// do stuff that depends on inputsFromAsync2
async4(function(inputsFromAsync3) {
function asyncSayHiTo(name) {
// define a defer
// defer is the context of the ASYNC operation
var defer = q.defer();
// make an async operation
setTimeout(function() {
// this should run after the function already terminated
// and returned a promise
async1()
.then(function(inputsFromAsync1) {
return async2();
})
.then(function(inputsFromAsync2) {
return async3();
})
.then(function(inputsFromAsync3) {
return async4();
})
function asyncOperation() {
// returns promise
}
var promises = [];
for (var i=0; i<=10; i++) {
var promise = asyncOperation();
promises.push(promise);
}
function asyncOperation() {
// returns promise
}
// show blocking loading modal
asyncOperation()
.then(function() {
// all fine
}, function() {
// something went wrong
function uploadFile(data) {
// we can send notification one or more time as following:
defer.notify(percentageUploaded);
// returns promise
}
uploadFile()
.then(function() {
// fine
/*
In case you have tens of files with '2 spaces' indentation that you need to convert to '4 spaces'
1. Install 'recursive-readdir-sync', do not add the --save label.
2. cd to the root of the directory you want to process
3. Place this script.
3. Run the script, commit, push, enjoy!
*/
let fs = require('fs');
let recursiveReadSync = require('recursive-readdir-sync');