Skip to content

Instantly share code, notes, and snippets.

[
{
"title": "Bye, privacy: Evernote will let its employees read your notes",
"date": "2016-12-14 21:44:00",
"link": "http://www.computerworld.com/article/3150291/security/bye-privacy-evernote-will-let-its-employees-read-your-notes.html",
@stucka
stucka / pipreplace.sh
Last active November 23, 2022 02:50
Force pip to reinstall all Python packages (works great with https://gist.github.com/stucka/0ced1cc71e1a5c374a18874471636d69)
#!/bin/bash
apt-get install libxml2-dev libssl-dev libffi-dev libxslt1-dev python-dev libjpeg-dev
pip freeze --local >pipfreeze.txt
tr '\n' ' ' < pipfreeze.txt >pipfreeze2.txt
pip install --upgrade --force-reinstall `cat pipfreeze2.txt`
@stucka
stucka / badpackagesearch.sh
Last active March 7, 2020 15:45
Fix corrupted packages on Ubuntu (tested on Xubuntu 16.04) (works great with https://gist.github.com/stucka/09cbd34c8bfec0c37dd8a122362ef9c1)
#!/bin/bash
echo "Attempting to install debsums package"
apt-get install --reinstall -y debsums
echo "."
echo "."
echo "."
echo "Running debsums to look for bad files. This will take a while."
debsums -cs 2>&1 >badfiles.txt
echo "."
echo "."
@stucka
stucka / FindMissingFiles.py
Created August 30, 2016 02:38
Find files from one directory tree that aren't in another
import os
sourcedir = "h:\\D\\video"
destdir = "d:\\video"
def getfilelist(dirname):
filelist = {}
count = 0
for root, dirs, files in os.walk(dirname):
for file in files:
@stucka
stucka / cssoptimize.py
Created June 10, 2016 16:41
Optimize yer CSS through Python
def optimize_css(directory):
import os
from csscompressor import compress
print("\tOptimizing CSS in " + directory)
file_paths = [] # List which will store all of the full filepaths.
# Walk the tree.
for root, directories, files in os.walk(directory):
for filename in files:
# Join the two strings in order to form the full filepath.
filepath = os.path.join(root, filename)
@stucka
stucka / stringsimilars.py
Last active May 6, 2016 13:51
Find similar strings
def similar(a, b):
from difflib import SequenceMatcher
return SequenceMatcher(None, a, b).ratio()
def list_match(key, mylist):
mylist = list(set(mylist)) # Get unique values to speed processing
top_score = -1
top_name = ""
@stucka
stucka / gist:dd296cdab56e74b3db019fbf40ab9264
Created May 3, 2016 19:15
Slugifyish thingy for Excel and Python
=substitute(substitute(substitute(substitute(lower(B2) & "-" & lower(A2) & text(C2, "mmddyyyy"), " ", "-"), "’", ""), "'", ""),".", "") & ".jpg"
photofilename = (row['First name'] + "-" + row['Last name']).lower()
photofilename = photofilename + datetime.datetime.strftime(datetime.datetime.strptime(row['Date'], "%m-%d-%Y"), "%m%d%Y")
photofilename = photofilename.replace(" ", "-").replace("'", "").replace('"', '').replace("’", "").replace(".", "")
photofilename = photofilename + ".jpg"
@stucka
stucka / gist:610eb2e67e56261f507e55efaaf7e0ae
Created April 27, 2016 16:00
Round to tenths of millions, billions, thousands in Excel
=IF(B2<1000000,"$"&(ROUND((B2/1000000),1)&" thousand"),IF(B2>1000000000,"$"&(ROUND((B2/1000000000),1)&" billion"),"$"&(ROUND((B2/1000000),1)&" million")))
@stucka
stucka / LocalIPs.py
Created April 11, 2016 13:41
Look for local IP blocks in Maxmind data
import csv
# data source is here https://dev.maxmind.com/geoip/geoip2/geoip2-csv-databases/
# lat column = -2
# long column = -1
# Set up bounding box in a very bad way
minlat = 26.3
maxlat = 27.52
@stucka
stucka / setup_panda_1404.sh
Created March 17, 2016 18:56
Beginning of attempt to get PANDA running on Ubuntu 14.04.
#!/bin/bash
### Note: Script for 12.02 linked from the docs is at a bad URL. Should be:
### https://raw.githubusercontent.com/pandaproject/panda/master/setup_panda.sh
# PANDA Project server setup script for Ubuntu 12.04
# Must be executed with sudo!
set -x