Skip to content

Instantly share code, notes, and snippets.

@selimslab
selimslab / get_gists.py
Last active December 23, 2023 15:52 — forked from leoloobeek/get_gists.py
Download all gists of a user
import sys
from subprocess import call
import json
import os
import requests
def download_gists(gists: list):
for gist in gists:
call(["git", "clone", gist["git_pull_url"]])
timeline
    title History of Social Media Platform
    2002 : LinkedIn
    2004 : Facebook
         : Google
    2005 : Youtube
    2006 : Twitter
import csv
import yaml
import ipaddress
from intervaltree import IntervalTree, Interval
def read_csv_lines(file):
with open(file, 'r') as file:
csv_reader = csv.reader(file)
return [row[0] for row in csv_reader]
@selimslab
selimslab / blockchain.py
Last active August 10, 2023 14:59
a simple blockchain in 100 lines
import time
import hashlib
import uuid
import random
from dataclasses import dataclass
from typing import List
@dataclass
class Node:
uid: str
@selimslab
selimslab / search.py
Last active August 10, 2023 14:59
a search engine in 200 lines
import re
import math
import operator
import logging
from collections import defaultdict, Counter
import numpy as np
class Tokenizer:
def __init__(self, stop_words, ):
"""
# exprassemble
Generate 8086 code for a given infix expression
It creates .asm yet it can't print the output
## Steps
@selimslab
selimslab / hashmap.c
Last active September 9, 2022 11:44
a hash map implementation in C, inspired by https://github.com/jamesroutley/write-a-hash-table
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
typedef struct {
char* key;
char* value;
} key_value_pair;
import os
from flask.json import JSONEncoder
import datetime
class CustomJSONEncoder(JSONEncoder):
"Add support for serializing time"
def default(self, o):
"""
Machine Learning model to predict the genres of a movie from its summary
"""
import os
import pickle
from io import StringIO
from flask import Flask, request
from sklearn.preprocessing import MultiLabelBinarizer
@selimslab
selimslab / SQL
Last active September 9, 2022 10:07
INTEGER
BOOLEAN
TEXT
FLOAT
DOUBLE
CHARACTER(num_chars)
VARCHAR(num_chars)
DATE
DATETIME
BLOB