Skip to content

Instantly share code, notes, and snippets.

:shipit:
Coding mode

Kirill Pavlov pavlov99

:shipit:
Coding mode
Block or report user

Report or block pavlov99

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am pavlov99 on github.
  • I am p99 (https://keybase.io/p99) on keybase.
  • I have a public key whose fingerprint is 247B E451 E71C 8AAD 6AF2 7842 5849 1A6C A92B 0F59

To claim this, I am signing this object:

@pavlov99
pavlov99 / crossjoin.py
Last active Sep 12, 2019
Pandas cross-join
View crossjoin.py
from functools import reduce
def crossjoin(*dfs, **kwargs):
"""Calculate a cartesian product of given dataframes.
Subsequently join each dataframe using a temporary constant key and then remove it.
Also set a MultiIndex - cartesian product of the indices of the input dataframes.
See: https://github.com/pydata/pandas/issues/5401
Args:
@pavlov99
pavlov99 / javascript-dependencies.sh
Created Aug 24, 2018
Visualize JavaScript dependencies
View javascript-dependencies.sh
# Install madge (https://github.com/pahen/madge) and graphviz first
madge --dot --layout neato --include-npm src/ | dot -Tpng > dependencies.png
@pavlov99
pavlov99 / test-javascript.sh
Created Aug 24, 2018
Find all *.spec.js testing files in src/ folder and execute with node.js
View test-javascript.sh
# This command line executes all test files with NodeJS.
# Test files are located in ./src folder and have *.spec.js
# In order to use ES6 import/export syntax, reify is required: https://github.com/benjamn/reify
# `find` command generates a "test file" which require() every actual test.
# If the output is TAP-compatible, one could pipe it to ./node_modules/.bin/tap-mocha-reporter spec
node --require reify -e "$(find ./src -name '*\.spec\.js' -type f -exec echo "require('{}');" \; | paste -s -d' ' -)"
@pavlov99
pavlov99 / update-photo-metadata.sh
Created Jul 22, 2018
Update incorrectly set image metadata in batch. Set geo location (latitude, longitude) and time.
View update-photo-metadata.sh
#!/usr/bin/env bash
# Update photo information: time and location.
# After photo editing by agency, all of the meta tags were changed. This script fixes it.
# Photos are ordered by filename, e.g. 001.jpg, 002.jpg, etc. The whole event happened
# between 16:30 and 21:00 Moscow time on 30th June. Set time to every picture as if they were
# taken uniformly during the event.
#
# See also:
# exiftool https://www.sno.phy.queensu.ca/~phil/exiftool/ (allows batch editing as well).
# https://www.latlong.net/ to find your location and get latitude and longitude info.
@pavlov99
pavlov99 / enum.py
Created Jun 6, 2018
Python helpers
View enum.py
class Choices(object):
""" Choices."""
def __init__(self, *choices):
self._choices = []
self._choice_dict = {}
for choice in choices:
if isinstance(choice, (list, tuple)):
@pavlov99
pavlov99 / combine-pdfs.sh
Created May 19, 2018
Combine multiple PDF files into one with dockerized PDFtk
View combine-pdfs.sh
docker run -v "$(pwd)":/work mnuessler/pdftk *.pdf cat output combined.pdf
View archives-progress-bar.sh
# Install linux pipe viewer and optional dialog
sudo apt-get install dialog
# Archive:
tar cf - /folder-with-big-files -P | pv -s $(du -sb /folder-with-big-files | awk '{print $1}') | gzip > big-files.tar.gz
# OSX:
tar cf - /folder-with-big-files -P | pv -s $(($(du -sk /folder-with-big-files | awk '{print $1}') * 1024)) | gzip > big-files.tar.gz
# Unarchive:
pv file.tgz | tar xzf - -C target_directory
@pavlov99
pavlov99 / GPG-keys.sh
Created Apr 2, 2017
GnuPG key management
View GPG-keys.sh
# Add gpg key: https://help.ubuntu.com/community/GnuPrivacyGuardHowto
# Install GnuPG from https://www.gnupg.org/download/index.html
gpg2 --full-generate-key
# Delete gpg key
gpg --delete-secret-key "User Name"
gpg --delete-key "User Name"
@pavlov99
pavlov99 / ansible-galaxy-find-role-id.sh
Created Mar 27, 2017
Find your role's id in ansible-galaxy
View ansible-galaxy-find-role-id.sh
$ ansible-galaxy info YourUser.RoleName | grep -E 'id: [0-9]' | awk {'print $2'}
You can’t perform that action at this time.