Skip to content

Instantly share code, notes, and snippets.

View typerandom's full-sized avatar

Robin Orheden typerandom

View GitHub Profile
@typerandom
typerandom / phpmailer-simple.php
Created November 21, 2012 17:25
PHPMailer - Simple example
<?php
require 'class.phpmailer.php';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->IsHTML(true);
$mail->Host = 'smtp1.example.com';
$mail->SMTPAuth = true;
@typerandom
typerandom / php-mail-html-mime.php
Created November 21, 2012 16:39
PHP mail-function - HTML mime example
<?php
// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
@typerandom
typerandom / comlang-template-for-sending-email-with-csharp
Created September 20, 2012 12:21
Comlang Template for Sending Email with AlphaMail using C#/.NET
<html>
<body>
<b>Name:</b> <# payload.FirstName " " payload.LastName #><br>
<b>Date of Birth:</b> <# payload.DateOfBirth #><br>
<# if (payload.Id != null) { #>
<a href="http://company.com/sign-up">Sign Up Free!</a>
<# } else { #>
<a href="http://company.com/login?username=<# urlencode(payload.UserName) #>">Sign In</a>
<# } #>
@typerandom
typerandom / csharp-send-email-alphmail.cs
Created September 19, 2012 18:57
Send Email through AlphaMail using C#/.NET
using System;
using Comfirm.AlphaMail.Services.Client;
using Comfirm.AlphaMail.Services.Client.Entities;
namespace Comfirm.Examples.AlphaMail
{
class Person
{
public int Id { get; set; }
public string UserName { get; set; }
@typerandom
typerandom / csharp-send-email-native.cs
Created September 19, 2012 18:20
Send Email natively with C#/.NET
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Mail;
namespace Comfirm.Examples.Native
{
class Program
@typerandom
typerandom / time-elapsed-approximation-format.js
Created April 23, 2012 11:48
Convert/format a date to the highest time unit.
function getApproximateElapsedTime(date) {
var timeDelta = new Date().getTime() - date.getTime(); // ms
var map = [
{ unit: 1000, singular: "%d second", plural: "%d seconds" },
{ unit: 60, singular: "%d minute", plural: "%d minutes" },
{ unit: 60, singular: "%d hour", plural: "%d hours" },
{ unit: 24, singular: "%d day", plural: "%d days" },
{ unit: 29.53, singular: "%d month", plural: "%d months" }, // Avg. days per month
{ unit: 12, singular: "%d year", plural: ">%d years" }