Skip to content

Instantly share code, notes, and snippets.

View lmacken's full-sized avatar

Luke Macken lmacken

  • Colorado
View GitHub Profile
@relrod
relrod / doubleslashwindowfixer.pl
Last active January 1, 2016 02:29
A script to make me stop looking like a fool in irc.
# I got tired of looking like a fool by accidentally sending e.g. /12/12 to
# channels when I would go to switch to window 12 (given that I have aliases
# set up for /<window number> -> /window <window number>).
#
# Often times I would type, e.g. /12, intending to switch to window 12, but
# then something would catch my eye and I would want to read the current
# window for a few seconds more. Then I would decide to switch again, having
# forgotten that I typed /12 already from the first time. Nothing caught this
# and I would end up sending "/12/12" to the channel. This script prevents that.
# It is a magical wonder, and nobody in a million years could ever dream of
@lmacken
lmacken / Wall-format-security-critpath-ftbfs.py
Last active December 29, 2015 09:39
Determine how many critical path packages failed to build from source using gcc -Werror=format-security
# Determine how many critical path packages failed to build from source using
# gcc -Werror=format-security. https://fedoraproject.org/wiki/Changes/FormatSecurity
import os
import subprocess
from collections import defaultdict
from fedora.client import PackageDB
pkgdb = PackageDB('https://admin.fedoraproject.org/pkgdb')
@ralphbean
ralphbean / testing-koji-fedmsg.py
Last active December 26, 2015 19:58
Script meant to measure fedmsg reliability.
#!/usr/bin/env python
""" Collect data on fedmsg reliability.
The gist is that we start up and go into a loop. Each time we wake up we:
- Ask koji for all the builds that were started in the last hour. This
includes builds that eventually fail or are in progress.
- Ask fedmsg for all the koji events from the past error. Throw out all
the ones except the 'build start' events.
- Compare the number of new koji builds to the number of fedmsg new build
messages. They should be the same.
@chengyin
chengyin / linkedout.js
Last active July 11, 2021 15:23
Unsubscribe all LinkedIn email in "one click". For an easier to use version, you can check out the bookmarklet: http://chengyin.github.io/linkedin-unsubscribed/
// 1. Go to page https://www.linkedin.com/settings/email-frequency
// 2. You may need to login
// 3. Open JS console
// ([How to?](http://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers))
// 4. Copy the following code in and execute
// 5. No more emails
//
// Bookmarklet version:
// http://chengyin.github.io/linkedin-unsubscribed/
@jackiekazil
jackiekazil / rounding_decimals.md
Last active January 17, 2024 12:29
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value

@zzzeek
zzzeek / gist:6143700
Last active December 20, 2015 14:08
# script: https://github.com/zzzeek/sqlalchemy/blob/master/test/perf/orm2010.py
# cpython 2.7 with no C extensions
classics-MacBook-Pro:sqlalchemy classic$ export PYTHONPATH=lib/
classics-MacBook-Pro:sqlalchemy classic$ python test/perf/orm2010.py
0 - Added 1000 boss objects
3 - Added 100000 grunt objects
29 - Associated grunts w/ bosses and committed
29 - Heavy query run #1
37 - Heavy query run #2
@lmacken
lmacken / fedmsg-sessions.py
Last active December 17, 2015 08:09
Count the number of current and maximum fedmsg zeromq connections
# A script to count the number of current and maximum fedmsg zeromq connections
# Author: Luke Macken <[email protected]>
# License: GPLv3
import requests
from multiprocessing.pool import ThreadPool
from BeautifulSoup import BeautifulSoup
num_proxies = 8
@ssokolow
ssokolow / .coveragerc
Created May 1, 2013 16:17
Boilerplate for making a coverage.io run on a Travis-CI Python project which cleanly skips py25, doesn't crash under pypy, and ignores nose, Python stdlib, and backported modules like unittest2 and ordereddict.
[run]
omit =
*/python?.?/*
*/lib-python/?.?/*.py
*/lib_pypy/_*.py
*/site-packages/ordereddict.py
*/site-packages/nose/*
*/unittest2/*
@jordansissel
jordansissel / RESULTS.md
Created September 21, 2012 07:41
screenshot + code showing how to query logstash/elasticsearch with a graphite function.

logstash queries graphed with graphite.

Operation: Decouple whisper from graphite.

Method: Create a graphite function that does a date histogram facet query against elasticsearch for a given query string for the time period viewed in the current graph.

Reason: graphite has some awesome math functions. Wouldn't it be cool if we could use those on logstash results?

The screenshot below is using logstash to watch the twitter stream of keywords "iphone" "apple" and "samsung" - then I graph them each, so we get an idea of popularity. As a bonus, I also do a movingAverage() on the iphone curve to show you why this is awesome.

@Jud
Jud / Price-Time Matching Engine.c
Created June 1, 2012 23:56
Price-Time Matching Engine
/*****************************************************************************
* QuantCup 1: Price-Time Matching Engine
*
* Submitted by: voyager
*
* Design Overview:
* In this implementation, the limit order book is represented using
* a flat linear array (pricePoints), indexed by the numeric price value.
* Each entry in this array corresponds to a specific price point and holds
* an instance of struct pricePoint. This data structure maintains a list