Skip to content

Instantly share code, notes, and snippets.

@lucaslouca
lucaslouca / .tmux.conf
Created January 18, 2025 06:51
.tmux.conf
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
@lucaslouca
lucaslouca / iptv.py
Created April 26, 2023 15:03 — forked from rlaphoenix/iptv.py
Various Python Flask API utilities for working with HLS/DASH/DRM streams.
from functools import wraps
import os
import re
import subprocess
from pathlib import Path
from typing import Literal
from urllib.parse import quote_plus, unquote_plus, urlencode, urljoin
from uuid import uuid4
import requests
#!/bin/bash
set -o errexit
# rm -rf .git/refs/original/ && git reflog expire --all && git gc --aggressive --prune
# git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch python/rotate-2d-matrix.py" HEAD
# git push origin master --force
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g.:
# git-delete-history path1 path2
@lucaslouca
lucaslouca / dcf-html-table.py
Last active January 11, 2025 13:55
Runs a 10-Year DCF Model and generates an HTML Table with the results.
import os
ASSUMPTIONTS_MAP = {}
ASSUMPTIONTS_MAP['CALM'] = {
'name': 'Cal-Maine Foods, Inc.',
'current_stock_price': 57,
'value_scale': '$mil',
'share_count_scale': 'mil',
'shares_outstanding': 49.0, # mil
@lucaslouca
lucaslouca / Shapes.java
Created April 30, 2020 06:55
Given a list of different shapes and a rectangular area, try to place the shapes in the area so that the placement takes up the minimum amount of space.
package problems;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author lucas
*
* Example:
@lucaslouca
lucaslouca / rename_files.py
Created June 29, 2018 11:24
Rename all files in a directory
import glob
import os
import argparse
def rename(dir, pattern, new_title):
count = 1
for path_and_filename in glob.iglob(os.path.join(dir, pattern)):
title, ext = os.path.splitext(os.path.basename(path_and_filename))
os.rename(path_and_filename, os.path.join(dir + '/', new_title + ('-%s' % count) + ext))
@lucaslouca
lucaslouca / strip_html.py
Last active November 1, 2018 07:10
Get <body>...</body> content from HTML file and write it to a file
import os
import sys
import re
def strip(path: str):
with open(path, "r") as html_file:
content = html_file.read()
body_start_index = content.find('<body>')
body_end_index = content.find('</body>')
@lucaslouca
lucaslouca / strip_html.py
Created April 27, 2018 08:29
Strips out the <body>...</body> from an HTML file and writes the content into a new file.
from bs4 import BeautifulSoup
import os
import sys
def strip(path:str):
with open(path, "r") as html_file:
content = html_file.read()
soup = BeautifulSoup(content, 'html.parser')
body = soup.find('body').prettify()
@lucaslouca
lucaslouca / 10y_historical_prices_nasdaq_dataframe.py
Last active April 27, 2018 08:55
Reads the 10-year historical prices from Nasdaq into a Pandas DataFrame
import requests
import pandas as pd
import csv
def historical_prices(symbol:str):
symbol = symbol.lower()
url = "https://www.nasdaq.com/symbol/{0}/historical".format(symbol)
headers = {'content-type' : 'application/json'}
data = "10y|true|{0}".format(symbol)
@lucaslouca
lucaslouca / 10y_historical_prices_nasdaq.py
Last active April 21, 2018 08:27
Fetches 10-Year Historical Stock Prices from Nasdaq and saves them as CSV
import requests
import bs4 as bs
import csv
import re
def historical_prices(symbol:str):
url = "https://www.nasdaq.com/symbol/{0}/historical".format(symbol)
headers = {'content-type' : 'application/json'}
data = "10y|false|{0}".format(symbol)
resp = requests.post(url, data=data, headers=headers)