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
@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 / viewer.py
Last active November 9, 2024 21:08
Daramet‌ viewer
from selenium import webdriver
from selenium.webdriver.common.by import By
def run(_func):
if __name__ == '__main__':
_func()
def viewer(username, view_number):
for i in range(view_number):
try:
@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 = [];
#include <iostream>
using namespace std;
int main() {
    string sentence, word;
    cout << "Enter a sentence: ";
    getline(cin, sentence);
    cout << "Enter a word: ";