Skip to content

Instantly share code, notes, and snippets.

View potaycat's full-sized avatar

Long potaycat

  • Mekong Delta
  • 18:11 (UTC +07:00)
View GitHub Profile
@potaycat
potaycat / main.py
Created October 31, 2018 15:51
Protober Quiz
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog
from random import randint
import copy
import xmlHandler
class MainWindow:
@potaycat
potaycat / arduinoSender.py
Last active September 15, 2019 15:29
bluetooth controlled 4 motors driver with python/pygame on pc client, and arduino
import serial, platform, glob
# A function that tries to list serial ports on most common platforms
def list_serial_ports():
system_name = platform.system()
if system_name == "Windows":
# Scan for available ports.
available = []
for i in range(256):
try:
@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)
@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 / 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 / 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
<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 / 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;
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 / 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