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 / extract_tweets.js
Last active October 1, 2023 01:57
Extract tweets from browser
if (!window.tweets) window.tweets = {};
/**
* @param tweetElem {HTMLElement}
*/
window.parseTweetElement = (tweetElem) => {
const isQuote = !!Array.from(tweetElem.querySelectorAll("span")).find(
(p) => p.textContent === "Quote"
);
@m-esm
m-esm / code-node.js
Last active July 16, 2023 01:34
embassy-appointment-n8n
const vision = require("@google-cloud/vision");
const puppeteer = require("puppeteer");
const fs = require("fs-extra");
const URL = "https://YOUR_EMBASSY_URL_AND_THE_PAGE";
const browser = await puppeteer.connect({
browserWSEndpoint: `ws://browserless:3000?token=TOKEN_HERE`,
args: [`--window-size=1024,860`],
defaultViewport: {
@m-esm
m-esm / whitespace-challenge.md
Created May 17, 2022 10:48
Whitespace coding challenge

We have a list of valid words, and a long string of text without whitespace. All characters are UTF8, a-z.

Please write a function that finds if the string can be composed of valid words, and if so, adds whitespace between them. Not all words have to be used, but words can be used multiple times. If it's not possible, return empty string and a descriptive error.

The words on validWords do not overlap.

func addWhitespace(input string, validWords []string) (string, error)
@m-esm
m-esm / gist:5abe07930a31975abd5610e5844e5fea
Created January 23, 2021 19:09
bolt_tech_interview_2.js
/**
Imagine some photo file names with lowercase letters and/or digits. We want to sort them as a human would consider natural with a function with the following signature.
// return 0 if a = b, <0 if a < b, >0 if a > b
function compareNaturally(a: string, b: string): number {
//TODO implement
}
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
*/
@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
@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:
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} . ; \
#!/bin/bash
### VARIABLES
base_data_path="/home/docker"
mongo_pass="PASSSS"
###### install resolvconf - to use shecan smart dns
@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