Skip to content

Instantly share code, notes, and snippets.

View leofun01's full-sized avatar
💭
Migrated to Codeberg.

Leo Ventyk leofun01

💭
Migrated to Codeberg.
View GitHub Profile
@leofun01
leofun01 / SomeType.cpp
Created May 22, 2021 22:05
C++ enum template
#include "SomeType.hpp"
#define S SomeType
#define T unsigned char
S operator&(S const l, S const r) { return (S)((T)l & (T)r); }
S operator^(S const l, S const r) { return (S)((T)l ^ (T)r); }
S operator|(S const l, S const r) { return (S)((T)l | (T)r); }
S &operator&=(S &l, S const r) { return l = l & r; }
@leofun01
leofun01 / OldWindowsPhotoViewer.bat
Created December 13, 2020 17:54
Batch script to open image using old Windows Photo Viewer
start %SystemRoot%\System32\rundll32.exe "%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen %~1
@leofun01
leofun01 / Connect-PPPoE-and-HideCredentials.bat
Last active October 30, 2020 15:04
Batch script to connect Windows to the internet using PPPoE.
cls && echo Connect ... && %WinDir%\System32\rasdial.exe "Connection name" "login" "password"
cls && echo Disconnect ... && pause
%WinDir%\System32\rasdial.exe "Connection name" /DISCONNECT && cls
cls
@leofun01
leofun01 / Main.cpp
Last active October 28, 2019 08:17
Matrix_for_topic_11158
// Main.cpp
#include <ctime>
#include <iostream>
#include "Matrix.h"
int main(int argc, char const *argv[]) {
Matrix<int> matrix(3, 5);
srand(time(nullptr));
matrix.init([]() -> int { return rand() % 10; });
@leofun01
leofun01 / MagicNumberHex8CA75BE0.c
Last active January 12, 2019 16:02
Unordered output of 32 values (from 0 to 31) using magic number.
#include <stdio.h>
int main(void) {
unsigned int v3 = 2359778272; // bin(10001100101001110101101111100000) == dec(2359778272) == hex(8CA75BE0)
do
printf(" %i", v3 & 31);
while(v3 >>= 1);
return 0;
}
// Output: 0 16 24 28 30 31 15 23 27 13 22 11 21 26 29 14 7 19 9 20 10 5 18 25 12 6 3 17 8 4 2 1
@leofun01
leofun01 / MagicNumberHexA6F0.c
Last active January 12, 2019 16:07
Unordered output of 16 values (from 0 to 15) using magic number.
#include <stdio.h>
int main(void) {
unsigned short v2 = 42736; // bin(1010011011110000) == dec(42736) == hex(A6F0)
do
printf(" %i", v2 & 15);
while(v2 >>= 1);
return 0;
}
// Output: 0 8 12 14 15 7 11 13 6 3 9 4 10 5 2 1
@leofun01
leofun01 / MagicNumberHexB8.c
Last active January 12, 2019 16:12
Unordered output of 8 values (from 0 to 7) using magic number.
#include <stdio.h>
int main(void) {
unsigned char v = 184; // bin(10111000) == dec(184) == hex(B8)
do
printf(" %i", v & 7);
while(v >>= 1);
return 0;
}
// Output: 0 4 6 7 3 5 2 1