Skip to content

Instantly share code, notes, and snippets.

"""Open fixture json files and remove lines which contain '>>>', '|||', '<<<',
and check that `.field.permissions` are unique"""
for fname in files:
fp = open(fname)
perms = json.loads(fixit(fname))
fp.close()
for perm in perms:
item = perm['fields']['permissions']
res = uniq(item)
@alex-bender
alex-bender / projects.txt
Created January 14, 2018 19:36
Project ideas, weekly report
week
date range
project name
description
============
2
08/01 - 14/01
-------------
toy-deploy
Aim of the project is not in solving any problem but in project design itself.
@alex-bender
alex-bender / sleeper.py
Created December 6, 2017 08:34
wait for pid ends; correct error handling
import os
import time
import sys
from subprocess import call
def check_pid(pid):
""" Check For the existence of a unix pid. """
while True:
try:
os.kill(pid, 0)
@alex-bender
alex-bender / README.md
Created November 22, 2017 15:54 — forked from danriti/README.md
Line Profiling in Python

Install the line_profiler module:

[driti@ubuntu ]$ pip install line_profiler

Add the @profile decorator and run:

[driti@ubuntu ]$ kernprof.py -l -v example.py
@alex-bender
alex-bender / infosec_newbie.md
Created November 16, 2017 20:38 — forked from mubix/infosec_newbie.md
How to start in Infosec
@alex-bender
alex-bender / TrueColour.md
Created September 4, 2017 16:39 — forked from XVilka/TrueColour.md
True Colour (16 million colours) support in various terminal applications and terminals

Colours in terminal

It's a common confusion about terminal colours... Actually we have this:

  • plain ascii
  • ansi escape codes (16 colour codes with bold/italic and background)
  • 256 colour palette (216 colours + 16 ansi + 24 gray) (colors are 24bit)
  • 24bit true colour ("888" colours (aka 16 milion))
printf "\x1b[${bg};2;${red};${green};${blue}m\n"
@alex-bender
alex-bender / SimpleHTTPServerWithUpload.py
Created July 31, 2017 07:06 — forked from zhangxiaoyang/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@alex-bender
alex-bender / sshpass.py
Created July 31, 2017 07:01 — forked from virtuald/sshpass.py
Simple python wrapper to give SSH a password for automation purposes (with output capture)
#!/usr/bin/env python3
import os
import sys
_b = sys.version_info[0] < 3 and (lambda x:x) or (lambda x:x.encode('utf-8'))
def ssh_exec_pass(password, args, capture_output=False):
'''
Wrapper around openssh that allows you to send a password to
@alex-bender
alex-bender / get_image_manifest.sh
Last active April 1, 2021 14:17
Docker Registry v2 get manifest and push\pull
#!/bin/bash
#
# Shell scripts for get image manifest from v2 registry
#
# Tested on Debian 8, curl 7.38.0, jq-1.5
#
set -e -u
# Default tag is latest