Skip to content

Instantly share code, notes, and snippets.

View realamirhe's full-sized avatar

Amir.H Ebrahimi realamirhe

View GitHub Profile
realamirhe / discord-crawler.js
Created December 27, 2022 08:30
Crawl discord images and text
View discord-crawler.js
window.discordRef = Object.keys(window.discordRef).length ? window.discordRef : {};
function debounceEvent(callback, time) {
let interval;
return () => {
interval = setTimeout(() => {
interval = null;
realamirhe /
Last active November 26, 2022 19:00
Setup postgres in goolge colab

Copy and paste each block of code to your colab notebook and run them all so you can save data in your postgres database and query (retierive) data from it.


# Install postgresql server
sudo apt-get -y -qq update
sudo apt-get -y -qq install postgresql
realamirhe / tweet-crawler.js
Last active November 4, 2022 09:53
tweet client crawler
View tweet-crawler.js
window.tweetsRef = {};
function debounceEvent(callback, time) {
let interval;
return () => {
interval = setTimeout(() => {
interval = null;
realamirhe / useUndoRedo.ts
Created October 28, 2021 13:33
undo redo react hook which don't cause re-render
View useUndoRedo.ts
import { useRef, useCallback } from 'react';
export const useUndoRedo = <T>() => {
const undoStack = useRef<T[]>([]);
const undoPointer = useRef(-1);
const add = useCallback((item: T) => {
const pointer = ++undoPointer.current;
undoStack.current.length = pointer;
undoStack.current[pointer] = item;
realamirhe / btree.ts
Created October 28, 2021 03:40
in-order BTree traversal in typescript with generators
View btree.ts
// binary tree
interface INode {
left: INode | null;
value: number;
right: INode | null;
class BinaryTree {
public root: INode;
realamirhe /
Last active October 26, 2021 16:44
Javascript array cheat sheet

Here is a list of array operations that you can review, such as blitz. From now on, we'll be working with these arrays.

const numbers: number[] = [0, 1, 2];
const alphabet: string[] = ['a', 'b', 'c'];


realamirhe /
Last active October 5, 2021 17:55
Installing flutter in Ubuntu with sanctions

Installing flutter in Ubuntu with sanctions

  1. Install snap
  2. follow instruction of this youtube video


install flutter with snap

realamirhe / install Puppeteer with downloaded chrome-linux .md
Last active August 16, 2021 12:12
install puppteer with local chrome-linux installation file. (offline/without extra download)
View install Puppeteer with downloaded chrome-linux .md

When you install Puppeteer, it downloads a recent version of Chromium (~170MB Mac, ~282MB Linux, ~280MB Win) that is guaranteed to work with the API.

If you have by chance here is instruction to get it into work

  1. PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 yarn add puppeteer
  2. make a folder named .local-chromium in node_modules/puppeteer
  3. if you are in linux make another folder named linux-901912 in .local-chromium

version is the same as the version which you've downloaded chromimum e.g. in

realamirhe /
Created July 9, 2021 11:05
Extract audio from power point (pptx file) with ffmpeg in python
import os
PREFIX_LENGTH = len('media')
POSTFIX_LENGTH = len('.wma')
files = [file for file in os.listdir('.') if file.endswith('wma')]
files.sort(key=lambda string: int(string[PREFIX_LENGTH: -1*POSTFIX_LENGTH]))
count_of_files = len(files)
input_query = ' -i '.join(files)
realamirhe / .env
Created April 30, 2021 06:28
configuring redis docker-compose.yml file using password from .env file
View .env
# redis