Skip to content

Instantly share code, notes, and snippets.

View mazzma12's full-sized avatar

MazzMa mazzma12

View GitHub Profile
@mazzma12
mazzma12 / numpy_pandas_json_serializer.py
Created November 28, 2023 16:35
handy json serializer for numpy and pandas type
import numpy as np
import pandas as pd
def default_json_encoder(value):
# This should be built-in ...
if isinstance(value, (datetime.datetime, pd.Timestamp)):
return value.isoformat()
elif isinstance(value, np.bool_):
return bool(value)
elif isinstance(value, np.floating):
@mazzma12
mazzma12 / chatgpt.md
Created August 31, 2023 09:55 — forked from veekaybee/chatgpt.md
Everything I understand about chatgpt

ChatGPT Resources

Context

ChatGPT appeared like an explosion on all my social media timelines in early December 2022. While I keep up with machine learning as an industry, I wasn't focused so much on this particular corner, and all the screenshots seemed like they came out of nowhere. What was this model? How did the chat prompting work? What was the context of OpenAI doing this work and collecting my prompts for training data?

I decided to do a quick investigation. Here's all the information I've found so far. I'm aggregating and synthesizing it as I go, so it's currently changing pretty frequently.

Model Architecture

@mazzma12
mazzma12 / dataframe_gist.py
Created January 18, 2022 11:08
Push a pandas dataframe to a GIST as a CSV through the Github API
import json
import os
from io import StringIO
import requests
GITHUB_API = "https://api.github.com"
API_TOKEN = os.getenv("GITHUB_API_TOKEN")
@mazzma12
mazzma12 / cookbook.sh
Last active October 13, 2021 12:30
Common oneliners used in Bash and their purpose
# Find IP address from host
nslookup $hostanme
# https://superuser.com/a/1414856
nslookup $hostname | grep -i address | awk -F" " '{print $2}' | awk -F# '{print $1}' | tail -n 1
# DNS issues: better use dig as host will use the local cache of the machine
# @ specifies another resolver than the local cache DNS
dig google.com +short @1.1.1.1
## Docker
@mazzma12
mazzma12 / machine_setup.sh
Last active September 26, 2021 17:34
Setup new Ubuntu server with libraries for work (Python, GIS, others...)
#!/usr/bin/env bash
# Pyenv https://github.com/pyenv/pyenv/wiki#suggested-build-environment
PYENV_PACKAGE="\
build-essential libssl-dev zlib1g-dev make \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
"
GIS_PACKAGE="\
libproj-dev proj-data proj-bin libgeos-dev \
libspatialindex-dev \
@mazzma12
mazzma12 / find_expression.sh
Last active May 21, 2021 14:58
Find and grep occurences in file
#!/usr/bin/env bash
# Find THE notebook you have lost
expr=$1 # The content you are looking for : "*myCode*"
files=${2:-*.ipynb} # File patterns
find . -type f -name "$files" -exec grep -E "$expr" --with-filename {} \;
@mazzma12
mazzma12 / mask_trackpad_area.sh
Created April 14, 2021 08:14
Disable trackpad area - HP Spectre X360
# Hp spectre x360 trackpad are too sensitive on the sides, which is error prone due to palm touch
# This work on Ubuntu 16.04, 18.04,
@mazzma12
mazzma12 / csv_with_location_to_geojson.py
Created September 29, 2020 15:13
Convert location points to GeoJSON
"""
Once often need to parse manually a CSV which contains erroneous cell, therefore I prefer not to use gpd.read_file()
"""
from pathlib import Path
import geopandas as gpd
import pandas as pd
import shapely
@mazzma12
mazzma12 / cat_jupyter_url.sh
Created March 26, 2020 21:50
Cat the url of the last most recent jupyter notebook under the user home.
#!/usr/bin/env bash
cat_jupyter_url () {
file=$(ls -rt $HOME/.local/share/jupyter/runtime/*.html | tail -n 1)
cat $file | grep href= | cut -d'"' -f2
}

Keybase proof

I hereby claim:

  • I am mazzma12 on github.
  • I am mcmzl (https://keybase.io/mcmzl) on keybase.
  • I have a public key ASDefTzbN9XeopYmMf1xZ9BcsPTfYSLByZdnnlMfjU98jQo

To claim this, I am signing this object: