Skip to content

Instantly share code, notes, and snippets.

View atrandafir's full-sized avatar

Alexandru Trandafir Catalin atrandafir

View GitHub Profile
@bcls
bcls / convert_milliseconds_to_formatted_time.php
Last active August 10, 2023 12:10
convert milliseconds to formatted time #php
/**
* Converts milliseconds to formatted time or seconds.
* @param int [$ms] The length of the media asset in milliseconds
* @param bool [$seconds] Whether to return only seconds
* @return mixed The formatted length or total seconds of the media asset
*/
function convertTime($ms, $seconds = false)
{
$total_seconds = ($ms / 1000);
@anubhavshrimal
anubhavshrimal / CountryCodes.json
Last active April 14, 2024 13:18 — forked from Goles/CountryCodes.json
Country and Dial or Phone codes in JSON format
[
{
"name": "Afghanistan",
"dial_code": "+93",
"code": "AF"
},
{
"name": "Aland Islands",
"dial_code": "+358",
"code": "AX"
@ravanscafi
ravanscafi / css-color-for-string.php
Last active April 23, 2024 15:47
Random Color from Input's MD5 Hash
<?php
/**
* Generate a consistent* random color for a text input.
* Consistent because it's based on MD5 hash for the input.
* Since both MD5 and CSS colors uses hexa, a substring of the MD5 can be used.
* Clever, huh?
*
* PS: you can get any substring of length 3 (for less colors) or 6 (for more colors) from your hash. Just don't
* randomize it, or you will loose consistency.
@stayallive
stayallive / install.sh
Last active September 20, 2022 17:24
Install PHP 5.5.23 on Plesk 11.5 and 12 (CentOS 6)
#!/bin/bash
# Make sure you are up to date
yum -y update && yum -y install wget
# Install EPEL repository
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# Get us a clean working directory
mkdir /php
@dalethedeveloper
dalethedeveloper / gist:966848
Created May 11, 2011 16:47
Reorder a PHP array, moving items up or down
<?php
/*
A quick set of functions to move items in a non-associative array
up or down by one, shifting the items around it appropriately.
Original usage was to for a set of UP and DOWN buttons to
manipulate the order of an array of items stored in Wordpress option.
*/
$a = array('a','b','c','d','e');
@jakebellacera
jakebellacera / ICS.php
Last active April 19, 2024 09:06
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*