This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
[] + [] // '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scopeName": "source.c.linker", | |
"fileTypes": ["ld"], | |
"foldingStartMarker": "{", | |
"foldingStopMarker": "}", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |
OlderNewer