Skip to content

Instantly share code, notes, and snippets.

View tocsindata's full-sized avatar
💭
Contact me via https://tocsindata.com

Daniel Foscarini tocsindata

💭
Contact me via https://tocsindata.com
View GitHub Profile
@adrianorsouza
adrianorsouza / ico-gen.php
Created November 8, 2019 20:49
PHP Icon Favicon.ico Generator
<?php
/*
Copyright 2011-2013 Chris Jean & iThemes
Licensed under GPLv2 or above
Version 1.0.2
*/
class PHP_ICO {
/**
* Images in the BMP format.
*
@swapnilshrikhande
swapnilshrikhande / function.php
Created April 26, 2016 10:08 — forked from YugalXD/function.php
Send mail with mailgun api by PHP CURL.
<?php
define('MAILGUN_URL', 'https://api.mailgun.net/v3/DOMAIN_NAME');
define('MAILGUN_KEY', 'KEY');
function sendmailbymailgun($to,$toname,$mailfromnane,$mailfrom,$subject,$html,$text,$tag,$replyto){
$array_data = array(
'from'=> $mailfromname .'<'.$mailfrom.'>',
'to'=>$toname.'<'.$to.'>',
'subject'=>$subject,
'html'=>$html,
@dominickp
dominickp / get_date_diff.php
Last active November 8, 2023 20:56 — forked from ozh/gist:8169202
Add text to tell whether date was past/future. "2 days ago" or "2 days from now".
<?php
/**
* Get human readable time difference between 2 dates
*
* Return difference between 2 dates in year, month, hour, minute or second
* The $precision caps the number of time units used: for instance if
* $time1 - $time2 = 3 days, 4 hours, 12 minutes, 5 seconds
* - with precision = 1 : 3 days
* - with precision = 2 : 3 days, 4 hours
* - with precision = 3 : 3 days, 4 hours, 12 minutes
@wboykinm
wboykinm / geojson.php
Last active June 14, 2024 20:01
Sample PHP to Point GeoJSON
<?php
/**
* PHP GeoJSON Constructor, adpated from https://github.com/bmcbride/PHP-Database-GeoJSON
*/
# Connect to MySQL database
$conn = new PDO('mysql:host=localhost;dbname=mydatabase','myusername','mypassword');
# However the User's Query will be passed to the DB:
$sql = 'SELECT * from GDA_database WHERE user_query = whatever';
@BilalBudhani
BilalBudhani / rssToJson
Created January 31, 2013 10:04
PHP function to convert simple RSS to JSON
public function Parse ($url) {
$fileContents= file_get_contents($url);
$fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents);
$fileContents = trim(str_replace('"', "'", $fileContents));
$simpleXml = simplexml_load_string($fileContents);
$json = json_encode($simpleXml);
return $json;
}