Skip to content

Instantly share code, notes, and snippets.

# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@radupotop
radupotop / openpgp-card-guide.md
Created April 2, 2023 09:59 — forked from ageis/openpgp-card-guide.md
Quick GPG Smartcard Guide
@radupotop
radupotop / Reviewing profiles
Last active January 9, 2023 13:57 — forked from mmalone/Reviewing profiles
Replacement Django runserver command that does profiling... because I've rewritten this too many times.
>>> import pstats
>>> p = pstats.Stats('p.1258156459.52174278XcQE.prof')
>>> p.strip_dirs().sort_stats(-1).print_stats(5)
Fri Nov 13 15:54:20 2009 p.1258156459.52174278XcQE.prof
124278 function calls (122386 primitive calls) in 0.589 CPU seconds
Ordered by: standard name
List reduced from 1014 to 5 due to restriction <5>
@radupotop
radupotop / wireguard.conf
Created March 3, 2022 23:08 — forked from nealfennimore/wireguard.conf
Wireguard VPN - Forward all traffic to server
# ------------------------------------------------
# Config files are located in /etc/wireguard/wg0
# ------------------------------------------------
# ---------- Server Config ----------
[Interface]
Address = 10.10.0.1/24 # IPV4 CIDR
Address = fd86:ea04:1111::1/64 # IPV6 CIDR
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # Add forwarding when VPN is started
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE # Remove forwarding when VPN is shutdown
@radupotop
radupotop / stubby.xml
Created February 18, 2022 10:24 — forked from alanbuxey/stubby.xml
Cloudflare Stubby config
#
# This is a yaml version of the stubby configuration file (it replaces the
# json based stubby.conf file used in earlier versions of getdns/stubby).
#
# For more information see
# https://dnsprivacy.org/wiki/display/DP/Configuring+Stubby
#
# This format does not fully support all yaml features - the restrictions are:
# - the outer-most data structure must be a yaml mapping
# - mapping keys must be yaml scalars
@radupotop
radupotop / readme.md
Created September 14, 2021 21:43 — forked from mowings/readme.md
ffmpeg stream and save video from Dahua 4300s IP Camera

Use ffmpeg to stream video from a dahua 4300s to a file or files

You can use ffmpeg to directly pull frames off of a dahua 4300s at full resolution. May be a good alternative to pricey dvrs which likely cannot record at full resolution, may not work with the camera, or are prohibitevly expensive

Simple Stream to file

Simple stream to file. Full resolution

ffmpeg -loglevel debug -rtsp_transport tcp -i "rtsp://admin:admin@198.175.207.61:554/live" \

-c copy -map 0 foo.mp4

@radupotop
radupotop / card-offline-outbound.json
Created September 10, 2021 10:15 — forked from billinghamj/card-offline-outbound.json
Monzo transaction types
{
"id": "tx_[transaction-id]",
"created": "2017-07-24T05:45:49.311Z",
"description": "TFL.GOV.UK/CP\\VICTORIA STREET\\TFL TRAVEL CH\\SW1H 0TL GBR",
"amount": -770,
"currency": "GBP",
"merchant": null,
"notes": "",
"metadata": {
"mastercard_clearing_message_id": "mcclearingmsg_[mastercard-clearing-message-id]",
@radupotop
radupotop / filter_model_mixin.py
Created August 24, 2021 20:12 — forked from mlalic/filter_model_mixin.py
A mixin for ``django-rest-framework``providing the possibility to filter the queryset based on query parameters.
from django.db.models import fields as django_fields
class FilteredModelViewSetMixin(object):
"""
A mixin providing the possibility to filter the queryset based on
query parameters.
The mixin overrides the ``get_queryset`` method to return the original
queryset additionally filtered based on the query string parameters.
@radupotop
radupotop / foo.py
Created June 29, 2021 14:53 — forked from Grokzen/Symmetrical ManyToMany Filter Horizontal in Django Admin.py
Symmetrical ManyToMany Filter Horizontal in Django Admin
# Based on post from: https://snipt.net/chrisdpratt/symmetrical-manytomany-filter-horizontal-in-django-admin/#L-26
# Only reposting to avoid loosing it.
"""
When adding a many-to-many (m2m) relationship in Django, you can use a nice filter-style multiple select widget to manage entries. However, Django only lets you edit the m2m relationship this way on the forward model. The only built-in method in Django to edit the reverse relationship in the admin is through an InlineModelAdmin.
Below is an example of how to create a filtered multiple select for the reverse relationship, so that editing entries is as easy as in the forward direction.
"""
### pizza/models.py ###
@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>"