Skip to content

Instantly share code, notes, and snippets.

@hartez
hartez / emailwordcounts.py
Created October 25, 2015 20:44
Python script for counting words in emails
View emailwordcounts.py
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 / TranslatePage.cs
Last active October 4, 2017 20:24
View accepts input after translation
View TranslatePage.cs
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
View TranslatePage.cs
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."))
};
View keybase.md

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
View bodytext.ps1
$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 / jquery-validation-engine_with_select2
Created June 25, 2012 22:27
Workaround for using jquery-validation-engine with select2 for 'required' validation
View jquery-validation-engine_with_select2
<script type="text/javascript">
// This is a workaround for using jquery-validation-engine with select2 for 'required' validation
// Since the _required validator for jquery-validation-engine uses .val() to see
// if there's anything in the input, we can hijack .val() for the container created by select2\
// and redirect it to the value of the hidden element
// jquery-validation-engine throws an error if the thing we're validating doesn't have an id
// so we'll put one on the container created by select2 (that way, the positioning of the prompts
// will be correct)
$('#mySelector').select2('container').attr('id', 'mySelectorValidate');
@hartez
hartez / gist:3881054
Created October 12, 2012 19:35
Convertinator temperature
View gist:3881054
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));
@hartez
hartez / gist:3881051
Created October 12, 2012 19:35
Convertinator celcius
View gist:3881051
var celcius = new Unit("Celcius")
.IsAlsoCalled("celcius", "Centigrade", "centigrade", "degrees Celcius", "degrees Centigrade")
.IsAlsoCalled("celcuis") // typo from legacy system
.CanBeAbbreviated("°C")
.PluralizeAs("°C");
@hartez
hartez / convertinator_interfaces.cs
Created October 12, 2012 19:29
Convertinator Conversion interfaces
View convertinator_interfaces.cs
public interface IConversion
{
IEnumerable<IConversionStep> Steps { get; }
void AddStep(IConversionStep step);
Conversion Reverse();
}
public interface IConversionStep
{
decimal Apply(decimal input);
@hartez
hartez / gist:3880921
Created October 12, 2012 19:13
Convertinator basic example
View gist:3880921
var graph = new ConversionGraph();
var meter = new Unit("meter");
var feet = new Unit("foot");
graph.AddConversion(Conversions.One(meter).In(feet).Is(3.28084M));