Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# easyIMAP2Notes (C)2015 by Jan-Piet Mens
# Connect to an IMAP mailbox, read messages, and convert them into
# a format suitable for iOS/OSX Notes, then store them in Notes/
#
# This uses two connections (consider that a feature b/c you can
# slurp from one IMAP account into another). The real reason is I
# couldn't be bothered to implement message decoding/attachment
# extraction with imaplib, so I chose easyimap (pip install easyimap)
# to do that.
@renesugar
renesugar / splitmbox.py
Created April 8, 2020 00:57 — forked from technicalflaw/splitmbox.py
Split a Unix-style mailbox into individual files
#! /usr/bin/env python
""" Split a Unix-style mailbox into individual files
Written by Aquarius <[email protected]>
Usage: splitmbox.py <mailbox-file> <directory>
This will create files numbered 01,02,03... in <directory>. The
number of prefixed zeroes will make all filenames in the
directory the same length. """
@renesugar
renesugar / recentServersSFL.py
Created May 13, 2020 18:48 — forked from pudquick/recentServersSFL.py
Working with SharedFileList (.sfl) files from OSX 10.11 El Capitan in python
from Foundation import NSKeyedUnarchiver
from struct import unpack
# This entire function is black magic of the highest order and I'll blog about it later
def extract_share(bookmark_data):
content_offset, = unpack('I', bookmark_data[12:16])
first_TOC, = unpack('I', bookmark_data[content_offset:content_offset+4])
first_TOC += content_offset
TOC_len, rec_type, level, next_TOC, record_count = unpack('IIIII', bookmark_data[first_TOC:first_TOC+20])
TOC_cursor = first_TOC + 20
@renesugar
renesugar / .gitignore
Created June 2, 2020 01:22 — forked from asford/.gitignore
pybind11 ostream example
# Created by https://www.gitignore.io/api/c++,cmake
### C++ ###
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
@renesugar
renesugar / Jsc.java
Created October 30, 2020 22:22 — forked from thomd/Jsc.java
compile javascript to java bytecode
import org.mozilla.javascript.tools.jsc.Main;
class Jsc {
public static void main(String args[]){
Main.main(args);
}
}
@renesugar
renesugar / fork forced sync
Created November 5, 2020 15:34 — forked from glennblock/fork forced sync
Force your forked repo to be the same as upstream.
git fetch upstream
git reset --hard upstream/master
@renesugar
renesugar / rope.cpp
Created February 15, 2021 19:35 — forked from dermesser/rope.cpp
A simple rope implementation in C++ – should work well enough.
// Licensed under MIT license.
// (c) Lewin Bormann 2014
# include <string>
# include <iostream>
# include <list>
# include <cstring>
# include <algorithm>
using std::string;
@renesugar
renesugar / sqlite-kv-restful.py
Created April 23, 2021 00:14 — forked from rmax/sqlite-kv-restful.py
Simple SQLite-backed key-value storage Rest API. Built with Flask & flask-restful.
import os
import sqlite3
from hashlib import md5
from time import time
import simplejson as json
from flask import Flask
from flask.ext import restful
from flask import g
from flask import request
@renesugar
renesugar / index.js
Created May 9, 2021 02:20 — forked from max-mapper/index.js
fast loading of a large dataset into leveldb
// data comes from here http://stat-computing.org/dataexpo/2009/the-data.html
// download 1994.csv.bz2 and unpack by running: cat 1994.csv.bz2 | bzip2 -d > 1994.csv
// 1994.csv should be ~5.2 million lines and 500MB
// importing all rows into leveldb took ~50 seconds on my machine
// there are two main techniques at work here:
// 1: never create JS objects, leave the data as binary the entire time (binary-split does this)
// 2: group lines into 16 MB batches, to take advantage of leveldbs batch API (byte-stream does this)
var level = require('level')
@renesugar
renesugar / utf8.js
Created May 10, 2021 22:42 — forked from pascaldekloe/utf8.js
JavaScript UTF-8 encoding and decoding with TypedArray
// This is free and unencumbered software released into the public domain.
// Marshals a string to an Uint8Array.
function encodeUTF8(s) {
var i = 0, bytes = new Uint8Array(s.length * 4);
for (var ci = 0; ci != s.length; ci++) {
var c = s.charCodeAt(ci);
if (c < 128) {
bytes[i++] = c;
continue;