Skip to content

Instantly share code, notes, and snippets.

View oleschley's full-sized avatar
🥋
俺はオレ

Ole oleschley

🥋
俺はオレ
  • Hamburg, Germany
View GitHub Profile
@oleschley
oleschley / scatter.js
Created October 19, 2019 16:36
Scatter plot with clip path element
// REFERENCE ONLY, DOES NOT WORK
import * as d3 from 'd3'
// Prepare canvas
const m = { left: 50, right: 50, top: 50, bottom: 50 }
const w = 900 - m.left - m.right
const h = 600 - m.top - m.bottom
const svg = d3.select('#canvas-scatter')
@oleschley
oleschley / gapminder.js
Last active October 19, 2019 16:37
Gapminder visualiation from d3 course
// REFERENCE ONLY, DOES NOT WORK
import * as d3 from 'd3'
const m = {left: 100, right: 50, top: 50, bottom: 100}
const w = 900 - m.left - m.right
const h = 600 - m.top - m.bottom
let time = 0
@oleschley
oleschley / snippets.css
Last active October 20, 2019 13:28
CSS Snippets
/* Basic reset */
*, *::before, *::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.5%;
@oleschley
oleschley / rename-lower.py
Last active June 30, 2019 11:02
Renames directory of files to their lowercase equivalent
import os
import glob
PATH = '/path/to/files'
def main(path: str):
files = glob.glob(f'{path}/*')
for file in files:
os.rename(file, file.lower())
@oleschley
oleschley / rename-images.py
Last active June 29, 2019 14:45
Rename images using their timestamp
"""Copies a list of images from one folder from another and renames
it using the 'datetime-original' field from exif spec. For images
without 'datetime-original', we generate a random id."""
import os
import glob
import uuid
import shutil
from datetime import datetime
from exif import Image
@oleschley
oleschley / snippets.sql
Created April 25, 2019 09:24
SQL Snippets
-- FILL TABLE FROM CSV FILE
COPY table_name FROM '/path/to/file.csv' WITH CSV;
@oleschley
oleschley / snippets.py
Last active November 23, 2022 07:15
Python Snippets
"""COLLECTION OF CODE SNIPPETS. CHEAT SHEET."""
import numpy as np
"""PANDAS CONFIG"""
import pandas as pd
# set maximum rows/columns to be printed
pd.options.display.max_rows = 999
pd.options.display.max_columns = 99
@oleschley
oleschley / snippets.sh
Last active November 18, 2022 08:54
Shell snippets
# make all files in current directory lowercase
for file in * ; do mv $file ${file:l} ; done
# activate env variables in .env file
export $(grep -v '^#' .env | xargs)
# python virtual environments
## create
virtualenv --python=python3.6 $HOME/venv/my-env
## activate