Skip to content

Instantly share code, notes, and snippets.

View caffeinatedMike's full-sized avatar
🫠
Stuck in a perpetual state of existential crisis

Michael Hill caffeinatedMike

🫠
Stuck in a perpetual state of existential crisis
View GitHub Profile
import collections
class DictProxy(collections.Mapping):
"""
A proxy for a dictionary that allows attribute access to underlying keys.
You may pass a custom ``wrapper`` to override the logic for wrapping
various custom types.
"""
@romanvm
romanvm / multi_select.py
Last active March 22, 2020 19:13
The example of a multi-select dialog in a Kodi addon created with PyXBMCt framework
# The example of a multi-select dialog in a Kodi addon created with PyXBMCt framework.
# You will need a checkmark image file.
import os
import xbmcgui
import xbmcaddon
import pyxbmct.addonwindow as pyxbmct
_addon = xbmcaddon.Addon()
_path = _addon.getAddonInfo("path")
_check_icon = os.path.join(_path, "check.png") # Don't decode _path to utf-8!!!
@dukebody
dukebody / json_field.py
Last active March 28, 2024 11:44
JSON field for WTForms that converts between the form string data and a dictionary representation, with validation
from wtforms import fields
import json
class JSONField(fields.StringField):
def _value(self):
return json.dumps(self.data) if self.data else ''
def process_formdata(self, valuelist):
if valuelist:
@trilopin
trilopin / fabfile.py
Created November 20, 2015 07:15
fabfile with google compute engine (GCE) support + releases + virtualenv + supervisor
from fabric.api import env, run, sudo, local, runs_once
# Uncomment this two lines if you need debug mode
# import paramiko
# paramiko.common.logging.basicConfig(level=paramiko.common.DEBUG)
# gce conf
GCE_PROJECT = 'my-project'
GCE_ZONE = 'europe-west1-b'
GCE_HOSTMATCH = 'frontend.*'
GCE_GS_URL = 'gs://bucket/dir/'
@parmentf
parmentf / GitCommitEmoji.md
Last active May 5, 2025 18:02
Git Commit message Emoji
@BertrandBordage
BertrandBordage / autoreplyer.py
Last active June 5, 2023 07:03
Automatically reply to unread and unanswered messages in Python
"""
Automatically replies to mails both unread and unanswered.
WARNING: This answers to any both unread and unanswered mail, even if it is years old.
Don’t use on a mailbox with old messages left unread and unanswered.
Simply subclass ``AutoReplyer``, define the undefined class attribute,
and call the ``run`` method on an instance. This loops until you stop the script
(using Ctrl+C, typically) or until an error occurs, like a network failure.
@noelboss
noelboss / git-deployment.md
Last active May 5, 2025 08:21
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@PlainSight
PlainSight / game.py
Last active December 16, 2023 13:40
Simple Multiplayer Python Game and Server
import pygame, sys
from pygame.locals import *
import pickle
import select
import socket
WIDTH = 400
HEIGHT = 400
BUFFERSIZE = 2048
@ITSecMedia
ITSecMedia / outlook_email.py
Last active May 28, 2024 16:59
Python: Create an Email with Outlook
# https://itsec.media/post/python-send-outlook-email/
import win32com.client
from win32com.client import Dispatch, constants
const=win32com.client.constants
olMailItem = 0x0
obj = win32com.client.Dispatch("Outlook.Application")
newMail = obj.CreateItem(olMailItem)
newMail.Subject = "I AM SUBJECT!!"
@darrenparkinson
darrenparkinson / JabberDemoBot.py
Last active March 7, 2022 01:51
Jabber BOT Demo using Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import logging
import getpass
from optparse import OptionParser
import time
import sleekxmpp