Skip to content

Instantly share code, notes, and snippets.

View shuttle1987's full-sized avatar
🙂
Writing a lot!

Janis Lesinskis shuttle1987

🙂
Writing a lot!
View GitHub Profile
@zzzeek
zzzeek / msg373145.rst
Last active October 22, 2022 12:36
asyncio support for SQLAlchemy (and Flask, and any other blocking-IO library)

This is a cross post of something I just posted on the Python bug tracker at https://bugs.python.org/msg373145.

I seem to have two cents to offer so here it is. An obscure issue in the Python bug tracker is probably not the right place for this so consider this as an early draft of something that maybe I'll talk about more elsewhere.

> This basically divides code into two islands - async and non-async

@zzzeek
zzzeek / asyncio_plus_greenlet.py
Last active July 5, 2023 16:32
An asyncio program that runs rows into a Postgresql database, using blocking style code to actually run the database commands
"""This program is exactly the same as that of
https://gist.github.com/zzzeek/33943060f7a08cf9e82bf8df1f0f75de ,
with the exception that the add_and_select_data function is written in
synchronous style.
UPDATED!! now includes refinements by @snaury and @Caselit . SIMPLER
AND FASTER!!
@0xnurl
0xnurl / Dockerfile
Created March 14, 2018 13:27
Compile OpenFST Python Extension for Python 3
FROM ubuntu:16.04
# Use bash (Ubuntu default is dash)
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Ubuntu packages
RUN apt-get update && apt-get install -y ssh gcc=4:5.3.1-1ubuntu1 g++=4:5.3.1-1ubuntu1 make vim zlib1g-dev libbz2-dev libssl-dev python-dev man libreadline-dev build-essential libreadline-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev python3 python3-dev
# Install Python 3.6 from source for optimizations
RUN cd /tmp && wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz && tar xzvf Python-3.6.0.tgz && cd Python-3.6.0 && ./configure && make && make install && cd /tmp && wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py
@JPvRiel
JPvRiel / apt_pinning_priorities.md
Last active April 22, 2024 19:42
Apt package pinning and priorities
@hartror
hartror / reading-list.md
Last active December 11, 2018 01:59
Rory's Reading List
@juhaelee
juhaelee / react-typescript.md
Last active January 26, 2023 00:52
React + Typescript Cheatsheet

React + Typescript Cheatsheet

Setup

If you use atom... download & install the following packages:

What are Typescript type definition files? (*.d.ts)

@peterhurford
peterhurford / pytest-fixture-modularization.md
Created July 28, 2016 15:48
How to modularize your py.test fixtures

Using py.test is great and the support for test fixtures is pretty awesome. However, in order to share your fixtures across your entire module, py.test suggests you define all your fixtures within one single conftest.py file. This is impractical if you have a large quantity of fixtures -- for better organization and readibility, you would much rather define your fixtures across multiple, well-named files. But how do you do that? ...No one on the internet seemed to know.

Turns out, however, you can define fixtures in individual files like this:

tests/fixtures/add.py

import pytest

@pytest.fixture
@freakdesign
freakdesign / extract-image-liquid
Last active May 8, 2023 14:15
Get image src from a string in Liquid
{% if article.content contains "<img" %}
{% assign src = article.content | split: 'src="' %}
{% assign src = src[1] | split: '"' | first | replace: '//cdn', 'http://cdn' | replace: 'http:http://', 'http://' | remove: 'https:' %}
{% endif %}