Skip to content

Instantly share code, notes, and snippets.

View donno2048's full-sized avatar
:octocat:
πŸ΄πŸ˜΄πŸ‘¨β€πŸ’»πŸ”

Elisha Hollander donno2048

:octocat:
πŸ΄πŸ˜΄πŸ‘¨β€πŸ’»πŸ”
View GitHub Profile
@donno2048
donno2048 / create.py
Last active September 21, 2022 19:37
the smallest possible "valid" png
# as far as I know this is the smallest possible "valid" png
open("new.png", "wb").write(b'\x89PNG\r\n\x1a\n\0\0\0\rIHDR\0\0\0\1\0\0\0\1\1\0\0\0\x007n\xf9$\0\0\0\1IDAT0')
# I use it to hide files inside "photos" to send on platforms that won't send executable etc. like so:
open("new.png", "wb").write(b'\x89PNG\r\n\x1a\n\0\0\0\rIHDR\0\0\0\1\0\0\0\1\1\0\0\0\x007n\xf9$\0\0\0\xffIDAT' + open("./snake.com", "rb").read())
@donno2048
donno2048 / stupid.js
Created November 6, 2022 19:40
Stupid things in Node.js
// Stupid things in Node.js
NaN == NaN // false
0.1 + 0.2 == 0.3 // false
[] == true // false
!![] == true // true
0 == [] // true
0 == [0] // true
[] == [0] == 0 // true
[] == [0] // false
[] + [] // ''
@donno2048
donno2048 / pi.c
Created September 30, 2023 18:56
// This will calculate pi, the larger the circle the accurate the calculation
// Based on the winning entry of 1988's IOCCC
#include "stdio.h"
#define _ ++y>x&&x++;
long x = 0, y = 0;
int main(void) {
calc();
printf("%f\n", 4. * y / x / x);
}
void calc() {
@donno2048
donno2048 / main.py
Created April 27, 2024 14:16
motion enhancment
# enhance motion in video, motion is calculated based on the last 10 frames
from cv2 import VideoCapture, VideoWriter_fourcc, VideoWriter, normalize, CAP_PROP_FPS, CAP_PROP_FRAME_WIDTH, CAP_PROP_FRAME_HEIGHT, NORM_MINMAX, CV_8U
from numpy import average
vidcap = VideoCapture("in.mp4")
video = VideoWriter("out.mp4", VideoWriter_fourcc(*"mp4v"), vidcap.get(CAP_PROP_FPS), (int(vidcap.get(CAP_PROP_FRAME_WIDTH)), int(vidcap.get(CAP_PROP_FRAME_HEIGHT))))
success, image = vidcap.read()
last_images = [image] * 10
while success:
motion = (0xff - image + last_images.pop(0)) / 2 # extract motion
motion = average(motion, axis=2, keepdims=True) # greyscale
{
"scopeName": "source.c.linker",
"fileTypes": ["ld"],
"foldingStartMarker": "{",
"foldingStopMarker": "}",
// can't find the source but made this because there was a discussion
// online where many people claimed that if you have two arrays the minimum
// time complexity you can get to find all common sub-sums is around O(2^n)
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>