This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git cleancommit <files> | |
# removes trailing end-of-line whitespace in staged or committed files | |
cleancommit = "!bash -c 'commit_args=\"\"; files_to_clean=\"\"; for i in \"$@\"; do if [[ \"$i\" == -* ]]; then commit_args=\"$commit_args $i\"; else if [[ \"$i\" = /* ]]; then files_to_clean=\"$files_to_clean $i\"; else files_to_clean=\"$files_to_clean ${GIT_PREFIX}$i\"; fi; fi; done; if [ -n \"$files_to_clean\" ]; then git diff --name-only -- $files_to_clean | while IFS= read -r file; do if [ -f \"$file\" ]; then temp_file=$(mktemp); git diff -U0 \"$file\" | grep \"^@@\" | awk \"{split(\\$3,a,\\\",\\\"); line=substr(a[1],2); count=(length(a)>1)?a[2]:1; for(i=0;i<count;i++) if(line+i>0) print line+i}\" > \"$temp_file\"; while read -r line_num; do if [ -n \"$line_num\" ] && [[ \"$line_num\" =~ ^[0-9]+$ ]]; then sed -i \"\" \"$line_num s/[[:space:]]*$//\" \"$file\"; fi; done < \"$temp_file\"; rm -f \"$temp_file\"; git add \"$file\"; fi; done; else git diff --cached --name-only --diff-filter=ACM | while IFS= read -r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{'ver': {'status': 'UNKNOWN', 'version': ''}} | |
{'cmds': {'sorted by calls': [{'get': '158,696,585 times'}, | |
{'set': '71,614,064 times'}, | |
{'ping': '23,045,904 times'}, | |
{'exists': '1,425,952 times'}, | |
{'info': '1,403,483 times'}, | |
{'replconf': '1,370,802 times'}, | |
{'mget': '700,439 times'}, | |
{'del': '163,092 times'}, | |
{'setex': '139 times'}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/time.h> | |
#include <string.h> | |
static long long ustime(void) { | |
struct timeval tv; | |
long long ust; | |
gettimeofday(&tv, NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* THIS CONVERSATION IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
* ARISING IN ANY WAY OUT OF THE USE OF THIS CONVERSATION, EVEN IF ADVISED OF THE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127.0.0.1:6379> script load "return redis.call('georadius', '{global}:z:locations:'..ARGV[1], ARGV[2], ARGV[3], 10, 'km', 'withdistance', 'ascending')" | |
"1c4c03da2a57cf99d50d57aba9a1d431526b2b9e" | |
127.0.0.1:6379> script load "return redis.call('get', 'abc')" | |
"b86fdf4c29439ed5d9a52c206d90e2b2d8cfc42c" | |
Geo tests (key doesn't exist, so just testing getting an empty reply): | |
matt@ununoctium:~/repos/redis/src% redis-benchmark -n 10000 georadius {global}:z:locations:u1 51.0500000 3.7166700 10 km withdistance ascending | |
====== georadius {global}:z:locations:u1 51.0500000 3.7166700 10 km withdistance ascending ====== | |
10000 requests completed in 0.08 seconds |
NewerOlder