Skip to content

Instantly share code, notes, and snippets.

View Yilmaz4's full-sized avatar

Yılmaz Alpaslan Yilmaz4

  • İstanbul, Turkey
View GitHub Profile
@Yilmaz4
Yilmaz4 / mp4_to_mp3_converter.py
Created March 24, 2022 19:09
Convert every single *.mp4 file to *.mp3 in the current directory
from moviepy.editor import * # Install with "pip install moviepy" command
import os
for file in [file for file in os.listdir() if os.path.splitext(file)[1] == ".mp4"]:
video = VideoFileClip(file)
video.audio.write_audiofile(os.path.splitext(file)[0] + ".mp3")
@Yilmaz4
Yilmaz4 / to_binary.cpp
Created September 19, 2022 21:07
Function to convert anything to binary representation with a null-terminated string in C++
template <typename type> char* to_binary(type* obj) {
char* binary = static_cast<char*>(malloc(sizeof(*obj) * 8 + (sizeof(*obj) - 1) + 1));
uint64_t idx = 0;
for (int64_t i = sizeof(*obj) - 1; i >= 0; i--) {
unsigned char byte = *((unsigned char*)(obj) + i);
auto* buffer = new char[8];
if (!binary || !buffer) {
return new char[1] {'\0'};
}
for (int64_t j = 7; j >= 0; j--) {