Skip to content

Instantly share code, notes, and snippets.

View m-esm's full-sized avatar
https://calendly.com/m-esm/coffee-chat

Mohsen Esmaeili m-esm

https://calendly.com/m-esm/coffee-chat
View GitHub Profile
@m-esm
m-esm / Exporting VS Code extension list.txt
Created August 12, 2019 18:32
Exporting VS Code extension list
Manual - By script
In machine A,
UNIX:
code --list-extensions | xargs -L 1 echo code --install-extension
@m-esm
m-esm / tmux_cheatsheet.markdown
Created September 6, 2019 15:50 — forked from henrik/tmux_cheatsheet.markdown
tmux cheatsheet

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@m-esm
m-esm / event-loop-delay-check.js
Last active January 29, 2020 19:19
Check event loop health by checking it's delay
const interval = 1000;
const acceptableDelay = 3;
let lastCheck = 0;
(function checkEventLoop() {
const now = Date.now();
if (lastCheck)
if (now - lastCheck > interval + acceptableDelay) {
console.log('\x1b[31m', 'event loop delay', (now - lastCheck - interval) + 'ms', '\x1b[0m');
@m-esm
m-esm / crypto-stream.js
Created February 6, 2020 23:34 — forked from chris-rock/crypto-stream.js
Encrypt and decrypt streams
// Part of https://github.com/chris-rock/node-crypto-examples
// Nodejs encryption of buffers
var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'd6F3Efeq';
var fs = require('fs');
var zlib = require('zlib');
@m-esm
m-esm / remove-old-snaps.sh
Created March 20, 2020 23:03
Removes older versions of Snap applications
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
echo "Current usage:";
du -h /var/lib/snapd/snaps
echo "";
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
#!/bin/bash
### VARIABLES
base_data_path="/home/docker"
mongo_pass="PASSSS"
###### install resolvconf - to use shecan smart dns
echo '
FROM ubuntu
RUN apt update
RUN apt install autossh -y
RUN ssh-agent bash
ENTRYPOINT ["/usr/bin/autossh", "-M", "0", "-T", "-N", "-oStrictHostKeyChecking=no", "-oServerAliveInterval=180", "-oUserKnownHostsFile=/dev/null", "-D","0.0.0.0:8888"]
' > Dockerfile ; \
project="ssh-tunnel" ; \
sudo docker rmi ${project} --force ; \
sudo docker build -t ${project} . ; \
@m-esm
m-esm / gist:1a01d9ac6e0eb12ea0587eef6dc088e8
Created August 14, 2020 23:47 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@m-esm
m-esm / freeup_disk_space_ubuntu
Created January 16, 2021 21:39
multiple command to delete cache and logs to free up disk space
sudo rm /var/lib/snapd/cache/*
sudo journalctl --vacuum-size=10M
sudo npm cache clean --force
sudo yarn cache clean
const _ = require('lodash');
/**
Write a function checking that the given string is valid. We consider a string to be valid if all the characters of the string have exactly the same frequency.
Examples:
"aabbcc" is a valid string
"aabbccc" is an invalid string
*/