Skip to content

Instantly share code, notes, and snippets.

@AlbertoEAF
AlbertoEAF / gmail_mbox_parser.py
Last active September 29, 2023 18:27 — forked from benwattsjones/gmail_mbox_parser.py
Extension of gmail_mbox_parser.py to parse GMail's Google Takeout exports in .mbox format and do clustering analysis of senders so you can quickly triage which kind of information sources might no longer be relevant. It also adds command line arguments and exports the sender's statistics in a .csv file.
#! /usr/bin/env python3
# ~*~ utf-8 ~*~
# About: Extension of gmail_mbox_parser.py to parse GMail's Google Takeout exports in .mbox format and do clustering analysis of senders so you can quickly triage which kind of information sources might no longer be relevant. It also adds command line arguments and exports the sender's statistics in a .csv file.
# Based on https://gist.github.com/benwattsjones/060ad83efd2b3afc8b229d41f9b246c4 but expanded to add command line arguments, do clustering of senders and export a .csv with those statistics.
import re
import argparse
import mailbox
from collections import Counter
void Main()
{
var harmony = new Harmony("test");
harmony.PatchAll();
var group = new StatusItemGroup();
var items = new List<StatusItemGroup.Entry>() { StatusItemGroup.Entry.Make("A"), StatusItemGroup.Entry.Make("B") };
Traverse.Create(group).Field("items").SetValue(items);
var enumerator = group.GetEnumerator();
@benwattsjones
benwattsjones / gmail_mbox_parser.py
Last active April 29, 2024 16:39
Quick python code to parse mbox files, specifically those used by GMail. Extracts sender, date, plain text contents etc., ignores base64 attachments.
#! /usr/bin/env python3
# ~*~ utf-8 ~*~
import mailbox
import bs4
def get_html_text(html):
try:
return bs4.BeautifulSoup(html, 'lxml').body.get_text(' ', strip=True)
except AttributeError: # message contents empty
@ebidel
ebidel / mo_vs.proxy.js
Last active December 31, 2023 12:24
MutationObserver vs. Proxy to detect .textContent changes
<!--
This demo shows two ways to detect changes to a DOM node `.textContent`, one
using a `MutationObserver` and the other using an ES2015 `Proxy`.
From testing, a `Proxy` appears to be 6-8x faster than using a MO in Chrome 50.
**Update**: removing the `Proxy` altogether speeds up the MO to be inline with the Proxy.
This has something to do with how the browser queues/prioritizes Proxies over MO.
@paulirish
paulirish / what-forces-layout.md
Last active May 6, 2024 07:54
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@lena3rika
lena3rika / UIUtility.cs
Last active January 24, 2018 13:27
UIUtility class used in my Dropdown tutorials
using UnityEngine;
using UnityEditor;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class UIUtility : MonoBehaviour
{
//Adds GameObject -> UI -> Dropdown menu item that instantiates
//a new button and attaches a dropdown component.
@mmj-the-fighter
mmj-the-fighter / ShadersLister.cs
Last active October 25, 2015 10:24
Unity3D Editor Script : Displays gameobjects linked to each shader present in a scene.
//Copyright © 2015 Manoj M J
//All Rights Reserved
//Why I do copyright the code that I provide at gist.github.com
//( https://gist.github.com/mmj-the-fighter/bccd0a7ff57c638beee8 )
/*
* ShadersLister.cs - Displays gameobjects linked to each shader present in a scene.
* It is useful for checking if the scene contains any unwanted shaders.
*/
@mmj-the-fighter
mmj-the-fighter / DropObject.cs
Last active October 25, 2015 10:22
Unity3D Editor Script: Moves selected object downwards till it touches the ground
//Copyright © 2015 Manoj M J
//All Rights Reserved
//Why I do copyright the code that I provide at gist.github.com
//( https://gist.github.com/mmj-the-fighter/bccd0a7ff57c638beee8 )
/*
* DropObject.cs - Moves selected object downwards till it touches the ground
* This is useful for placing 3d models on scene.
* TODO:Add Spherecast in addition to Raycast
@esemwy
esemwy / mkdim.py
Created June 10, 2015 12:13
Create DAZ Install Manager packages from zip or directory
#!/usr/bin/python
import uuid
import os
from zipfile import ZipFile, is_zipfile
import sys
import time
from random import randint
import argparse
import re
@fauxparse
fauxparse / sortable.coffee
Created January 13, 2015 01:49
Sortable lists in < 100 LoC
class SortableList
constructor: (el) ->
@el = $(el)
down: (e) =>
e.preventDefault()
top = @el.offset().top
@el.find(".sortable").each (i, el) ->
$el = $(el)
offset = $el.offset().top