Skip to content

Instantly share code, notes, and snippets.

View dsully's full-sized avatar

Dan Sully dsully

View GitHub Profile
@royling
royling / tmux-iterm2.md
Last active April 24, 2023 19:35
tmux in iTerm2 cheatsheet
@dpino
dpino / ns-inet.sh
Last active May 13, 2025 10:00
Setup a network namespace with Internet access
#!/usr/bin/env bash
# set -x
if [[ $EUID -ne 0 ]]; then
echo "You must be root to run this script"
exit 1
fi
# Returns all available interfaces, except "lo" and "veth*".
@relevitt
relevitt / events.py
Last active November 22, 2016 05:01
SoCo Events module rewritten to use twisted
# -*- coding: utf-8 -*-
"""Classes to handle Sonos UPnP Events and Subscriptions."""
#from __future__ import unicode_literals
import logging
import socket
import time
firewall {
ipv6-name dmz-lan-6 {
default-action drop
enable-default-log
rule 100 {
action accept
log enable
protocol ipv6-icmp
}
rule 1 {
@jmcarp
jmcarp / marshmodel.py
Last active March 5, 2018 01:45
marshmallow-models
import six
import inflection
import marshmallow as ma
class Model(object):
def __init__(self, **kwargs):
self._schema = self.Schema()
self.load(**kwargs)
@corny
corny / unifi-backup.sh
Last active February 27, 2025 09:08
Improved backup script for Ubiquiti UniFi controller
#!/bin/bash -e
#
# Improved backup script for Ubiquiti UniFi controller
# original source: http://wiki.ubnt.com/UniFi#Automated_Backup
#
# must contain:
# username=<username>
# password=<password>
source ~/.unifi-backup
@kaka19ace
kaka19ace / curl_request.py
Last active June 6, 2020 18:37
using pycurl request (support multi request)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# @file curl_request.py
# @author kaka_ace <[email protected]>
# @date Jan 10 2015
# @breif learn from human_curl
# @refrences:
# http://pycurl.sourceforge.net/doc/curlmultiobject.html
# http://curl.haxx.se/libcurl/c/curl_multi_info_read.html
@Schnouki
Schnouki / popcorntime-vpn.sh
Last active November 12, 2024 00:33
OpenVPN for a single application using network namespaces -- helper scripts
#!/usr/bin/env zsh
# Initialize VPN
sudo vpnns up
sudo vpnns start_vpn
# Popcorn time!
sudo ip netns exec frootvpn sudo -u $USER popcorntime
# Cleanup
@voidfiles
voidfiles / secmatics_to_json_schema.py
Created November 8, 2014 00:11
Schematics to JSONSchema
import json
from schematics.types.base import (BaseType, NumberType, IntType, LongType, FloatType,
DecimalType, BooleanType)
from schematics.types.compound import ModelType, ListType
__version__ = '1.0'
SCHEMATIC_TYPE_TO_JSON_TYPE = {
@Zearin
Zearin / python_decorator_guide.md
Last active April 26, 2025 15:21
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].