Skip to content

Instantly share code, notes, and snippets.

View potaycat's full-sized avatar

Long potaycat

  • Mekong Delta
  • 04:08 (UTC +07:00)
View GitHub Profile
import os
import sys
import time
import importlib
import signal
import re
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.gzip import GZipMiddleware
from packaging import version
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.py]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.js]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.env]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.json]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.java]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.ahk]
"PerceivedType"="text"
@potaycat
potaycat / Sprite.js
Last active February 14, 2022 07:00
My sprite base class for <canvas> rendering
const debug = 0
export default class Sprite {
constructor(x, y, width, height) {
this.x = x
this.y = y
this.width = width
this.height = height
this.angle = 0 // rad
import cv2, time, torch
from torchvision import transforms
import numpy as np
import win32gui, win32ui, win32con, win32api # https://pypi.org/project/pywin32/
def grab_screen(region=None):
hwin = win32gui.GetDesktopWindow()
@potaycat
potaycat / TileMapGenerate.cs
Created April 9, 2020 21:28
Dungeon map generator inspired by PMD. For Godot
using Godot;
using System;
using System.Text;
public class GenScript : TileMap {
private const int roomsHorz = 4; // numbers of columns of region
Random rnd = new Random();
private _ugameCtrl cntrllr;
private (int left, int top, int width, int height) dim;
private Vector2 ul, dr;
<template>
<div
class="wf-background dsplay--flx--clmn"
:style="rendering?'cursor:progress':null"
>
<div
class="wf-container dsplay--flx--clmn"
@mouseup="down=[false, false]"
@mouseleave="down=[false, false]"
>
@potaycat
potaycat / PaginationMixin.py
Last active October 24, 2019 06:14
Django Rest Framework stateless pagination mixin
class PaginationMixin(object):
'''
Supports multiple sorting fields/anotations
The working principle is that it uses offset object to get
list of next items
Instruction of use:
step 1: inherit this mixin to your view class
step 2: define list of ordering fields/anotates in
@potaycat
potaycat / flush migrations.txt
Last active November 10, 2019 20:45
useful terminal commands i found online
find . -path "*/migrations/*.py" -not -name "__init__.py" -not -path "./venv/*" -delete
find . -path "*/migrations/*.pyc" -not -path "./venv/*" -delete
@potaycat
potaycat / fanSignals.txt
Created September 15, 2019 15:48
Mitsubishi fan remote control IR signal frequency. Captured using Arduino and IR receiver. Though forgot to label them
/ ON, OFF (in 10's of microseconds)
336, 160,
48, 118,
46, 120,
46, 42,
42, 42,
40, 44,
40, 120,
46, 42,
42, 42,
@potaycat
potaycat / ytFirst6VidsInAQueryToAPage.py
Created September 14, 2019 07:40
one of my first encounter to the web. a recreate of Tom Scott's youtube privacy demo in a presentation of his
import urllib
import urllib2
from bs4 import BeautifulSoup
from lxml import etree
def main():
textToSearch = raw_input('tim video cho thuyet trinh: ')
query = urllib.quote(textToSearch)
url = "https://www.youtube.com/results?search_query=" + query
response = urllib2.urlopen(url)