Skip to content

Instantly share code, notes, and snippets.

View heiswayi's full-sized avatar
👽

Heiswayi Nrird heiswayi

👽
View GitHub Profile
@heiswayi
heiswayi / atari.css
Created March 26, 2024 07:10
Atari ST 8x16 System Font
@font-face {
font-family: 'Atari ST 8x16 System Font';
src: url('data:font/woff2;charset=utf-8;base64,d09GMgABAAAAABZkAA4AAAAAh4AAABYHAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP0ZGVE0cGiYGYACHZggEEQgKgeo0gcl0C4QEAAE2AiQDhAoEIAWHVQeIYRtBdHWGHGwcAHD9CrMRFWwcgAjZ9lFRskn17P//mqDGEdXyU3TgNajIaElGuPDT6svhKnys5ed2p0TdtW3YRc7fw28sORJanphupo8OV1FIXjv8zlR1UbGQgYTex56+alsojGa6FZZWn439LHH111OGphmaPr1lpRg3j8j+x2hMPJNLBK1FVs/M7gOhInLAmoTB/U9UFLKPREKJwiBfAgTQ+X3TdK4ioXQ5pUopo5SbF96hUZpEJLIfsHCjlL5KG8DDjFL66Zy3S7BRmqtEbgfnlvOuZkAk41xvYgIVcybFdcv/3zglzrYjyOC4WrqQgslgv4AC/zfpxMLgIBAIHBQOHg4KgUJgUCwMhsMBDlz2aipVDpls+HbbeT4RZk5CJ8gxzzckc5IapnfcA8uDaXvvxaN7PrH6URTC5O6bj0IYLQL+XHuzP7/EspJSYCMqXJ1J0sxbSAlwfLo7HQAQmlwdKwDSZSE7FaZzwpxR7ozwZ98vS7HDnKStUYBnAE2oQkRmbNT3t3+dt2bPYXcUUqSu+u+/N3Ojmb24p1UKyCEVN4zcmLkMgWwkaGzADF81/cTZzhQchapf7SiHBKAJ1uzrmR92L0kmEJyJagfSWg8m+WFSE5EFlFvX0uVCvFJJmAxpSFZkcMVNueuPr33P5F+7w/Eddpjvm6mIiIiKiIqKTmNaDXEnufvq1uwNaUQIzYrSFGJhT4TA1/2qM+CDdxcdMXdbertgImZbrIiEaPizYLBzq0vzq442tR3Ft7B95UBuoujHUY5juBVnOnhq/+AVWf
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@heiswayi
heiswayi / simple-http-file-server.py
Created March 7, 2024 04:04
Simple HTTP File Server - Convenient script to transfer file within LAN
import http.server
import socket
import sys
def check_port_in_use(port):
# Check if the specified port is in use
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
return s.connect_ex(('localhost', port)) == 0
def find_available_port(start_port):

To create a Python web API using FastAPI and Uvicorn as described, follow the steps below:

Firstly, install the required packages:

pip install fastapi uvicorn python-jose[cryptography]

Next, create your main file main.py with the following content:

@heiswayi
heiswayi / encryption-decryption.md
Created November 17, 2023 17:33
Encryption and Decryption in PHP, TypeScript, Ruby, C#, and Batch scripting

PHP + OpenSSL extension

<?php

function encryptData($data, $key, $iv) {
    $cipher = "aes-256-cbc";
    $options = 0;
    $encryptedData = openssl_encrypt($data, $cipher, $key, $options, $iv);
 return $encryptedData;
@heiswayi
heiswayi / cron.py
Created October 19, 2023 01:39
Python script to query REST API endpoint with X interval
import requests
import time
def query_rest_api(api_url):
try:
response = requests.get(api_url)
if response.status_code == 200:
return response.json() # Assuming the API returns JSON data
else:
print(f"Failed to retrieve data. Status code: {response.status_code}")
@echo off
rem Set the time for the hibernation
set /p time="Enter the time for the hibernation (in 24-hour format): "
rem Convert the time to a Unix timestamp
rem (This is necessary for the shutdown command)
set timestamp=%time:~0,2%%time:~3,2%%time:~6,2%000
rem Hibernate the computer
font-family: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;
font-size: .875rem;
line-height: 1.25rem;
font-weight: 400;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
@heiswayi
heiswayi / upload.html
Created November 4, 2022 02:47
Simplified upload form webpage
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Upload</title>
<style>
*,::after,::before{box-sizing:border-box}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;background-color:#fff;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}[tabindex="-1"]:focus:not(:focus-visible){outline:0!important}hr{margin:1rem 0;color:inherit;background-color:currentColor;border:0;opacity:.25}hr:not([size]){height:1px}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}h1{font-size:2.5rem}h2{font-size:2rem}h3{font-size:1.75rem}h4{font-size:1.5rem}h5{font-size:1.25rem}h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:un
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'titleLength' })
export class TitleLengthPipe implements PipeTransform {
transform(title: String): String {
if (title === null) {
return '';
} else if (title.length > 15) {
return title.substring(0, 15) + '...';