Skip to content

Instantly share code, notes, and snippets.

View medamin25's full-sized avatar

Mohamed Amin Boubaker medamin25

View GitHub Profile
@cp6
cp6 / curl_func.php
Last active August 19, 2022 14:24
Ultimate PHP cURL function example
<?php
function doCurl(string $url, string $type = 'GET', array $headers = [], array $post_fields = [], string $user_agent = '', string $referrer = '', bool $follow = true, bool $use_ssl = false, int $con_timeout = 10, int $timeout = 40)
{
$crl = curl_init($url);
curl_setopt($crl, CURLOPT_CUSTOMREQUEST, $type);
curl_setopt($crl, CURLOPT_USERAGENT, $user_agent);
curl_setopt($crl, CURLOPT_REFERER, $referrer);
if ($type == 'POST') {
curl_setopt($crl, CURLOPT_POST, true);
if (!empty($post_fields)) {
@flangofas
flangofas / ConvertMS.js
Last active February 29, 2024 17:22
JS: Convert Milliseconds to days? minutes? seconds? or all!
function convertMiliseconds(miliseconds, format) {
var days, hours, minutes, seconds, total_hours, total_minutes, total_seconds;
total_seconds = parseInt(Math.floor(miliseconds / 1000));
total_minutes = parseInt(Math.floor(total_seconds / 60));
total_hours = parseInt(Math.floor(total_minutes / 60));
days = parseInt(Math.floor(total_hours / 24));
seconds = parseInt(total_seconds % 60);
minutes = parseInt(total_minutes % 60);
@elundmark
elundmark / secure_bash_passwords.sh
Created July 18, 2012 12:15
Store and use secure passwords in bash
#!/bin/bash
# Mixing in python with bash we can easily retrieve our passwords securely in our shell scripts.
# Read this first: https://live.gnome.org/GnomeKeyring/SecurityPhilosophy
# Make sure your distro has gnome-keyring-daemon installed and running at login,
# as well as python-keyring installed (sudo apt-get install python-keyring)
##
# Follow these steps to see what it does. Verify by looking in Seahorse for your password.
##