Skip to content

Instantly share code, notes, and snippets.

@jlinoff
jlinoff / pmi.py
Last active March 9, 2021 14:45
Simple PMI calculator that accepts the loan amount, interest and term in years.
#!/usr/bin/env python2.7
'''
Simple PMI calculator for monthly payments.
Enter the loan amount, the annual interest rate and the number
of years.
'''
import sys
@jlinoff
jlinoff / lswhl
Created August 26, 2017 14:52
Report information about python wheel files. Works for both python 2 and 3.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Report information about Python wheel files.
It is useful for analyzing wheels that have not been installed.
By default it provides a one-line ls -l like report of each wheel that
reports the file name, the size, the wheel name, the version and the
summary.
@jlinoff
jlinoff / atctest.go
Last active June 9, 2017 00:44
Go program to test ANSI terminal color capability.
// ANSI terminal color test.
// Just run it on your terminal to see the available colors.
// CITATION: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
//
// $ go build atctest.go
// $ ./atctest
//
// Copyright (c) 2017 Joe Linoff
// License: MIT Open Source
package main
@jlinoff
jlinoff / inc.js
Created April 5, 2017 02:01
Javascript ES6 class that does aes-256-cbc encryption using the Google closure library that matches openssl.
// ================================================================
// This must be included before index.js to make sure that the
// Google closure libraries are loaded correctly.
// <script type="text/javascript" src="js/closure-library/closure/goog/base.js"></script>
// <script type="text/javascript" src="js/inc.js"></script>
// <script type="text/javascript" src="js/index.js"></script>
// ================================================================
goog.require('goog.array')
goog.require('goog.asserts')
goog.require('goog.color')
@jlinoff
jlinoff / asn1parse.py
Last active March 30, 2017 16:10
Python tool to report BER and DER encoded ASN.1 files in binary or PEM format with a bit more information than openssl asn1parse. Useful for analyzing SSL certificates.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
r'''
Ouput the structure and contents of BER and DER encoded ASN.1 files in
binary or PEM format.
It can be used to analyze the contents of X.509 certificates and key
files.
It offers two features not avaiable in the openssl ans1parse report:
@jlinoff
jlinoff / example.sh
Created March 22, 2017 00:37
Python wheel example.
#!/bin/bash
#
# This script demonstrates how to create wheels for distributing the
# packages in a virtualenv.
#
# It first creates a virtualenv named "venv" and populates it with
# several packages. After that it creates wheels of all of the
# packages in the virtualenv for distribution in the wheel
# subdirectory.
#
@jlinoff
jlinoff / gzip_stringio_example.py
Last active February 8, 2024 05:54
Python example to show to use gzip to compress/uncompress in memory strings in python-2.7 and python-3.x.
#!/usr/bin/env python
'''
Show how gzip compress/uncompress works for in memory string objects
for python-2.7 and python-3.x.
License: MIT Open Source
Copyright (c) 2017 by Joe Linoff
'''
import base64
import gzip
@jlinoff
jlinoff / mycrypt.py
Last active April 2, 2024 13:28
Simple python tool that demonstrates openssl -aes-256-cbc compatible encrypt/decrypt.
#!/usr/bin/env python
'''
Implement openssl compatible AES-256 CBC mode encryption/decryption.
*********************************
UPDATE: 2021-08-28
Apparently this no longer works out of the box. That is probavbly because the
pycrypto package is getting stale.
I found this hacky workaround to get things working but it is likely not safe:
@jlinoff
jlinoff / setup.sh
Last active March 7, 2017 21:42
Demo to show how to setup a Google git-repo from scratch with 2 projects, it creates the projects, the manifest and the repo.
#!/bin/bash
#
# This example sets up two remote repositories named project1 and
# project2 in the current directory.
#
# It assumes a very old version of bash so that it can be used
# Mac OS X as well as Linux.
#
# Run it like this:
#
@jlinoff
jlinoff / trex.go
Last active February 15, 2017 17:00
Simple program to test go regular expressions.
// Simple program to test go regular expressions.
//
// You specify a regular expression followed by a list of
// strings to test against it. The program reports whether
// each string matched.
//
// Here is how you build it:
//
// $ go build trex.go
//