Skip to content

Instantly share code, notes, and snippets.

View erdum's full-sized avatar

Erdum erdum

View GitHub Profile
@erdum
erdum / request-tester.php
Created October 3, 2023 08:00
Get insight of the incoming http requests
<?php
$request_payload = !empty($_POST) ? $_POST : array();
$request_payload = empty($_POST) && !empty($_GET) ? $_GET : $request_payload;
$request_payload = isset($_SERVER['CONTENT_TYPE'])
&& $_SERVER['CONTENT_TYPE'] == 'application/json'
? json_decode(file_get_contents('php://input'), true)
: $request_payload;
$request_details = array(
@erdum
erdum / random-string.js
Last active November 29, 2023 11:23
Generates a random string of alphanumeric characters with the specified length
btoa(Math.random()).substr(0, 10);
@erdum
erdum / yt-audio-downloader.py
Last active September 16, 2023 12:59
Youtube Audio Downloader
import os
from pytube import YouTube
import time
from urllib.parse import urlparse, parse_qs
import gradio as gr
def download_audio_from_youtube_url(url: str) -> gr.outputs.File:
filename = 'yt-audio-{timestamp}.mp4'.format(timestamp=round(time.time()))
try:
@erdum
erdum / yt-audio.py
Last active September 14, 2023 06:53
Download highest quality audio of YouTube video
from pytube import YouTube
yt = YouTube('http://youtube.com/watch?v=2lAe1cqCOXo')
yt.streams.get_audio_only().download(filename="test.mp3")
@erdum
erdum / countries.json
Created August 18, 2023 07:06
List of countries and their mobile code
[
{
"name": "Afghanistan",
"mobile_code": "+93",
"iso_code": "AF",
"flag_emoji": "🇦🇫"
},
{
"name": "Albania",
"mobile_code": "+355",
@erdum
erdum / HandleUploadSaveAsWebp.php
Created May 12, 2022 20:43
Handle image upload in laravel and convert them to webp for storage.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ImageUploadController
{
public function saveToWebp($src, $destination, $extension)
{