Skip to content

Instantly share code, notes, and snippets.

View serialc's full-sized avatar

Cyrille Médard de Chardon serialc

View GitHub Profile
@serialc
serialc / email_structuring.php
Created September 9, 2021 14:36
How to send an email from PHP that is well formed. Failure to provide all the necessary and well structured information can result in email contents being placed in attachments rather than in email content.
<?php
# This is a fragment, needs to be integrated
# This doesn't send the sender's information - uses the system's email
# parameters to customize, perhaps in a function
$to_name = "MJ Watson";
$to_email = "mjwatson@marvel.com";
#$from_name = "P Parker";
#$from_email = "pparker@marvel.com;
$subject = "test email";
@serialc
serialc / long2utmepsg.R
Last active July 8, 2020 18:29
R script to transform longitude to UTM zone and EPSG code for projections
# Functions to convert a longitude to the UTM zone and EPSG code
# Get the UTM zone for a given longitude
long2UTM <- function(long) {(floor((long + 180)/6) %% 60) + 1 }
# get the EPSG code (int) for a given longitude and hemisphere
UTMzone2EPSG <- function(utmzone, hemisphere) {
if( tolower(hemisphere) %in% c("north", "n") ) {
if( utmzone < 10 ) { epsg = '3260' } else { epsg = '326' }
} else if( tolower(hemisphere) %in% c("south", "s") ) {
@serialc
serialc / google_direction_points_decoder.R
Last active January 22, 2018 22:03
A google maps points decoder function in R
# Decode Google encoding lat,long point series
# Based on JavaScript code by Mapbox on Github: https://github.com/mapbox/polyline/blob/master/src/polyline.js
# Google algorithm: http://code.google.com/apis/maps/documentation/polylinealgorithm.html
decode_google_path <- function( point_string ) {
# break string into individual characters
chars <- strsplit(point_string, '')[[1]]