Skip to content

Instantly share code, notes, and snippets.

View Alex-Just's full-sized avatar

AlekseiK Alex-Just

  • Europe
View GitHub Profile
@Alex-Just
Alex-Just / Main.sublime-menu
Last active September 9, 2021 14:04
Sublime Text plugin "Count Duplicates". Adds command in the Edit main menu that counts number of duplicate rows in a file and prints it in the first left column.
[
{
"id": "edit",
"children":
[
{ "command": "count_duplicates" }
]
}
]
@Alex-Just
Alex-Just / simple_encrypt_decrypt.py
Last active June 8, 2022 14:57
Simple encrypt/decrypt algorithm (Vigenere cipher)
#!/usr/bin/env python3
import base64
"""
Simple obfuscation that will obscure things from the very casual observer.
It is one of the strongest of the simple ancient ciphers.
https://en.wikipedia.org/wiki/Vigenère_cipher
"""
@Alex-Just
Alex-Just / strip_emoji.py
Last active June 29, 2023 18:12
Python regex to strip emoji from a string
import re
# http://stackoverflow.com/a/13752628/6762004
RE_EMOJI = re.compile('[\U00010000-\U0010ffff]', flags=re.UNICODE)
def strip_emoji(text):
return RE_EMOJI.sub(r'', text)
print(strip_emoji('🙄🤔'))
@Alex-Just
Alex-Just / curl.sh
Last active December 23, 2016 13:58
# curl via proxy with auth
curl -x proxy.com:8080 -U user:pass wtfismyip.com/json
# Response headers only
-I
# Measure time
-w %{time_total}
# find by name
find . -name 'MYTEXT*'
# find text in files
grep -r "MYTEXT" .
# find dir by name
find . -name "MYTEXT" -type d
# free space
@Alex-Just
Alex-Just / git.sh
Last active February 20, 2019 17:27
# Reset/checkout a single file from remote origin `branch`
git fetch --all
git checkout origin/branch -- path/to/file
# Reset local repository branch to be just like remote repository HEAD
git fetch origin && git reset --hard origin/develop
# Update current branch from dev
# `git checkout dev; git pull origin dev; git checkout branch; git rebase dev`
git pull --rebase origin develop
# http://stackoverflow.com/questions/16073603/how-do-i-update-each-dependency-in-package-json-to-the-latest-version
# Use npm-check-updates or npm outdated to suggest the latest versions.
npm outdated
# If you agree, update.
npm update
rm -rf node_modules
rm npm-shrinkwrap.json
# OSX
lsof -i :8000
# Ubuntu
sudo netstat -peanut
# Login as a UNIX user (IDENT/PEER authentication)
sudo -u postgres psql postgres
# Login via PostgreSQL's own managed username/password (TCP authentication)
psql username -h 127.0.0.1 -d dbname
# Switch to postgres user via root
sudo -i -u postgres
# Backup DB
# Upgrading all packages with pip
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
# Pip freeze for only project requirements.txt
pip freeze -r requirements.txt | grep -B100 "pip freeze" | grep -v "pip freeze" > /tmp/requirements.txt && mv /tmp/requirements.txt .