Skip to content

Instantly share code, notes, and snippets.

👾
invading spaces

Andrei Fokau andreif

👾
invading spaces
  • Funnel.io
  • Stockholm, Sweden
Block or report user

Report or block andreif

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 convert-openssh-to-pem-rsa-key.sh
ssh-keygen -p -m PEM -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -C "" -m PEM
View ffmpeg-m3u8-hls-stream-to-mp4.sh
ffmpeg -i "http://example.com/video_url.m3u8" -c copy -bsf:a aac_adtstoasc "output.mp4"
View check_number_of_tests.sh
@ EXPECTED=$$(cat test/__init__.py | head -1 | cut -d " " -f3); \
pytest --collect-only | grep "collected $$EXPECTED items" || \
(echo "\033[1;31mERROR: Collected number of tests does not match $$EXPECTED \033[0m" && exit 1)
View pip-uninstall-all.sh
alias pip-uninstall-all="pip freeze --local | xargs -r pip uninstall -y"
# pip freeze --exclude-editable
View pypi-publish.sh
# https://realpython.com/pypi-publish-python-package/
pip install twine
python ./setup.py sdist bdist_wheel
python ./setup.py --help-commands
twine check dist/*
# not working: twine upload --repository-url https://test.pypi.org/legacy/ dist/*
twine upload dist/*
View mobtimer.py
from datetime import datetime, timedelta
import AppKit
import Foundation
import PyObjCTools.AppHelper
class App(Foundation.NSObject):
started_at = status_item = duration = None
callbacks = {}
View locked.py
from datetime import datetime
from functools import wraps
from django.core.cache import cache
def locked(timeout):
def decorate(func):
@wraps(func)
def call(*args, **kwargs):
key = f"locked:{func.__name__}"
View fswatch_rsync.sh
if [ $# -eq 0 ]; then
echo "No arguments supplied"
return
fi
LOCAL="/Users/andrei/Project/src/$1/"
REMOTE="andrei@10.0.0.1:~/src/$1"
RSYNC="rsync -avzr --exclude=.git --exclude=ENV --exclude=dist"
FSWATCH='fswatch -0rl 3 --exclude=".*\.git.*" --exclude=".*___jb_.*"'
View django_static_debug_false.py
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
elif settings.IS_LOCAL: # for testing with DEBUG=False
urlpatterns += patterns('',
(r'^%s(?P<path>.*)$' % re.escape(settings.STATIC_URL.lstrip('/')),
'django.contrib.staticfiles.views.serve', {'insecure': True}),
(r'^%s(?P<path>.*)$' % re.escape(settings.MEDIA_URL.lstrip('/')),
'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
View prepare_inline_admin_formset.py
# Django 1.7
class InlineAdminFormsetMixin(object):
inline_admin_formset_class = InlineAdminFormSet
def get_inline_formsets(self, request, formsets, inline_instances,
obj=None):
inline_admin_formsets = []
for inline, formset in zip(inline_instances, formsets):
You can’t perform that action at this time.