Skip to content

Instantly share code, notes, and snippets.

View hctilg's full-sized avatar
🥀
Depression and Studying for the entrance exam (Konkour)

Mahi ✨ hctilg

🥀
Depression and Studying for the entrance exam (Konkour)
View GitHub Profile
<?php
/*
* Source https://github.com/SafaSafari/freeproxylists
*/
function get($proxy = null, $page = 1) {
$ch = curl_init('http://www.freeproxylists.net/' . ($page > 1 ? '?page=' . $page : null));
$options[CURLOPT_FOLLOWLOCATION] = true;
$options[CURLOPT_RETURNTRANSFER] = true;
@hctilg
hctilg / translate_srt.php
Created July 24, 2025 06:57
Subtitle (srt files) translation with PHP
<?php
function translate($text, $source_lang = 'en', $target_lang = 'fa') {
$url = 'https://translate.googleapis.com/translate_a/single?';
$url .= http_build_query([
'client' => 'gtx',
'sl' => $source_lang,
'tl' => $target_lang,
'dt' => 't',
'q' => $text,
@hctilg
hctilg / redirectcheck.php
Created July 18, 2025 10:26
Check your URL redirect for accuracy.
<?php
// Check if cURL is installed
if (!function_exists('curl_init')) {
die("<h2>Error:</h2><p>PHP cURL extension is not enabled. Please enable it to use this script.</p>");
}
function validateUrl($url) {
return filter_var($url, FILTER_VALIDATE_URL);
}
@hctilg
hctilg / ping.php
Created July 16, 2025 15:22
How can I ping a server port with PHP?
<?php
function ping($ip, $port = 80, $timeout = 1) {
try {
$output = [];
$result = null;
exec("ping -c 4 " . escapeshellarg($ip), $output, $result);
if ($result === 0) {
@hctilg
hctilg / whitenoise.sh
Created May 20, 2025 10:23
Play whitenoise on Linux
#!/usr/bin/env bash
# Requirement: sox
# For Example : `sudo pacman -S sox`
while true; do
play -n synth 3600 whitenoise
done
@hctilg
hctilg / index.php
Created February 25, 2025 15:07
GitHub Checker
<?php
class GitHub {
public $username;
public function __construct(string $username) {
// Check username
if (empty($username))
die("Username should not be empty!\n");

Fibonacci Sequence Generator

This Python script generates the Fibonacci sequence up to a specified maximum number of terms. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1.

How It Works

The script defines a generator function fibonacci(n) that yields the Fibonacci numbers up to n. The main part of the script prompts the user to input the maximum number of terms they want to generate and then prints each term of the Fibonacci sequence.

Code

import os
import re
images = [img for img in os.listdir(folder_path) if img.endswith(('.png', '.jpg', '.jpeg'))]
images.sort(key=lambda filename: [int(text) if text.isdigit() else text for text in re.split('([0-9]+)', filename)])
print(images)
"The number of segments cannot exceed the length of the list!"
def split_list(lst, n):
if n <= 0: return []
elif n > len(lst):
return "The number of segments cannot be greater than the length of the list!"
else:
avg = len(lst) / n
out = []
last = 0.0
@hctilg
hctilg / copy.js
Created October 8, 2024 20:23
Copy to clipboard with Javascript
function copyToClipboard(text, success) {
if (navigator.clipboard && window.isSecureContext) {
return navigator.clipboard.writeText(text).then(success).catch(err => {
console.error('Failed to copy text: ', err);
});
} else {
const textarea = document.createElement('textarea');
textarea.value = text;
document.body.appendChild(textarea);