Skip to content

Instantly share code, notes, and snippets.

View 0xdeafcafe's full-sized avatar
🕺
disco disco

Alexander Forbes-Reed 0xdeafcafe

🕺
disco disco
View GitHub Profile

Keybase proof

I hereby claim:

  • I am 0xdeafcafe on github.
  • I am 0xdeafcafe (https://keybase.io/0xdeafcafe) on keybase.
  • I have a public key ASANuGtX01IEwplboVPjan4JEgCc5rltukeTikIVSZPeKwo

To claim this, I am signing this object:

using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
namespace SgTest.Controllers
{
public class InboundController : ApiController
// what were you doing Peaches? ;_;
private function _getTimePlayed($time)
{
/* Check for days, hours, minutes, seconds */
if (preg_match('/P(?P<days>[0-9]*)DT(?P<hours>[0-9]*)H(?P<minutes>[0-9]*)M(?P<seconds>[0-9]*)S/s', $time, $regs))
{
/* now dump */
$totalSeconds = ($regs['days'] * 86400) + ($regs['hours'] * 3600) + ($regs['minutes'] * 60) + $regs['seconds'];
}
@0xdeafcafe
0xdeafcafe / NetworkInformationHelper.cs
Created July 9, 2014 17:19
NetworkInformationHelper
namespace SnapDotNet.Core.Miscellaneous.Helpers
{
public static class NetworkInformationHelper
{
private const int IanaInterfaceTypeWifi = 71;
public static bool OnWifiConnection()
{
var internetConnectionProfile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
return internetConnectionProfile.NetworkAdapter.IanaInterfaceType == IanaInterfaceTypeWifi;
@0xdeafcafe
0xdeafcafe / InboundController.cs
Last active August 29, 2015 13:57
SendGrid Inbound Parse API Demo
// POST api/inbound
[ValidateInput(false)]
[ParseEmailObjectFilter]
public ActionResult Post()
{
if (ActionContext == null || ActionContext.ActionArguments == null || ActionContext.ActionArguments["email"] == null || !ActionContext.ActionArguments.ContainsKey("email"))
return new HttpStatusCodeResult(HttpStatusCode.OK);
var email = ActionContext.ActionArguments["email"] as Email;
if (email == null)
@0xdeafcafe
0xdeafcafe / ParseEmailObjectFilter.cs
Created March 22, 2014 21:19
SendGrid Inbound Parse API Demo
public class ParseEmailObjectFilter : ActionFilterAttribute
{
/// <summary>
/// Parses the raw form-data of the POST into a snazzy email
/// model, and then sets it in the arguments for the POST function
/// to read.
/// </summary>
/// <param name="actionContext">The HTTP action context of the POST.</param>
public override void OnActionExecuting(HttpActionContext actionContext)
{
@0xdeafcafe
0xdeafcafe / InboundEmail.cs
Created March 22, 2014 21:13
SendGrid Inbound Parse API Demo
/// <summary>
/// A model with the data format of the Inbound Parse API's POST
/// </summary>
public class Email
{
/// <summary>
/// The Domain Keys Identified Email code for the email
/// </summary>
public string Dkim { get; set; }