Skip to content

Instantly share code, notes, and snippets.

Avatar
👓

Amir.H Ebrahimi realamirhe

👓
View GitHub Profile
@realamirhe
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 () => {
clearTimeout(interval);
interval = setTimeout(() => {
interval = null;
@realamirhe
realamirhe / postgres_colab.md
Last active November 26, 2022 19:00
Setup postgres in goolge colab
View postgres_colab.md

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.

Setup

%%bash
# Install postgresql server
sudo apt-get -y -qq update
sudo apt-get -y -qq install postgresql
@realamirhe
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 () => {
clearTimeout(interval);
interval = setTimeout(() => {
interval = null;
callback(arguments);
@realamirhe
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
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
realamirhe / js.array.cheat-sheet.md
Last active October 26, 2021 16:44
Javascript array cheat sheet
View js.array.cheat-sheet.md

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'];

Indexing

@realamirhe
realamirhe / flutter-installation.md
Last active October 5, 2021 17:55
Installing flutter in Ubuntu with sanctions
View flutter-installation.md

Installing flutter in Ubuntu with sanctions

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

Notes:

install flutter with snap

@realamirhe
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 chrome-linux.zip 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 https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/901912/chrome-linux.zip

@realamirhe
realamirhe / conatenation.py
Created July 9, 2021 11:05
Extract audio from power point (pptx file) with ffmpeg in python
View conatenation.py
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
realamirhe / .env
Created April 30, 2021 06:28
configuring redis docker-compose.yml file using password from .env file
View .env
# redis
REDIS_PORT=6379
REDIS_PASSWORD=pass1234