Skip to content

Instantly share code, notes, and snippets.

@radupotop
radupotop / github_flask_oauth2.py
Created June 20, 2021 17:05 — forked from ib-lundgren/github_flask_oauth2.py
Example of how to use Flask with requests-oauthlib to fetch a GitHub user profile using an OAuth 2 token.
from requests_oauthlib import OAuth2Session
from flask import Flask, request, redirect, session, url_for
from flask.json import jsonify
import os
app = Flask(__name__)
# This information is obtained upon registration of a new GitHub
client_id = "<your client key>"
@radupotop
radupotop / proxy_request_verification.py
Created June 10, 2021 21:21 — forked from gavinballard/proxy_request_verification.py
Python methods to verify the signature of a request being sent through a Shopify application proxy.
import hashlib, base64, hmac
def get_proxy_signature(query_dict, secret):
"""
Calculate the signature of the given query dict as per Shopify's documentation for proxy requests.
See: http://docs.shopify.com/api/tutorials/application-proxies#security
"""
# Sort and combine query parameters into a single string.
@radupotop
radupotop / create-superuser.py
Last active January 9, 2023 14:10 — forked from c00kiemon5ter/create-superuser.py
Extend Django's management createsuperuser command to allow non-interactive creation of a superuser with a password.
"""
Extend createsuperuser command to allow non-interactive creation of a
superuser with a password.
Instructions:
mkdir -p path-to-your-app/management/commands/
touch path-to-your-app/management/__init__.py
touch path-to-your-app/management/commands/__init__.py
@radupotop
radupotop / .gitconfig
Created March 24, 2021 11:59 — forked from johnpolacek/.gitconfig
My current .gitconfig aliases
[alias]
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
st = status
aa = add -A .
diff --git a/trunk/config b/trunk/config
index 8ab7f658dda..d6a80d38e66 100644
--- a/trunk/config
+++ b/trunk/config
@@ -1,11 +1,11 @@
#
# Automatically generated file; DO NOT EDIT.
-# Linux/x86 5.10.15 Kernel Configuration
+# Linux/x86 5.11.8-arch1 Kernel Configuration
#
@radupotop
radupotop / imaplib_append.py
Created March 13, 2021 22:46 — forked from Averroes/imaplib_append.py
imaplib append
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright (c) 2008 Doug Hellmann All rights reserved.
#
"""
"""
__version__ = "$Id$"
#end_pymotw_header
@radupotop
radupotop / docker-compose.yml
Last active February 23, 2021 20:07
S3 bucket with Minio
# Run with:
# docker-compose run --service-ports bucket server /tmp/
#
# Set credentials:
#
# export AWS_ACCESS_KEY_ID=root
# export AWS_SECRET_ACCESS_KEY=testtest
#
# Create a bucket & put objects:
#
@radupotop
radupotop / systemd_service_hardening.md
Created February 12, 2021 19:18 — forked from ageis/systemd_service_hardening.md
Options for hardening systemd service units

security and hardening options for systemd service units

A common and reliable pattern in service unit files is thus:

NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=strict
@radupotop
radupotop / test_hyp.py
Last active February 8, 2021 12:15
Hypothesis play around
from hypothesis import given, strategies as st
def q(list):
"""Quicksort"""
return [] if list==[] else q([x for x in list[1:] if x < list[0]]) + [list[0]] + q([x for x in list[1:] if x >= list[0]])
@given(st.lists(st.integers(min_value=-10000, max_value=10000)))
def test_qsort(int_list):
@radupotop
radupotop / backupbucket.fish
Last active February 8, 2021 11:13
Backup folders to an AWS/B2 bucket using rclone.
#!/usr/bin/fish
#
# Script to backup folders to an AWS/B2 bucket using rclone.
#
begin
set -l RCLONE /usr/bin/rclone -Pv --links --exclude ".git/" --delete-excluded sync
set -l BUCKET BackupBucket:
set -l SYNC_FOLDERS Courses Documents Foto