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> |
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
# 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
// 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
// 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
# 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
from os import environ | |
environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1' | |
from pygame import Rect, init, K_LEFT, K_RIGHT, K_UP, K_DOWN, K_RETURN, K_ESCAPE, K_r, K_p, QUIT | |
from pygame.event import get | |
from pygame.font import Font | |
from pygame.key import get_pressed | |
from pygame.display import set_mode, flip | |
from pygame.draw import rect | |
from pygame.time import delay | |
from random import randint, choice |
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
#include <stdio.h> | |
void*memset(void*s,int c,int n){} | |
int main(int argc, char *argv[]) { | |
while(argc --> 0) argv[argc] = 0; | |
printf("%s\n", argv); | |
return 0; | |
} | |
/* | |
`gcc .\main.c -O3 -o main;./main` | |
and |
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
# enable "Alt" + "+" + "3" + "3" to write "3" (unicode input) | |
from winreg import * | |
SetValueEx(OpenKey(HKEY_CURRENT_USER, r"Control Panel\Input Method", 0, KEY_ALL_ACCESS), "EnableHexNumpad", 0, 1, "1") |
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
from pypp import Str, Int, Float, cout, cin, endl | |
if __name__ == "__main__": | |
str1, str2, int1, float1 = Str(), Str(), Int(), Float() | |
cout << "Hello, " << "world!" << endl | |
cin >> str1 >> str2 >> int1 >> float1 | |
cout << str1 << endl << str2 << endl << (int1 + Int(1)) << endl << float1 << endl |
NewerOlder