Skip to content

Instantly share code, notes, and snippets.

import csv
import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--file")
parser.add_argument("--outfile")
args = parser.parse_args()
mapping = {
@lokesh1729
lokesh1729 / notion_rename_exported_files.py
Last active January 8, 2024 12:20
When you export your notion notes, they will be exported with a 32 random character suffix. This script removes them.
import os
import re
import logging
def rename_it(dirpath, path_suffix, is_dir):
pattern = r"([a-zA-Z0-9\s\+\&\']+)\s([a-z0-9]{32})"
match = re.match(pattern, path_suffix)
if match is not None:
if is_dir:
@lokesh1729
lokesh1729 / consumer.py
Last active December 27, 2022 09:10
Code for my blog
from kafka import KafkaConsumer
consumer1 = KafkaConsumer('payments', group_id="group1", bootstrap_servers='localhost:9092')
for msg in consumer1:
print(msg)
import tweepy
import os
consumer_key = os.getenv("TWITTER_API_KEY")
consumer_secret = os.getenv("TWITTER_API_SECRET")
access_token = os.getenv("TWITTER_OAUTH_TOKEN")
access_token_secret = os.getenv("TWITTER_OAUTH_SECRET")
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
@lokesh1729
lokesh1729 / get_twitter_following_list.py
Created July 29, 2021 07:03
Get twitter following list
import tweepy
import os
consumer_key = os.getenv("TWITTER_API_KEY")
consumer_secret = os.getenv("TWITTER_API_SECRET")
access_token = os.getenv("TWITTER_OAUTH_TOKEN")
access_token_secret = os.getenv("TWITTER_OAUTH_SECRET")
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
@lokesh1729
lokesh1729 / Nginx Redirection Flow
Last active January 6, 2021 11:50
Nginx configuration with certbot
Nginx Redirection flow
www.host.com www.host.com
80 443
\ /
@lokesh1729
lokesh1729 / search_repos.py
Created September 14, 2020 09:06
Search Github Repos
import requests
import sys
import webbrowser
GITHUB_URL = "https://api.github.com/search/repositories?q={query_string}&sort=stars"
class CustomException(Exception):
pass
@lokesh1729
lokesh1729 / my first webpack config.js
Created May 12, 2020 14:29
yahoooo!!! my first webpack config working fine :)
const path = require("path");
const webpack = require("webpack");
const TerserPlugin = require("terser-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
module.exports = ({ mode, presets } = { mode: "production", presets: [] }) => ({
devtool: "eval-cheap-module-source-map",
@lokesh1729
lokesh1729 / get_starting_date_minus_n_months.py
Last active October 31, 2019 12:20
This function returns the datetime object by substracting n months (time won't change) #python
def get_starting_date_minus_n_months(curr_date, num_months):
"""
Given the curr_date (datetime) object and num_months, returns the starting date
minus "num_months" months. Note that time won't change
for example: curr_date is "2019-10-22 23:59:59" and num_months is 3
it returns "2019-07-01 23:59:59"
"""
if num_months < 0:
raise ValueError(
@lokesh1729
lokesh1729 / base62_encode.py
Last active July 17, 2019 05:41
#python #url #shortid #short #base62 #base64
BASE62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
def encode(num, alphabet=BASE62):
"""Encode a positive number in Base X
Arguments:
- `num`: The number to encode
- `alphabet`: The alphabet to use for encoding
"""
if num == 0: