Skip to content

Instantly share code, notes, and snippets.

@cpcloud
cpcloud / sample1.sql
Created October 3, 2018 20:06
Buggy SQL Query
SELECT *,
acq_ipos / num_investments AS acq_rate
FROM (
SELECT CASE WHEN i.investor_name IS NULL THEN ‘NO INVESTOR’
ELSE i.investor_name
END AS “Investor name”,
COUNT(DISTINCT c.permalink) AS num_investments,
COUNT(DISTINCT
CASE WHEN c.status IN (‘ipo’, ‘acquired’) THEN c.permalink
END) AS acq_ipos
@cpcloud
cpcloud / sample2.py
Created October 3, 2018 20:08
Ibis Night Owl Query
con = ibis.bigquery.connect(billing_project, 'bigquery-public-data.samples')
t = con.table('github_nested')
expr = (
t.mutate(
# get the hour in UTC during which a repo was created
hour=lambda t: t.created_at
.to_timestamp('%Y/%m/%d %T %z')
.hour(),
# compute the UTC offset to adjust in the next expression
utc_offset=lambda t: t.created_at.split(' ')[2].cast('int64') // 100)
@cpcloud
cpcloud / sample3.txt
Created October 3, 2018 21:06
Result of Ibis Query
night_owl total night_owl_perc
0 422315 2541639 0.166159
@cpcloud
cpcloud / stupidb.py
Last active November 21, 2018 20:09
A really slow database implemented using generators
import abc
import copy
from collections import defaultdict
from pprint import pprint
from typing import (
Any,
Callable,
Dict,
Hashable,
(define (term? expr)
(or (symbol? expr) (number? expr)))
(define/match (expr? expr)
[((list (or '+ '- '*) (? expr?) ...)) #t]
[((? term?)) #t]
[(_) #f])
{ pkgs, ... }:
let unstable = import <nixpkgs-unstable> {};
vim-nginx = unstable.vimUtils.buildVimPlugin {
name = "nginx-vim";
src = unstable.fetchFromGitHub {
owner = "chr4";
repo = "nginx.vim";
rev = "a3def0ecd201de5ea7294cf92e4aba62775c9f5c";
sha256 = "038g7vg6krlpj0hvj3vbhbdiicly8v8zxvhs7an4fa1hr7gdlp4s";
diff --git a/src/configuration/ArcanistConfigurationManager.php b/src/configuration/ArcanistConfigurationManager.php
index f1391a8b..8689c34e 100644
--- a/src/configuration/ArcanistConfigurationManager.php
+++ b/src/configuration/ArcanistConfigurationManager.php
@@ -181,7 +181,7 @@ final class ArcanistConfigurationManager extends Phobject {
'Config: Reading user configuration file "%s"...',
$user_config_path));
- if (!phutil_is_windows()) {
+ if (false) {
@cpcloud
cpcloud / 11
Last active October 16, 2020 22:22
Add the nixos nvidia driver location
diff --git a/patch.sh b/patch.sh
index 8e572f5..fc85e4c 100755
--- a/patch.sh
+++ b/patch.sh
@@ -252,6 +252,7 @@ patch_common () {
'/usr/lib/x86_64-linux-gnu/nvidia/current/'
'/usr/lib64'
"/usr/lib/nvidia-${driver_version%%.*}"
+ "/run/opengl-driver/lib"
)
@cpcloud
cpcloud / 11
Created October 16, 2020 22:23
Add the nixos nvidia driver location and remove ldconfig
diff --git a/patch.sh b/patch.sh
index 8e572f5..1336cc0 100755
--- a/patch.sh
+++ b/patch.sh
@@ -252,6 +252,7 @@ patch_common () {
'/usr/lib/x86_64-linux-gnu/nvidia/current/'
'/usr/lib64'
"/usr/lib/nvidia-${driver_version%%.*}"
+ "/run/opengl-driver/lib"
)
@cpcloud
cpcloud / ffgrid.sh
Created January 19, 2021 15:20
hardware accelerated ffmpeg hls mosaic
#!/usr/bin/env nix-shell
#!nix-shell --pure -i bash -p ffmpeg-full -p bc -p findutils -p ripgrep
set -euxo pipefail
function join_by {
local d=$1
shift
local f=$1
shift