Skip to content

Instantly share code, notes, and snippets.

@Kludex
Kludex / main.py
Last active February 19, 2024 08:52
Run Gunicorn with Uvicorn workers in code
View main.py
""" Snippet that demonstrates how to use Gunicorn with Uvicorn workers in code.
Feel free to run:
- `python main.py` - to use uvicorn.
- `ENV=prod python main.py` - to use gunicorn with uvicorn workers.
Reference: https://docs.gunicorn.org/en/stable/custom.html
"""
View freshest_camera_frame.py
#!/usr/bin/env python3
'''
always getting the most recent frame of a camera
================================================
Usage:
------
freshest_camera_frame.py
@miohtama
miohtama / jsonb.py
Created April 27, 2015 18:06
JSOB field decoratore: Create SQLAlchemy model properties which are stored inside JSONB data
View jsonb.py
"""JSONB data utilities."""
import datetime
from decimal import Decimal
import copy
import json
import iso8601
from sqlalchemy import inspect
from sqlalchemy.orm.attributes import flag_modified
@ThereExistsX
ThereExistsX / fileio.cpp
Created February 26, 2015 20:17
File IO
View fileio.cpp
#include "fileio.h"
#include <QFile>
#include <QTextStream>
FileIO::FileIO()
{
}
void FileIO::save(QString text){
@GaretJax
GaretJax / test_events.py
Last active August 29, 2015 14:05
after_flush_postexec events skipped when removing handlers
View test_events.py
python -m unittest test_events
.F...F
======================================================================
FAIL: testDoubleRemove (sqlalchemy_mptt.tests.test_flush.FlushingTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "sqlalchemy_mptt/tests/test_flush.py", line 60, in testDoubleRemove
self.assertEqual(self.calls, 2)
AssertionError: 1 != 2
@4b5ent1
4b5ent1 / subscriber.py
Last active August 29, 2015 14:00
pyramid.events.BeforeRender: fix the UnicodeDecodeError exception on rendering template
View subscriber.py
# encoding:utf-8
u"""
用比较恶心的办法解决模板渲染时出现 UnicodeDecodeError 的问题
This subscriber try to convert all <str> to <unicode>
functional available for Chameleon, Jinja2, and Mako
@mgedmin
mgedmin / conf.py.rst
Created July 22, 2013 10:37
HOWTO add "Show on GitHub" and "Edit on GitHub" links to the Sphinx sidebar
View conf.py.rst

Edit on GitHub links for Sphinx

Create _ext/ and _templates/ subdirectories.

Move edit_on_github.py into the _ext/ subdirectory.

Move sourcelink.html into the _templates/ subdirectory.

Add the following after the import sys, os line

@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active February 27, 2024 03:49
tmux shortcuts & cheatsheet
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts
View multiple_ssh_setting.md

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@hrldcpr
hrldcpr / tree.md
Last active December 5, 2023 09:57
one-line tree in python
View tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!