Skip to content

Instantly share code, notes, and snippets.

View mattsta's full-sized avatar
🐢
Moving slowly and fixing things

Matt Stancliff mattsta

🐢
Moving slowly and fixing things
View GitHub Profile
@mattsta
mattsta / setup.sh
Last active June 5, 2023 06:22
ubuntu 20 / lambdalabs pyenv+poetry+cuda12 bring-up
#!/usr/bin/env bash
## PURPOSE: Fix problems with the currently outdated lambdalabs default image.
# Does:
# - Installs latest Python 3.10 using pyenv
# - Installs the current poetry environment (assuming this is running in a poetry project dir)
# - Installs latest pytorch CUDA 12 nightly into current poetry environment
# Script for "normal-maxing" the default lambdalabs image as of June 2023.
@mattsta
mattsta / useragents_sorted_by_count
Created July 12, 2011 04:10
1567 unique user agents hitting http://matt.io/entry/uq today
1250 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30
620 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30
558 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30
409 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1
395 Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20100101 Firefox/5.0
363 Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
354 -
307 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.41 Safari/535.1
271 Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30
244 Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0
#!/usr/bin/env bash
# mac vm_stat output is unreadable by default (it reports values as multiple of 16384 byte pages),
# so convert the results to actual GB used automatically.
# this python one liner is a list comprehension because it has to hack around
# python not allowing single-line for loops directly.
vm_stat | python -c 'import sys; [print(f"{l:<35}{int(sz) * 16384 / 2**30:>15,.2f} GB") for idx, (l, sz) in enumerate(x.strip().strip(".").split(":") for x in sys.stdin) if idx > 0]'
@mattsta
mattsta / speedups.c
Created December 11, 2021 19:24
a more optimized version of speedups.c from python websockets project with more efficient cascading XOR calculation for large data using Intel SIMD from 32 byte blocks then 16 byte blocks then 8 byte blocks then 1 byte blocks.
/* C implementation of performance sensitive functions. */
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <assert.h>
#include <stdint.h> /* uint32_t, uint64_t */
#include <stdio.h>
#if __AVX2__
@mattsta
mattsta / hsetup.sh
Created December 10, 2020 19:27
quick install steps for haproxy-2.3.2
#!/usr/bin/env bash
set -e
set -x
sudo apt install libssl-dev libsystemd-dev libpcre2-dev -y
wget http://www.haproxy.org/download/2.3/src/haproxy-2.3.2.tar.gz
tar xfvzp hap*
@mattsta
mattsta / compile-mustache-from-pipe.js
Created January 23, 2012 07:29
server-side stdin/stdout mustache template compiler for hogan.js
#!/bin/env node
/*****************
* After getting your compiled template, you re-instantiate it client side by:
* var myTemplate = new Hogan.Template(compiledTemplateEvaledFunction);
* var renderedTemplate = myTemplate.render({field1: "someVal"});
*****************/
/* open le stdin */
@mattsta
mattsta / gist:1652084
Created January 21, 2012 09:06
My frigging HDV->FCP->Motion->Internet workflow

How to HDV->FCP X->Motion 5->Internet

Importing

First, import your video: dvgrab -rewind -f mpeg2/hdv -showstatus -a timestamp

Next, convert your hdv mpeg2 stream to a mov container so Final Cut Pro can import it: ffmpeg -i timestamp001.m2t -vcodec copy -acodec copy -f mov timestamp001.mov

FCP X is buggy, so we need to export the audio from our movie individually: ffmpeg -i timestamp001.m2t timestamp001.aiff

@mattsta
mattsta / gist:1107824
Created July 26, 2011 19:56
Fix Lion DNS Search Domains
How To Fix DNS Search Domains in OS X Lion
==========================================
Edit the mDNSResponder Config
------------------------------
sudo vim /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
Add <string>-AlwaysAppendSearchDomains</string> below <string>-launchd</string>.
Reload mDNSResponder
@mattsta
mattsta / referrers_sorted_by_count
Created July 12, 2011 04:14
237 unique referrers hitting http://matt.io/entry/uq today
5345 -
4793 http://news.ycombinator.com/
738 http://news.ycombinator.com/news
343 http://news.ycombinator.com/item?id=2752136
180 http://twitter.com/
120 http://www.google.com/reader/view/
78 http://news.ycombinator.org/
56 http://hckrnews.com/
46 http://hackerne.ws/
42 http://www.google.com/ig
@mattsta
mattsta / hundreds.erl
Last active August 29, 2015 14:20
This is an erlang version of https://gist.github.com/gigamonkey/6249d85021bc8bf54eb4 (with a minor change to 'combos'/'combineAdjacent' for easier reading)
#!/usr/bin/env escript
% Problem statement:
% Write a program that outputs all possibilities to put + or - or nothing between the
% numbers 1, 2, ..., 9 (in this order) such that the result is always 100.
% For example: 1 + 2 + 34 – 5 + 67 – 8 + 9 = 100.
% Generate all combos of digits 1-9 with +, -, or nothing in between.
combos([N]) -> [[N]];
combos([N|Ns]) -> [[N, X] ++ Rest || X <- [plus, minus, empty], Rest <- combos(Ns)].