Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jn0 on github.
  • I am jno (https://keybase.io/jno) on keybase.
  • I have a public key whose fingerprint is 331E 0917 CEE8 9631 3379 4F30 2F8A 511D 4B5A 7166

To claim this, I am signing this object:

@jn0
jn0 / rtsp-rtp-sample.py
Created December 2, 2016 08:43
Sample Python script to employ RTSP/RTP to play a stream from an IP-cam (from stackoverflow)
"""
http://stackoverflow.com/questions/28022432/receiving-rtp-packets-after-rtsp-setup
A demo python code that ..
1) Connects to an IP cam with RTSP
2) Draws RTP/NAL/H264 packets from the camera
3) Writes them to a file that can be read with any stock video player (say, mplayer, vlc & other ffmpeg based video-players)
Done for educative/demonstrative purposes, not for efficiency..!
@jn0
jn0 / local_file.md
Last active December 27, 2016 11:00

reference for playground.md

@jn0
jn0 / SHA-crypt.txt
Last active February 17, 2017 07:12
Trying to make mkpasswd(1) SHA-512 compatible JS code...
# Stolen from https://www.akkadia.org/drepper/SHA-crypt.txt for references.
Unix crypt using SHA-256 and SHA-512
------------------------------------
Author: Ulrich Drepper <drepper@gmail.com>
Version: 0.6 2016-8-31
Only editorial changes since 0.4
#!/bin/bash
# a tool to extract data from those MS Winsoze "web-archives" arrived as a ".DOC" file...
# run as ```splitmime.sh < /tmp/where-it-is.doc``` and check for "./C_/" directory.
div=''
typeset -i nl=0
typeset -i ol=0
file_header='yes'
header='no'
@jn0
jn0 / zabbix307-pg95-centos7-inststall.sh
Last active March 3, 2017 16:08
Install zabbix 3.0.7 with PostgreSQL 9.5 on a CentOS 7 host in "almost automatic" mode
#!/bin/bash
#
# This script is supposed to be ran on the TARGET machine as "root" user.
#
# this one was useful: https://gist.github.com/sebastianwebber/5f7dd76d0b7eabb1d388fbfdcbafebda
#
# NB: It will DROP the existing database and create a fresh one!
# NB: It will losen access restrictions to dumb passwords, etc.
#
@jn0
jn0 / oss-zpool-status.py
Created April 21, 2017 10:41
zpool status block for zabbix/grafana
#!/usr/bin/python
'''
Make use of backend's CSS (it's a "bootstrap" deep in its heart).
Note: any inline "style" elements are filtered out!
JFYI:
.p-a-0 { padding:0 }
Usage:
0. Put this script to, say, /etc/zabbix/oss-status.py
@jn0
jn0 / qnet.py
Created May 2, 2017 15:41
A tool to map sockets to processes. If you're lucky enough.
#!/usr/bin/python
# -*- coding: utf-8 -*- vim: et ts=4 sw=4
'''
A tool to replace netstat(8) that has RIP in CentOS and alikes.
Yes, ss(8) should be there.
'''
# /proc/net/udp
# sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode ref pointer drops
# 120: 0100007F:0143 00000000:0000 07 00000000:00000000 00:00000000 00000000 997 0 15319 2 ffff8800f1d80000 0
# /proc/net/tcp
@jn0
jn0 / which-virt.sh
Created May 15, 2017 11:08
yet another tool to detect hypervisor from guest
#!/bin/bash
# Which Hypervisor
verbose=no
exe="$0"
say() { echo "$@" >&2; }
verb_say() { [ "$verbose" = 'yes' ] && say "$@"; }

Converts a series of "assignments" to a "JSON" dict.

It was intended to parse /var/lib/iscsi/nodes/$TARGET/$PORTAL/default files of iSCSI initiator node (where one have ran iscsiadm command). The path is for CentOS 7 based machines -- your mileage may vary.

Syntax of input files

  • line ::= entry? [ # comment ] \n