Skip to content

Instantly share code, notes, and snippets.

View mr-linch's full-sized avatar
🚧
Work In Progress

Sasha Savchuk mr-linch

🚧
Work In Progress
View GitHub Profile
@mr-linch
mr-linch / capture_darwin.py
Last active January 15, 2024 13:50
Make fast screenshot of Mac OS window from Python (using native api bindings, 30 fps on Air M2)
import Quartz as QZ
import Quartz.CoreGraphics as CG
import AppKit as AK
import numpy as np
import numpy.typing as npt
import typing as t
Matcher = t.Callable[[dict[str, t.Any]], bool]
@mr-linch
mr-linch / docker-compose.yml
Last active August 17, 2022 12:40
Docker Compose with Postgres 14 and PgBouncer for local development
version: '3.9'
volumes:
postgres-data:
driver: local
services:
postgres:
image: postgres:14-alpine
@mr-linch
mr-linch / create-read-only-user.sql
Last active February 6, 2021 19:42
👁‍🗨 PostgreSQL: Create readonly user
-- create user (e.g. metabase)
create user metabase with encrypted password 'password';
-- allow user connect to db
grant connect on database site to metabase;
-- allow user access to schema
grant usage on schema public to metabase;
-- grant select on existing tables
@mr-linch
mr-linch / cloud-config.yml
Last active February 11, 2021 14:39
Cloud Config / Docker
#cloud-config
package_update: true
package_upgrade: true
runcmd:
# install docker
- curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh && rm get-docker.sh
botsford.link/content/static/061e6cb2f600fb8ebc5b2fe1a6f6afa9/4462.html
HTTP/1.1 302 Found
Cache-Control: no-store, no-cache, must-revalidate, max-age=0
Connection: keep-alive
Content-Type: text/html; charset=utf-8
Date: Sun, 26 Feb 2017 04:14:55 GMT
Expires: Mon, 04 Dec 1999 21:29:02 GMT
Location: https://c.opinion.com.ua/?q=286664773752&p=138834&c=3&target=https://youtu.be/VyUKOQkTiV4
Pragma: no-cache
(function(){function e(e){function t(t,n,r,i,o,s){for(;o>=0&&s>o;o+=e){var a=i?i[o]:o;r=n(r,t[a],a,t)}return r}return function(n,r,i,o){r=b(r,o,4);var s=!E(n)&&y.keys(n),a=(s||n).length,u=e>0?0:a-1;return arguments.length<3&&(i=n[s?s[u]:u],u+=e),t(n,r,i,s,u,a)}}function t(e){return function(t,n,r){n=x(n,r);for(var i=C(t),o=e>0?0:i-1;o>=0&&i>o;o+=e)if(n(t[o],o,t))return o;return-1}}function n(e,t,n){return function(r,i,o){var s=0,a=C(r);if("number"==typeof o)e>0?s=o>=0?o:Math.max(o+a,s):a=o>=0?Math.min(o+1,a):o+a+1;else if(n&&o&&a)return o=n(r,i),r[o]===i?o:-1;if(i!==i)return o=t(l.call(r,s,a),y.isNaN),o>=0?o+s:-1;for(o=e>0?s:a-1;o>=0&&a>o;o+=e)if(r[o]===i)return o;return-1}}function r(e,t){var n=D.length,r=e.constructor,i=y.isFunction(r)&&r.prototype||a,o="constructor";for(y.has(e,o)&&!y.contains(t,o)&&t.push(o);n--;)o=D[n],o in e&&e[o]!==i[o]&&!y.contains(t,o)&&t.push(o)}var i=this,o=i._,s=Array.prototype,a=Object.prototype,u=Function.prototype,c=s.push,l=s.slice,f=a.toString,h=a.hasOwnProperty,p=Array.isArr
@mr-linch
mr-linch / weblancer.py
Last active November 4, 2023 18:17
Исходный код для урока (https://youtu.be/KPXPr-KS-qk)
#!/usr/bin/env python3
import csv
import urllib.request
from bs4 import BeautifulSoup
BASE_URL = 'http://www.weblancer.net/projects/'
@mr-linch
mr-linch / vectormath.py
Created June 15, 2014 14:07
Minimal implementations of vector mathematics for game development on the python
import math
import collections
"""Minimal implementations of vector mathematics for game development on the python.
Usage:
import vector
current_position = (5, 2)
destination = (8, 4)
@mr-linch
mr-linch / camera.py
Created June 8, 2014 10:19
First person camera for pyglet
# -*- coding: utf-8 -*-
import math
import collections
import pyglet
class FirstPersonCamera(object):
"""First person camera implementation
@mr-linch
mr-linch / pygame_application.py
Created March 23, 2014 22:24
Class simplifies work with the application for PyGame
# -*- coding: utf-8 -*-
import sys
import pygame
__author__ = "Alexander Savchuk"
class Singleton(type):
"""Implementation of the Singleton pattern"""
_instances = {}