Skip to content

Instantly share code, notes, and snippets.

View cast42's full-sized avatar

Lode Nachtergaele cast42

View GitHub Profile
@grahama1970
grahama1970 / agent_bubble.py
Last active February 26, 2025 18:31
Dynamic, safe, self-contained Python execution environment using bubblewrap & uv. Generates code/requirements on-the-fly, creates an isolated persistent venv, and lays the groundwork for an LLM-driven adaptive system that installs only needed packages.
#!/usr/bin/env python3
"""
Dynamic and Adaptive Python Environment in a Bubblewrap Sandbox
Overview:
This project demonstrates a minimal, safe, and self-contained Python execution
environment using bubblewrap (bwrap) and uv. The goal is to provide a lightweight
alternative to Docker for running agent code—in this case, dynamically generated
Python code along with its dependencies—within an isolated sandbox.
@RobertTLange
RobertTLange / twitter.py
Last active November 15, 2024 17:09
Twitter API Example
import tweepy
import os
from typing import List, Optional
class TwitterClient:
def __init__(
self,
consumer_key: str,
consumer_secret: str,
@kylemcdonald
kylemcdonald / function-calling.ipynb
Created June 14, 2023 01:10
Example of OpenAI function calling API to extract data from LAPD newsroom articles.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ttomasz
ttomasz / google_sheets_example.py
Created May 24, 2023 19:16
Query Google Spreadsheet directly using Duckdb and Fabduckdb extension
import duckdb
import fabduckdb
import gspread
import pandas as pd
def read_gsheet(service_account_json_path: str, gsheets_url: str, worksheet_name: str) -> pd.DataFrame:
gc = gspread.service_account(filename=service_account_json_path, scopes=gspread.auth.READONLY_SCOPES)
gsheet = gc.open_by_url(gsheets_url)
data = gsheet.worksheet(worksheet_name).get_all_records()
@shawwn
shawwn / adam.py
Last active February 15, 2023 19:48
Reformulating Adam optimizer to gain an intuition about what it's doing.
def lerp(a, b, t):
return (b - a) * t + a
def bias(i, x, beta):
return 1 - jnp.asarray(beta, x.dtype) ** (i + 1)
@optimizer
def adam(step_size, b1=0.9, b2=0.999, eps=1e-8) -> OptimizerResult:
"""Construct optimizer triple for Adam.
@Olshansk
Olshansk / video_to_gif.sh
Last active January 12, 2023 13:35
A handy bash function to convert a video (e.g. a screen cap) to a gif using ffmpeg in your shell
function video_to_gif {
local input_video_path="$1"
local output_gif_path="$2"
local fps="${3:-10}"
local scale="${4:-1080}"
local loop="${5:-0}"
ffmpeg -i "${input_video_path}" -vf "setpts=PTS/1,fps=${fps},scale=${scale}:-2:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop $loop "${output_gif_path}"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PaoloLeonard
PaoloLeonard / expect_table_row_count_to_be_more_than_others.py
Last active October 28, 2022 11:06
Full implementation of a custom table expectation that compares the considered dataset row count to other datasets row count with the possibility of using different comparison keys.
"""
Custom table expectation which checks whether the row count is greater than the row count of other tables.
There are different ways to compare the row counts:
* With absolute values, if one row count value of the other tables is greater than the current then the validation
fails,
* With mean values, if the mean of value of the other tables row count is greater than the current row count then
the validation fails.
"""
from copy import deepcopy
@lpheller
lpheller / tldr-global-gitignore-ds-store.sh
Created November 11, 2020 08:51
Globally ignore .DS_Store files
# Quick and easy one line command to setup a global .gitignore file and ignore macOS .DS_store files globally
git config --global core.excludesfile "~/.gitignore" && echo .DS_Store >> ~/.gitignore
@rvanbruggen
rvanbruggen / colruyt datascience homework assignment.cql
Created November 7, 2019 09:37
colruyt datascience homework assignment.cql
//colruyt datascience homework assignment in Neo4j
// from: https://github.com/MarkiesFredje/data-engineering-exercise/blob/master/data_engineer_exercise.ipynb
// json file download location: https://ecgplacesmw.colruytgroup.com/ecgplacesmw/v3/nl/places/filter/clp-places
//import into neo4j using apoc
//create indexes and constraint
create index on :Address(streetName);
create index on :City(name);