Skip to content

Instantly share code, notes, and snippets.

View liquidcarbon's full-sized avatar
🙃

Alexander Kislukhin liquidcarbon

🙃
  • Colorful Colorado
View GitHub Profile
@liquidcarbon
liquidcarbon / fix_linebreaks.py
Created June 29, 2020 23:11
Remove newline and caret return characters to fix broken lines in a large data export
import sys
def fix(file, sep, nf, output):
"""Checks and fixes prematurely terminated lines in a tabular file.
:param file: input file
:param sep: delimiter or its ASCII **octal** code
:param nf: expected number of fields
:param output: output file
:return: None
@liquidcarbon
liquidcarbon / value_counts_mapreduce.py
Created July 1, 2020 15:31
Map-Reduce implementation of COUNT GROUP BY on each column of a large dataframe
from functools import reduce
import numpy as np
import pandas as pd
class Counts:
"""COUNT ... GROUP BY on every column of a large dataset"""
def __init__(self, file, ddl_file, n_cols=None, n_top=10):
self.file = file
self.columns = get_columns_from_ddl(ddl_file)
@liquidcarbon
liquidcarbon / list_comprehension.py
Created April 19, 2021 20:03
How I feel about list comprehensions
''.join([chr(i) for i in [70, 85, 67, 75, 32, 89, 69, 65, 72, 33]])
@liquidcarbon
liquidcarbon / PoissonRaindrops.html
Created July 19, 2023 20:26
Animated simulation of rare events variability
<!DOCTYPE html>
<html>
<head>
<style>
#canvasContainer {
display: inline-block;
position: relative;
background-color: #f7f7f7;
padding: 5px;
text-align: center;
@liquidcarbon
liquidcarbon / poetry_package_sizer.sh
Last active August 25, 2023 23:56
Size of Python packages
#!/bin/bash
# this script will install a single package into a virtual environment using poetry,
# check the size of the installed dependencies, and clean up.
#
# usage:
# ./poetry_package_sizer.sh "notebook pandas polars altair bokeh matplotlib panel plotly streamlit fastapi flask django rdkit torch"
# Poetry version: 1.5.1
# Python version (change to yours)
@liquidcarbon
liquidcarbon / .bashrc
Created April 16, 2024 03:52
My .bashrc with aliases and Ubuntu 24.04 defaults
# ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# app aliases
alias edit='gnome-text-editor'
# history aliases
alias h='history'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Animated Ball-and-Stick Triangle</title>
<style>
.triangle-container {
position: relative;
width: 200px;
from pathlib import Path
import json
import os
import psutil
kernel_pids = [p.pid for p in psutil.process_iter(['pid', 'name']) if 'python' in p.info['name']]
rows = []
for pid in kernel_pids:
process = psutil.Process(pid)
@liquidcarbon
liquidcarbon / list-for-state-hack.py
Last active November 22, 2024 13:18
Marimo Chuck Norris Joke Dashboard
# video: https://github.com/user-attachments/assets/7e364faf-ddac-4acc-b5e6-83e61c9ed2de
import marimo
__generated_with = "0.9.20"
app = marimo.App(width="medium")
@app.cell
def __():