This file contains hidden or 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
| """ | |
| RSA Sign a Message using a private key | |
| Just turns this example into a script: | |
| https://cryptography.io/en/latest/hazmat/primitives/asymmetric/rsa/#signing | |
| """ | |
| import sys | |
| import hashlib | |
| import base64 |
This file contains hidden or 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
| """ | |
| This code is a Python 2.7 port of [aws-lambda-ses-forwarder](https://github.com/arithmetric/aws-lambda-ses-forwarder). Follow instructions there for setting up SES and AWS Lambda. | |
| """ | |
| from email import message_from_file | |
| import json | |
| import logging | |
| import os | |
| import re |
This file contains hidden or 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
| """ | |
| http://stackoverflow.com/questions/28022432/receiving-rtp-packets-after-rtsp-setup | |
| A demo python code that .. | |
| 1) Connects to an IP cam with RTSP | |
| 2) Draws RTP/NAL/H264 packets from the camera | |
| 3) Writes them to a file that can be read with any stock video player (say, mplayer, vlc & other ffmpeg based video-players) | |
| Done for educative/demonstrative purposes, not for efficiency..! |
This file contains hidden or 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
| CREATE OR REPLACE FUNCTION notify_trigger() RETURNS trigger AS $$ | |
| DECLARE | |
| channel_name varchar DEFAULT (TG_TABLE_NAME || '_changes'); | |
| BEGIN | |
| IF TG_OP = 'INSERT' THEN | |
| PERFORM pg_notify(channel_name, '{"id": "' || NEW.id || '"}'); | |
| RETURN NEW; | |
| END IF; | |
| IF TG_OP = 'DELETE' THEN | |
| PERFORM pg_notify(channel_name, '{"id": "' || OLD.id || '"}'); |
This file contains hidden or 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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # | |
| # This is how I used it: | |
| # $ cat ~/.bash_history | python bash-to-zsh-hist.py >> ~/.zsh_history | |
| import sys | |
| import time |
This file contains hidden or 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
| #!/usr/bin/env python | |
| """ | |
| mocking requests calls | |
| """ | |
| import mock | |
| import unittest | |
| import requests | |
| from requests.exceptions import HTTPError |
This file contains hidden or 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 sqlalchemy.orm import sessionmaker, relationship, aliased | |
| from sqlalchemy import cast, Integer, Text, Column, ForeignKey, literal, null | |
| from sqlalchemy.sql import column, label | |
| class Catalog(Base): | |
| __tablename__ = 'catalog' | |
| id = Column(String, primary_key=True) | |
| parentid = Column(String, ForeignKey('catalog.id')) | |
| name = Column(String) | |
| parent = relationship("Catalog", remote_side=[id]) |
This file contains hidden or 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
| # Sample Nginx config with sane caching settings for modern web development | |
| # | |
| # Motivation: | |
| # Modern web development often happens with developer tools open, e. g. the Chrome Dev Tools. | |
| # These tools automatically deactivate all sorts of caching for you, so you always have a fresh | |
| # and juicy version of your assets available. | |
| # At some point, however, you want to show your work to testers, your boss or your client. | |
| # After you implemented and deployed their feedback, they reload the testing page – and report | |
| # the exact same issues as before! What happened? Of course, they did not have developer tools | |
| # open, and of course, they did not empty their caches before navigating to your site. |
This file contains hidden or 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 flask_restful | |
| import functools | |
| class Api(flask_restful.Api): | |
| """ | |
| Patch Flask-style custom error handling into the Flask-RESTful api class. | |
| """ | |
| def __init__(self, *args, **kwargs): |
This file contains hidden or 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
| # | |
| # read/write access to python's memory, using a custom bytearray. | |
| # some code taken from: http://tinyurl.com/q7duzxj | |
| # | |
| # tested on: | |
| # Python 2.7.10, ubuntu 32bit | |
| # Python 2.7.8, win32 | |
| # | |
| # example of correct output: | |
| # inspecting int=0x41424344, at 0x0228f898 |