Skip to content

Instantly share code, notes, and snippets.

@cpcloud
cpcloud / shell.nix
Last active February 16, 2021 15:23
very rough shared memory profiling
let
pkgs = import <nixpkgs> { };
in
with pkgs;
mkShell {
name = "profile-shmem";
buildInputs = [ clang_11 boost ];
}
FROM alpine:latest
RUN apk add build-base
RUN apk add clang
RUN apk add boost-dev
COPY ./base.hpp .
COPY ./shmem_profile_consumer.cpp .
RUN clang++ -O3 -std=c++17 -o /usr/bin/consumer shmem_profile_consumer.cpp -lrt -I. -pthread
@cpcloud
cpcloud / Pulumi.dev.yaml
Last active March 19, 2021 14:44
Pulumi setup
# NB: `dev` is the stack name. You can call your stack whatever you want.
# The pulumi config should then be called `Pulumi.${my_stack_name}.yaml`.
config:
dev:nix_build_expr: "config.nodes.%s.configuration.system.build.googleComputeImage"
dev:image_bucket: "nixos-images"
dev:instances:
- name: $HOSTNAME_OF_YOUR_CHOOSING
disk:
size_gb: 500
type: "pd-ssd"
pub fn munge<D, I>(&'a mut self, data: D) -> impl Iterator<Item = u8> + 'a
where
D: IntoIterator<Item = I> + 'a,
I: Borrow<u8> + 'a,
{
data.into_iter()
.zip(&mut self.key)
.map(|(byte, k)| byte.borrow() ^ k)
}
@cpcloud
cpcloud / configuration.nix
Last active May 30, 2021 19:25
rpi4 templtae
{ pkgs, ... }:
let
hardwareUrl = "https://github.com/NixOS/nixos-hardware/archive/684ae160a6e76590eafa3fca8061b6ad57bcc9ad.tar.gz";
in
{
imports = [
"${fetchTarball hardwareUrl}/raspberry-pi/4"
];
boot = {
@cpcloud
cpcloud / test_3163.py
Created January 7, 2022 17:48
The world's most annoying bug
import sqlalchemy as sa
import sqlparse
def issue_sql(con):
part = con.table("part")
supplier = con.table("supplier")
partsupp = con.table("partsupp")
q = part.join(partsupp, part.P_PARTKEY == partsupp.PS_PARTKEY)
@cpcloud
cpcloud / anaylze-bigquery.R
Created January 13, 2022 02:07
ibis ci analysis
library(ggplot2)
library(stringr)
library(tidyr)
library(ggh4x)
library(bigrquery)
library(DBI)
library(dplyr, warn.conflicts = FALSE)
library(lubridate, warn.conflicts = FALSE)
@cpcloud
cpcloud / flake.lock
Created February 7, 2022 10:57
mkdocstrings reproducible example
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"type": "github"
@cpcloud
cpcloud / script.py
Created February 10, 2022 16:26
ibis ffill
from pprint import pprint as print
import duckdb
import ibis
garbage = """
DROP TABLE IF EXISTS demo_data;
CREATE TABLE demo_data (
event_id INT
@cpcloud
cpcloud / joinmovies.py
Last active November 4, 2022 13:33
comparision of pandas and ibis + duckdb on a real use case
import contextlib
import time
from datetime import timedelta
import ibis
import pandas as pd
from ibis import _
def pandas():