Skip to content

Instantly share code, notes, and snippets.

View edavis's full-sized avatar
💭
I may be slow to respond.

Eric Davis edavis

💭
I may be slow to respond.
View GitHub Profile
@edavis
edavis / if_rx_eth0.sh
Created January 21, 2024 04:40
Graph rx and tx separately in munin. Taken from the core if_ plugin but simplified down.
#!/bin/bash
INTERFACE="eth0"
case $1 in
config)
echo "graph_title $INTERFACE rx traffic"
echo 'graph_args --base 1000'
echo 'graph_category network'
echo 'traffic.label rx'
@edavis
edavis / torrent-sum.py
Created November 23, 2023 06:48
Parse a directory of torrent files and return the total size of all files within
#!/usr/bin/env python
import os, glob
from io import BytesIO
class End(Exception): pass
def decode(stream):
delim = stream.read(1)
@edavis
edavis / bsky_firehose_standalone.py
Created September 23, 2023 04:58 — forked from DavidBuchanan314/bsky_firehose_standalone.py
This is not production quality code, several corners have been cut, etc. etc.
import io
import base64
import struct
import hashlib
import asyncio
import websockets
from enum import Enum
# ground control to major type
@edavis
edavis / dbhist.sh
Last active September 1, 2023 21:03 — forked from outcoldman/dbhist.sh
DBHist: bash history in sqlite
# The MIT License
# SPDX short identifier: MIT
# Further resources on the MIT License
# Copyright 2017 Denis Gladkikh (https://www.outcoldman.com/en/archive/2017/07/19/dbhist/)
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@edavis
edavis / counter.py
Created January 3, 2020 17:36
Determining when baseball games become unique
#!/usr/bin/env python
import csv
from itertools import groupby
from collections import Counter
reader = csv.DictReader(open('MLB.CWEVENTS'))
writer = csv.writer(open('sequences.csv', 'wb'))
it = groupby(reader, key=lambda row: row['GAME_ID'])
@edavis
edavis / gist:1395977
Created November 26, 2011 16:59
Get memcached working with SASL
Download memcached source
./configure --enable-sasl --enable-sasl-pwdb
make
echo "user:password" > memcached-sasl-pwdb
export MEMCACHED_SASL_PWDB=memcached-sasl-pwdb
./memcached -S -vv
Don't need anything with sasl, saslpasswd2, or memcached.conf
@edavis
edavis / bet-odds-formats.org
Created May 14, 2018 01:52
Betting odds cheatsheet

Cheatsheet for converting between different betting odds and calculating implied probability.

American to Decimal

Fav
-110 = 100 / 110 + 1 = 1.909
Dog
+150 = 150 / 100 + 1 = 2.5

American to Fractional

Fav
-110 = 100 / 110 = 10 / 11
Dog
+150 = 150 / 100 = 3 / 2
<?xml version="1.0"?>
<opml version="2.0">
<head>
<title>Feeds for Journalists</title>
<dateCreated>2018-01-15T20:13:26Z</dateCreated>
<docs>https://github.com/edavis/feedsForJournalists</docs>
<ownerId>https://github.com/edavis</ownerId>
</head>
<body>
<outline type="rss" xmlUrl="http://beta.thehindu.com/news/?service=rss"/>
@edavis
edavis / google-analytics.js
Created January 23, 2013 21:21
Google Analytics tracking code for NPRI.org/blog/
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6492871-3']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);