Skip to content

Instantly share code, notes, and snippets.

@cpburnz
cpburnz / Get_system_from_CPython_and_Jython.py
Last active August 29, 2015 13:57
Reliably determine the name of the host system in both CPython and Jython.
# coding: utf-8
"""
Reliably determine the name of the host system in both CPython and
Jython.
"""
__author__ = "Caleb P. Burns"
__license__ = "CC0 1.0 Universal (CC0 1.0) Public Domain Dedication"
__version__ = "1.0.2"
@cpburnz
cpburnz / Natural_sort.js
Last active August 29, 2015 13:58
A natural sort comparison function for use with Array.prototype.sort().
/*!
This Gist provides a natural sort comparison function for use with
`Array.prototype.sort()`.
Author: Caleb P. Burns
License: CC BY-SA 3.0 <http://creativecommons.org/licenses/by-sa/3.0/>
Version: 1.0.1
Source: <https://gist.github.com/cpburnz/9975800>
Note: This is derived from the natural sort implementation by thg435 <http://stackoverflow.com/users/989121/thg435>
posted at <http://stackoverflow.com/a/15479354/369450>.
@cpburnz
cpburnz / Datetime_with_timezone.py
Last active August 29, 2015 14:02
How to create time-zone aware date-time instances.
# coding: utf-8
"""
How to create time-zone aware date-time instances.
"""
__author__ = "Caleb P. Burns"
__license__ = "CC0 1.0 Universal (CC0 1.0) Public Domain Dedication"
__version__ = "1.0.1"
import datetime
@cpburnz
cpburnz / Execute_command_foreach_line.sh
Last active August 29, 2015 14:02
From a bash shell, store new-line separated strings into a variable, and execute a command for each line.
#!/bin/sh
#
# From a bash shell, store new-line separated strings into a variable, and
# execute a command for each line.
#
# Author: Caleb P. Burns
# License: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# Version: 1.0.0
# Enter new-line separated strings into $LINES.
@cpburnz
cpburnz / Git_notes.rst
Last active April 26, 2017 16:25
Git notes.

Git Notes

Staging

File status

@cpburnz
cpburnz / Grep_files_from_stdin.sh
Last active August 29, 2015 14:05
From a bash shell, grep file names received from STDIN. The file names may contain spaces.
#!/bin/bash
#
# From a bash shell, grep file names received from STDIN. The file names may
# contain spaces.
#
# Author: Caleb P. Burns
# License: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# Version: 1.0.0
# 1. Find the files to grep.
@cpburnz
cpburnz / TLS_certificates.rst
Last active September 25, 2023 00:50
TLS (SSL) certificate notes.

TLS (SSL) Certificates

Note

TLS is the successor to SSL but may still be incorrectly referred to as SSL.

Certificate Authority

@cpburnz
cpburnz / Brother_DCP-L2540DW_on_Arch_Linux.rst
Last active July 23, 2023 18:36
Brother DCP-L2540DW on Arch Linux

Brother DCP-L2540DW on Arch Linux

Printer

The printer driver can be installed with the brother-brgenml1 AUR package.

@cpburnz
cpburnz / NVIDIA_GeForce_GTX_960M_with_Optimus_on_Arch_Linux.rst
Last active August 31, 2023 13:23
NVIDIA GeForce GTX 960M with Optimus on Arch Linux

Packages

  • bumblebee 3.2.1-10 (provides nvidia-libgl)
  • mesa 11.0.4-1
  • mesa-libgl 11.0.4-1
  • nvidia 355.11-4 (Nvidia driver)
  • primus 20150118-2 (Bumblebee bridge)
  • xf86-video-intel 1:2.99.917+478+gdf72bc5-2 (Intel driver)
@cpburnz
cpburnz / XSLT_Remove_Attribute_from_Elements.rst
Last active May 19, 2016 13:30
Remove Attribute from Elements using XSLT

XSLT Remove Attribute from Elements

Transform XML document:

xsltproc -o output.xml remove-attribute.xslt input.xml