Skip to content

Instantly share code, notes, and snippets.

View Eugeny's full-sized avatar

Eugene Eugeny

View GitHub Profile
@Eugeny
Eugeny / README.md
Last active April 16, 2024 02:56
Full-on SSH clone in asyncio

An "SSH" clone in Python asyncio

This is a demo on how to handle remote process execution in asyncio

Obviously don't use in production as there's no auth.

  • Supports starting processes and killing them
  • Streams stdin/out/err
  • Optional PTY mode with resizing support
#!/usr/bin/python
# -*- coding: utf-8 -*-
import subprocess
__all__ = ["transform"]
__version__ = '0.3'
__author__ = 'Christoph Burgmer <cburgmer@ira.uka.de>'
__url__ = 'http://github.com/cburgmer/upsidedown'
@Eugeny
Eugeny / sidebar.js
Created April 23, 2021 12:54
macOS finder favourites parser
const bplist = require('bplist-parser');
const { isObject } = require('rxjs/internal-compatibility');
(async () => {
let content = await bplist.parseFile(process.env.HOME + '/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.FavoriteItems.sfl2')
content = content[0];
let root = content.$top.root
@Eugeny
Eugeny / readme.md
Last active March 7, 2023 11:40
Frame accurate video reader - OpenCV VideoCapture replacement

OpenCV's VideoCapture is broken and hasn't been fixed for the last 5 years: opencv/opencv#9053

This is a PyAV based replacement. Unlike other implementations it can seek at any time.

How to use:

reader = VideoReader('video.mp4')
reader.seek(reader.total_frames - 100)  # frame number 
while True:
@Eugeny
Eugeny / 1.sql
Created February 20, 2023 16:02
drop table if exists test;
set character_set_client = utf8mb4;
create table test (x varchar(1024) character set utf8mb4 COLLATE utf8mb4_general_ci) character set utf8mb4 COLLATE utf8mb4_general_ci;
insert into test values ("👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍
@Eugeny
Eugeny / MatContextMenuTrigger.ts
Created February 16, 2023 16:12
Angular Material context menu trigger
import { ConnectedPosition, FlexibleConnectedPositionStrategy } from '@angular/cdk/overlay'
import { Directive, HostListener, Input } from '@angular/core'
import { MatMenuPanel, _MatMenuTriggerBase } from '@angular/material/menu'
import { fromEvent, merge } from 'rxjs'
// @Directive declaration styled same as matMenuTriggerFor
// with different selector and exportAs.
@Directive({
selector: `[matContextMenuTriggerFor]`,
@Eugeny
Eugeny / 1.ts
Last active February 14, 2023 15:28
// -----------
// Challenge 0
// -----------
// function F<T> (f: ???): Promise<T> {
// return new Promise(f)
// }
// -----------
// Challenge 1
@Eugeny
Eugeny / memuse.md
Last active February 1, 2023 01:57
memuse - measure a total unique RAM taken by process tree
diff --git a/apps/cloud/serializers.py b/apps/cloud/serializers.py
index 15e6dd28a..433de2006 100644
--- a/apps/cloud/serializers.py
+++ b/apps/cloud/serializers.py
@@ -19,7 +19,7 @@ class CloudConnectionSerializer(ModelSerializer):
class ClickGallerySerializer(Serializer):
- id = fields.IntegerField()
+ id = fields.IntegerField(read_only=True)
diff --git a/apps/cloud/serializers.py b/apps/cloud/serializers.py
index 15e6dd28a..433de2006 100644
--- a/apps/cloud/serializers.py
+++ b/apps/cloud/serializers.py
@@ -19,7 +19,7 @@ class CloudConnectionSerializer(ModelSerializer):
class ClickGallerySerializer(Serializer):
- id = fields.IntegerField()
+ id = fields.IntegerField(read_only=True)