Skip to content

Instantly share code, notes, and snippets.

View hartez's full-sized avatar

E.Z. Hart hartez

View GitHub Profile
@hartez
hartez / TranslatePage.cs
Last active October 4, 2017 20:24
View accepts input after translation
public class TranslatePage : ContentPage
{
public TranslatePage()
{
var layout = new RelativeLayout();
double viewSize = 100;
var box = new Entry
{
@hartez
hartez / TranslatePage.cs
Created October 3, 2017 22:07
Add gesture to off-screen view, animate it onto the screen, gesture still works
public class TranslatePage : ContentPage
{
public TranslatePage()
{
var layout = new RelativeLayout();
var tapGesture = new TapGestureRecognizer
{
Command = new Command(() => DisplayAlert("Box Tapped", "The box was tapped", "Cool, thanks."))
};

Keybase proof

I hereby claim:

  • I am hartez on github.
  • I am hartez (https://keybase.io/hartez) on keybase.
  • I have a public key ASDHDfsQ0rypUYqHl9WtalmOx-BzQgjxRscWRqnmdtVdpAo

To claim this, I am signing this object:

@hartez
hartez / bodytext.ps1
Last active February 9, 2017 18:10
PowerShell script to pull email body text out of GMVault
$emails = @()
$gmvaultdb = "[path to your gmvault data]"
$total = (Get-ChildItem $gmvaultdb -Recurse -Filter *.eml | measure).Count
Add-Type -Path "MimeKit.1.2.10.0\lib\net45\MimeKit.dll"
$formats = @{
[MimeKit.Text.TextFormat]::Text = 0;
@hartez
hartez / emailwordcounts.py
Created October 25, 2015 20:44
Python script for counting words in emails
from bs4 import BeautifulSoup as bsoup
import pandas as pd
import numpy as np
import humanfriendly
# Read in email data file
df = pd.read_csv('../bodytext.csv', header = 0)
# Filter out sent mail
emails = df.query('FromEmail != "[my email address]"').copy()
@hartez
hartez / attachments3.py
Created October 4, 2015 19:21
Plotting email attachment data using pandas
import pandas as pd
import numpy as np
import humanfriendly
import matplotlib.pyplot as plt
plt.style.use('ggplot')
import os.path
# Read in our email data file
df = pd.read_csv('../attachments2.csv', header = 0)
@hartez
hartez / RefactorableSettingsTemplate.tt
Created August 15, 2014 23:36
T4 template for generating refactorable settings
<#@ template language="C#" hostspecific="True" #>
<#@ assembly name="System.Xml" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Xml" #>
<#
XmlDocument doc = new XmlDocument();
doc.Load(Path.Combine(Path.GetDirectoryName(Host.TemplateFile), "Settings.settings"));
string xmlns = doc.DocumentElement.Attributes["xmlns"].Value;
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
@hartez
hartez / AddressController.cs
Created June 23, 2014 18:13
Address controller with comments
/// <summary>
/// Endpoints for managing Addresses
/// </summary>
public class AddressController : ApiController
{
/// <summary>
/// Gets a list of addresses in the system
/// </summary>
/// <returns>IEnumerable&lt;AddressViewModel&gt;.</returns>
public IEnumerable<AddressViewModel> Get()
@hartez
hartez / AddressController.cs
Created June 23, 2014 18:07
Controller without documentation
public class AddressController : ApiController
{
public IEnumerable<AddressViewModel> Get()
{
return Addresses.Get();
}
[Route(Name = "GetAddress")]
public AddressViewModel Get(int id)
{
@hartez
hartez / gist:3881054
Created October 12, 2012 19:35
Convertinator temperature
var temperature = new ConversionGraph();
var fahrenheit = new Unit("degrees Fahrenheit")
.IsAlsoCalled("Fahrenheit")
.CanBeAbbreviated("°F")
.PluralizeAs("°F");
temperature.AddConversion(
Conversions.From(fahrenheit).To(celcius).Subtract(32).MultiplyBy(5M / 9M));