Skip to content

Instantly share code, notes, and snippets.

View hctilg's full-sized avatar
🦋
Always Online But Not Always Avalable!

Mahoor (Mahi) ✨ hctilg

🦋
Always Online But Not Always Avalable!
View GitHub Profile
@hctilg
hctilg / range.js
Created July 31, 2024 03:30
Sequence generator function
// Sequence generator function
const range = (start = 0, stop = 0, step = 0) => Array.from({ length: (stop - start) / step + 1 }, (_, i) => start + (i * step));
@hctilg
hctilg / colors.sh
Last active December 16, 2025 15:10
Colors & ClearScreen Ascii code in bash Script
#!/usr/bin/env bash
clear_screen () {
echo -en '\033[2J\033[u'
}
# Reset
Color_rst='\033[0m' # Text Reset
# Regular Colors
@hctilg
hctilg / ip.php
Created July 30, 2024 18:55
Get real ip address
<?php
function real_ip() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
// Check IP from internet shared proxy
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
// Check IP from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif (!empty($_SERVER['REMOTE_ADDR'])) {
@hctilg
hctilg / element.js
Created July 29, 2024 14:49
create Element From HTML using JavaScript
/**
* @param {String} HTML representing any number of sibling elements
* @return {NodeList}
*/
const createElementFromHTML = (htmlString = '') => {
var template = document.createElement('template');
template.innerHTML = htmlString;
return template.content;
}
@hctilg
hctilg / fade.js
Created July 29, 2024 14:48
Animation fadeOut and fadeIn using JavaScript
var fadeInInterval, fadeOutInterval;
const fadeOut = (element, timing=7) => {
clearInterval(fadeInInterval);
clearInterval(fadeOutInterval);
element.fadeOut = timing => {
var newValue = 1;
element.style.opacity = 1;
@hctilg
hctilg / reverse_string.js
Created July 29, 2024 14:46
Reverse strings in Javascript
String.prototype.reverse = function () {
var str = this + '';
// Check the input is invalid
if (!str || str.length < 2 ||
typeof str !== 'string') {
return str;
}
// Take empty array revArray
@hctilg
hctilg / remove_duplicates.js
Created July 29, 2024 14:45
Remove duplicates in Javascript
const remove_duplicates = _array => {
let unique = [];
_array.forEach(element => {
if (!unique.includes(element)) unique.push(element);
});
return unique;
}
@hctilg
hctilg / secure_erase.sh
Created July 17, 2024 20:21 — forked from tavallaie/secure_erase.sh
**Secure Data Erasure Script (Bash)** This Bash script securely erases data from a specified device with random data, ensuring irrecoverability. Use with caution.
#!/bin/bash
# Check if the script is run with superuser privileges
if [ "$EUID" -ne 0 ]; then
echo "Please run this script as root (sudo)."
exit 1
fi
# Prompt the user for the target devices
read -p "Enter the target devices (e.g., /dev/sdX /dev/sdY): " target_devices
@hctilg
hctilg / stt.py
Created June 23, 2024 14:34
Sound to Text (fa-IR)
import speech_recognition as sr
from pydub import AudioSegment
audio_file = "your_audio_file_path_here.mp3"
sound = AudioSegment.from_mp3(audio_file)
sound.export("output.wav", format="wav")
recognizer = sr.Recognizer()
with sr.AudioFile("output.wav") as source:
audio_data = recognizer.record(source)
<?php
// checking the exists Library.
if (!file_exists("finglish.php")) {
copy('https://raw.githubusercontent.com/hctilg/finglish/main/index.php', 'finglish.php');
}
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
$response = [];