Skip to content

Instantly share code, notes, and snippets.

View tysonholub's full-sized avatar

Tyson Holub tysonholub

  • Western MA
View GitHub Profile
@tysonholub
tysonholub / HiddenValidationMixin.py
Last active November 20, 2018 19:41
Flashes an error message for Hidden/CSRFToken fields on form submit
class HiddenValidationMixin(wtf_Form):
def validate_on_submit(self):
valid = super(wtf_Form, self).validate_on_submit()
if not valid and request.method == 'POST':
for k, v in self.errors.iteritems():
if k not in self.data:
flash('{0}: {1}'.format(k, v), 'error')
else:
attr = self.__getattribute__(k)
if attr and hasattr(attr, 'type'):
PORT=8080
VIRTUAL_ENV=/env
PWD=/home/vmagent/app
GAE_VERSION=[timestamp]
GAE_MEMORY_MB=614
HOSTNAME=[alphanumeric]
HOME=/root
PYTHONUNBUFFERED=1
GAE_SERVICE=default
PATH=/env/bin:/opt/python3.6/bin:/opt/python3.5/bin:/opt/python3.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
@tysonholub
tysonholub / windows.py
Last active January 4, 2022 19:04
Elementary OS: Switch windows of the same application
from subprocess import Popen, PIPE, call
import logging
import logging.handlers
import sys
import os
# NOTE: this script assumes a debian system and requires the wmctrl and xdotool packages
# sudo apt-get install wmctrl xdotool
# NOTE: To get [Alt + ` ]to register on Elementary OS requires removing the keybinding via dconf editor for switch-group/switch-group-backward
@tysonholub
tysonholub / CountryCodeHelper.cs
Last active June 5, 2016 13:56
C# Country Code Map
using System;
using System.Collections.Generic;
namespace Sample
{
public static class Helpers
{
public static IDictionary<string, string> COUNTRY_CODES = new Dictionary<string, string>()
{
{ "afghanistan", "AF" },