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 * as fse from 'fs-extra'; | |
function checkIfNameExistsInDirectory(appDirectory) { | |
return async () => { | |
if (!(await fse.pathExists(appDirectory))) { | |
return | |
} | |
throw throwError(() => { | |
print.error('Invalid project name') |
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
type ExtractPromiseGeneric<P> = P extends Promise<infer T> ? T : never; | |
const currentDirectory = fs.realpathSync(process.cwd()); | |
function throwError(func: Function) { | |
return func; | |
} | |
function CatchError(err: Function | Error) { | |
if (typeof err === 'function') { |
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 { GluegunToolbox, print } from 'gluegun' | |
module.exports = { | |
name: 'init', | |
alias: ['init'], | |
run: async (toolbox: GluegunToolbox) => { | |
print.success('base command created with success'); | |
}, | |
} | |
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
(ns listzip.core) | |
(defn toListZipper | |
"I don't do a whole lot." | |
[lToLz] | |
(list (list) lToLz)) | |
(defn fromListZipper | |
[lz] | |
(let [left (first lz) |
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
type ListZipper<T> = [T[], T[]]; | |
function toListZipper<T>(list: T[]): ListZipper<T>; | |
function toListZipper<T>(list: T[]) { | |
return [[], list]; | |
} | |
function fromListZipper<T>(lz: ListZipper<T>): T[] | |
function fromListZipper<T>([L, R]: ListZipper<T>) { | |
return [...L.reverse(), ...R]; |
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
// flatten.js | |
const flatten = (array) => { | |
return array.reduce((acc, elm) => { | |
if (Array.isArray(elm)) { | |
acc.push(...flatten(elm)) | |
} else { | |
acc.push(elm); | |
} | |
return acc; |
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
# With the basic (500 MB RAM) you will need a swap with 1 GB to run MEAN.js or | |
# Gitlab, you can do that following the steps above: | |
sudo swapon -s | |
sudo dd if=/dev/zero of=/swapfile bs=1024 count=2048k | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
sudo echo '/swapfile none swap sw 0 0' > /etc/fstab | |
# This sets the system to swap memory only when RAM usage is more than 80%, | |
# default was swapping when RAM usage was more than 60%, which results in | |
# most of the services being swapped if you experience a traffic spike. |
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
source /usr/share/nvm/init-nvm.sh |
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
github() { | |
path=$1 | |
count=0 | |
shift | |
case $path in | |
*) pathToList=$(ls -d ~/Documentos/github/* | cut -f6 -d '/') | |
pathToDir=($(ls -d ~/Documentos/github/*)) | |
for i in ${pathToList[*]}; | |
do | |
echo $count')' $i |