Skip to content

Instantly share code, notes, and snippets.

View palawer's full-sized avatar

palawer palawer

View GitHub Profile
from itertools import zip_longest
def grouper(iterable, n=1000, fillvalue=None):
args = [iter(iterable)] * n
return zip_longest(*args, fillvalue=fillvalue)
def chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i+n]
@palawer
palawer / pid.py
Created October 3, 2019 07:21
Check if python process is already running
def check_pid(pid):
try:
os.kill(pid, 0)
except OSError:
return False
else:
return True
pid = None
try:
import logging
logging.basicConfig(
format='%(asctime)s - %(levelname)s - %(message)s',
level=logging.INFO,
handlers=[
logging.StreamHandler(),
logging.FileHandler("filename.log"),
]
)
@palawer
palawer / docker.md
Last active July 5, 2019 06:16
Docker Elasticsearch Kibana

Docker

Docker version 18.09.6, build 481bc77

Basic Commands

List images docker images
List containers docker ps -a
Remove containers docker rm <container_id>
Create network docker network create <network_name> --driver=bridge
Enter docker exec -it /bin/bash

@palawer
palawer / .bash_profile
Created June 18, 2019 10:48
Autocomplete SSH hosts
function __completeSSHHosts {
COMPREPLY=()
local currentWord=${COMP_WORDS[COMP_CWORD]}
local completeHosts=$(
cat "$HOME/.ssh/config" | \
grep --extended-regexp "^Host +([^* ]+ +)*[^* ]+ *$" | \
tr -s " " | \
sed -E "s/^Host +//"
)
@palawer
palawer / sudoers
Created February 20, 2019 08:03
/etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
@palawer
palawer / mitmproxy.md
Last active September 26, 2018 08:00
mitmproxy
  1. Modify mobile network adding proxy
  • IP: mitmproxy machine local IP
  • PORT: 8080
  1. From mobile browser go to mitm.it
  • Install mobile certificate

Commands

Keybase proof

I hereby claim:

  • I am guillemp on github.
  • I am guillemp (https://keybase.io/guillemp) on keybase.
  • I have a public key whose fingerprint is 7DAB B720 EC12 A4A4 C484 732C D527 BFBA 4135 DC3A

To claim this, I am signing this object: