Skip to content

Instantly share code, notes, and snippets.

View mz0's full-sized avatar
☂️
לֹא הַבַּיְשָׁן לָמֵד‎

Mark Zhitomirski mz0

☂️
לֹא הַבַּיְשָׁן לָמֵד‎
View GitHub Profile
@mz0
mz0 / hubdecrypt.sh
Created January 28, 2019 16:58 — forked from rgbkrk/hubdecrypt.sh
Encrypt a (short) file using someone's public key from github
#!/usr/bin/env bash
# HubCrypt
# ========
#
# Decrypt a file encrypted using hubencrypt (ok, it's just openssl + rsautl +
# your SSH keys). It needs the private key that matches your last public key
# listed at github.com/<user>.keys
#
@mz0
mz0 / 7digits.py
Last active January 15, 2019 18:50
"Programming pearls" problem 1 test data: unsorted "phone number" file generator.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
print 9,999,999 unique unordered "phone numbers" - 7-digit sequences
"""
m = 9999999 # max number
s = 1046527 # Carol prime: 7, 47, 223, 3967, 16127, 1046527, ...
l = len(str(m))
@mz0
mz0 / arabic.py
Last active January 15, 2019 15:01
Arabic alphabet learning aid and PyQt5 primer
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
https://opensource.com/article/18/11/study-aid-python
2018.11.06 Greg Pittman
An exercise for learning Arabic letters.
An Arabic letter is shown, the name of which can be guessed.
Hover the mouse cursor over the letter to see its name in a Tool Tip.
@mz0
mz0 / aruba.py
Last active December 19, 2018 10:31
It.ArubaCloud API exploration, work moved to mz0/arubacloud-api & then to github.com/mz0/ansible/tree/a-smart/lib/ansible/modules/cloud/it_aruba
#!/usr/bin/python3
# tested with Python 3.6.7 & 2.7.15+ on Ubuntu 18.10
import requests
from pprint import pprint
import json
from datetime import datetime
try:
from ConfigParser import ConfigParser as iniParser
@mz0
mz0 / debian-copy.sh
Last active July 7, 2018 14:43
chroot&grub
#from sda5 (/) to sdb1, MBR/BIOS - HP Microserver N40
newroot=/mnt/b1
mount /dev/sdb1 $newroot
mount -o bind / /tmp/realroot
cd /tmp/realroot
rsync -a --exclude /tmp/realroot . $newroot/
#rsync -a -n --exclude /tmp/realroot . $newroot/
#sent 1,049,625 bytes received 122,278 bytes 260,422.89 bytes/sec
#total size is 2,516,596,807 speedup is 2,147.44 (DRY RUN)
mount -t proc /proc "$newroot/proc"
@mz0
mz0 / cprogress.gnu.sh
Last active July 5, 2018 12:41
monitor disk-copy progress (Unix/macOS)
Total=2695716
BW=28.5
Last=0
while true; do
echo -n $(date +%H:%M:%S.%N); # %N - nanoseconds, GNU 'date' only
Curr=$(df -m /dev/sdd1 |grep sdd1|awk '{print $3}');
Remain=$(expr "$Total" - "$Curr")
TtRun=$(echo "(($Remain / $BW) +0.5)/1" | bc)
ETA=$(date --date="+ $TtRun seconds") # GNU 'date' only
echo ' '$Curr' +'$(expr "$Curr" - "$Last") MB "; ETA: $ETA (@ $BW MBps)"
@mz0
mz0 / htpasswd.php
Last active March 12, 2018 09:37
a PHP function to check user credentials against .htpasswd file with apr1 (MD5) hashes
<?php
/* loosely based on
https://elonen.iki.fi/code/misc-notes/htpasswd-php
Use
===
require('htpasswd.inc');
if ( passOK($user,$pass) ) print "Access granted.";
@mz0
mz0 / transform-check
Last active December 5, 2017 17:11
Gatling multi-message websocket check with save
val unam = """^\{"foo":"ShowBar","name":"(\w+)"\}\Z""".r
val sAvr = """^\{"foo":"Av","viewid":([\d]{1,3})\}\Z""".r
val M = true
def defaultWorkspace17 =
wsAwait.within(3.seconds).until(1+1+7+1+7).message.transform((m: String, s: Session) => { m match {
case m if m.startsWith(uiShowLout) => {M} // 1 Layout
case unam(tName) => {tName == s("uTrader").as[String]} // 1 title-bar label
case m if m.startsWith(uiShowGrid) => {appendGr(m,s(grids).validate[ListBuffer[String]]); M} // 7 Grids
case m if m.startsWith(uiShowForm) => {M} // 1 Order Entry form
case sAvr(v) /*extract viewid*/ => {appendGr(v,s(agIDs).validate[ListBuffer[String]]); M} // 7 ActivateView
@mz0
mz0 / git-subdirectory-tracking.md
Created November 5, 2017 18:47 — forked from tswaters/git-subdirectory-tracking.md
Adding subdirectory of a remote repo to a subdirectory in local repo

This is way more complicated than it should be. The following conditions need to be met :

  1. need to be able to track and merge in upstream changes
  2. don't want remote commit messages in master
  3. only interested in sub-directory of another repo
  4. needs to go in a subdirectory in my repo.

In this particular case, I'm interested in bringing in the 'default' template of jsdoc as a sub-directory in my project so I could potentially make changes to the markup it genereates while also being able to update from upstream if there are changes. Ideally their template should be a separate repo added to jsdoc via a submodule -- this way I could fork it and things would be much easier.... but, it is what it is.

After much struggling with git, subtree and git-subtree, I ended up finding this http://archive.h2ik.co/2011/03/having-fun-with-git-subtree/ -- it basically sets up separate branches from tracking remote, the particular sub-directory, and uses git subtree contrib module to pull it all togther. Following are

@mz0
mz0 / ping.txt
Last active March 28, 2017 10:24
Qualcom Atheros QCA6174 802.11ac (nb13) vs. Atheros AR9285 802.11n (nb-sat4)
# litvax - wired connection
litvax:~ mz0$ ping 107.173.176.5
PING 107.173.176.5 (107.173.176.5): 56 data bytes
64 bytes from 107.173.176.5: icmp_seq=0 ttl=47 time=130.257 ms
64 bytes from 107.173.176.5: icmp_seq=1 ttl=47 time=130.071 ms
64 bytes from 107.173.176.5: icmp_seq=2 ttl=47 time=130.027 ms
64 bytes from 107.173.176.5: icmp_seq=3 ttl=47 time=130.117 ms
64 bytes from 107.173.176.5: icmp_seq=4 ttl=47 time=130.535 ms
64 bytes from 107.173.176.5: icmp_seq=5 ttl=47 time=130.097 ms
64 bytes from 107.173.176.5: icmp_seq=6 ttl=47 time=129.882 ms