This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from re import Pattern | |
from typing import Dict, Any, cast | |
from pydantic.utils import update_not_none | |
from pydantic.validators import constr_length_validator | |
class RFC3986Regex: | |
ALPHA: Pattern = r"[a-zA-Z]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Little helper class to request a payment on an OPI enabled Card Terminal | |
*/ | |
class OPIHelper { | |
private $ip; | |
private $port; | |
private $requestID = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyqtgraph.Qt import QtGui, QtCore | |
import numpy as np | |
import pyqtgraph as pg | |
## Start Qt event loop unless running in interactive mode or using pyside. | |
if __name__ == '__main__': | |
import sys | |
from window import CustomWindow | |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Scrape the number of podcast reviews from iTunes for all country specific storefronts. | |
* | |
* @author Sean Murphy <sean@iamseanmurphy.com> | |
*/ | |
$podcast_id = '366931951'; // Startups For the Rest of Us | |
//$podcast_id = '318567721'; // techzing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.core.exceptions import ValidationError | |
from django.forms import ModelForm | |
class CleanModel(models.Model): | |
""" Abstract class that adds field validations """ | |
def clean_fields(self, exclude): | |
errors = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.ioloop | |
import tornado.web | |
import tornado.httpserver | |
import tornado.httputil | |
import tempfile | |
class MainHandler(tornado.web.RequestHandler): | |
def put(self): | |
filename = self.request.body.name | |
# do stuff with the image |