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
| const EventEmitter = require('events'); | |
| /** | |
| * Pipeline class to manage a sequence of functions using an event-driven approach. | |
| */ | |
| class Pipeline { | |
| name; // Name of the pipeline | |
| #initialData = {}; // Initial data | |
| #connRunSeq = []; // Connection run sequence | |
| #ee; // EventEmitter instance |
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
| local ret_status="%(?:%{$fg_bold[green]%}»:%{$fg_bold[red]%}»%s)" | |
| PROMPT='🔥%{$fg_bold[cyan]%}%p %{$fg[cyan]%}%c ${ret_status} %{$fg[green]%}%{$reset_color%}' | |
| RPROMPT='$(git_prompt_info)%{$fg_bold[white]%}%{$reset_color%}' | |
| ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[yellow]%} " | |
| ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" | |
| ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[yellow]%}%{$fg[red]%} 🗴 %{$reset_color%}" | |
| ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[yellow]%}%{$fg[green]%} 🗹 %{$reset_color%}" |
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
| function *primeGenerator() { | |
| let knownPrimes = [2] | |
| const isPrime = (num) => knownPrimes.find(p => num % p === 0) === undefined | |
| let n = 2 | |
| while (true) { | |
| if (isPrime(n)) { | |
| knownPrimes.push(n) | |
| yield n | |
| } | |
| n++ |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>Service worker demo</title> | |
| <!--[if lt IE 9]> |
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
| # -*- mode: ruby -*- | |
| # vi: set ft=ruby : | |
| $script = <<-SCRIPT | |
| rsync -a --delete --delete-excluded --exclude 'node_modules' /vagrant/ /home/vagrant/project | |
| cd /home/vagrant/project | |
| npm install --unsafe-perm | |
| pm2 kill && pm2 start bin/www | |
| SCRIPT | |
| Vagrant.configure("2") do |config| |
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
| { | |
| "env": { | |
| "es6": true, | |
| "node": true, | |
| "mocha": true | |
| }, | |
| "extends": "airbnb-base", | |
| "rules": { | |
| "func-names": [ | |
| "error", |
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
| function isSame(str1, str2) { | |
| return String(str1).split('').sort().join('') === String(str2).split('').sort().join('') | |
| } | |
| function kaprekar(num, seed = num, iterations = 0) { | |
| const digits = String(num).padStart(String(seed).length, '0').split('') | |
| const big = Number(digits.sort().reverse().join('')) | |
| const small = Number(digits.sort().join('')) | |
| const diff = big - small | |
| if (isSame(num, diff)) return console.log(seed, iterations, diff) | |
| kaprekar(diff, seed, iterations + 1) |
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
| server { | |
| server_name example.com; | |
| root /home/ls/app/; | |
| index index.html; | |
| location / { | |
| try_files $uri $uri/ =404; | |
| # try_files $uri /index.html =404; | |
| } |
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
| function lookandsay(str) { | |
| return str.replace(/(.)\1*/g, (seq, p1) => seq.length.toString() + p1) | |
| } | |
| function conway(n) { | |
| if (n === 1) return "1" | |
| return lookandsay(conway(n - 1)) | |
| } |
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
| async function sleep(secs = 1) { | |
| return new Promise(r => setTimeout(() => r(), secs * 1000)) | |
| } |
NewerOlder