Skip to content

Instantly share code, notes, and snippets.

View lmacken's full-sized avatar

Luke Macken lmacken

  • Colorado
View GitHub Profile
@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

@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/
@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.
@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')
@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
@takeshixx
takeshixx / hb-test.py
Last active September 8, 2025 01:16
OpenSSL heartbeat PoC with STARTTLS support.
#!/usr/bin/env python2
"""
Author: takeshix <[email protected]>
PoC code for CVE-2014-0160. Original PoC by Jared Stafford ([email protected]).
Supportes all versions of TLS and has STARTTLS support for SMTP,POP3,IMAP,FTP and XMPP.
"""
import sys,struct,socket
from argparse import ArgumentParser
#!/usr/bin/python
# Connects to servers vulnerable to CVE-2014-0160 and looks for cookies, specifically user sessions.
# Michael Davis ([email protected])
# Based almost entirely on the quick and dirty demonstration of CVE-2014-0160 by Jared Stafford ([email protected])
# The author disclaims copyright to this source code.
import select
@ralphbean
ralphbean / linear-regression-on-text.py
Created May 1, 2014 15:07
Messing around with linear regression over text data
""" Messing around with scikit-learn. """
import sys
import numpy as np
import scipy.sparse
import sklearn.linear_model
import sklearn.datasets
import sklearn.svm
@superjamie
superjamie / raspberry-pi-vpn-router.md
Last active October 6, 2025 20:22
Raspberry Pi VPN Router

Raspberry Pi VPN Router

This is a quick-and-dirty guide to setting up a Raspberry Pi as a "router on a stick" to PrivateInternetAccess VPN.

Requirements

Install Raspbian Jessie (2016-05-27-raspbian-jessie.img) to your Pi's sdcard.

Use the Raspberry Pi Configuration tool or sudo raspi-config to:

@lmacken
lmacken / migrate-pass.py
Created June 5, 2016 06:00
Migrates a 'pass' setup to a different GPG key
#!/usr/bin/env python3
# Re-encrypt all pass files with a different GPG key
# 1) First, add your new key to ~/.password-store/.gpg-id
# 2) Run this script.
# 3) Confirm that things work
# 4) Remove the old backup keys with `find ~/.password-store -name '*.old' | xargs rm`
import os
import shutil
import subprocess