Skip to content

Instantly share code, notes, and snippets.

View likema's full-sized avatar

Like Ma likema

View GitHub Profile
@likema
likema / ssl_display
Last active May 1, 2016 16:43
Show SSL certificate (from file or tcp) , certificate request and private key.
#!/bin/sh
if [ $# -lt 1 ]; then
echo "$0 <host:port|SSL certificate|SSL certificate request|private key>" >&2
exit 1
fi
src=$1
if [ -f $1 ]; then
grep -q -- '-BEGIN CERTIFICATE-' $src && openssl x509 -in $src -text -noout
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# \Author: Like Ma <likemartinma@gmail.com>
# \brief: It shows btrfs subvolume info and supports Python 2/3
import sys
from re import compile as rcomp
from subprocess import Popen, PIPE, STDOUT
SUBVOL_CHECKER = rcomp(
r'^ID\s+(?P<id>\d+)\s+gen\s+(?P<gen>\d+)\s+'
/* vim: set ts=4 sw=4 sts=4 et: */
#include <blkid.h>
#include <stdio.h>
static void print_udev_format (FILE* fp, const char *name, const char *value)
{
char enc[265], safe[256];
*safe = *enc = 0;
if (!strcmp (name, "TYPE") || !strcmp (name, "VERSION")) {
blkid_encode_string (value, enc, sizeof(enc));