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 / 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);
@hctilg
hctilg / index.php
Created September 15, 2024 08:59
Get audio tags in PHP
<?php
require_once './getid3/getid3.php';
/**
* @param string $audio URL or local Path
* @return array
*/
function get_audio_tags($audio) {
// Initialize getID3 engine
from bs4 import BeautifulSoup
from requests import get
class github():
def __init__(self, user):
self.user = user
def following(self):
return self.get_users("following")
@hctilg
hctilg / README.md
Created August 14, 2024 17:43
Send HTTP requests easily using JavaScript

requests.js

Send HTTP requests easily using JavaScript

import RequestsJs using this script link

<script src="requests.js" async></script>

Example

@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
Created July 31, 2024 03:29
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
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
@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