Skip to content

Instantly share code, notes, and snippets.

@aembleton
aembleton / lastfm_top-tags.py
Created December 13, 2015 16:45
Add tags to MP3s
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys
def main(f):
if not os.path.splitext(f)[1].lower() == '.mp3':
err('usage')
@aembleton
aembleton / Ignore certificate for HttpURLConnection in Android.java
Created March 27, 2011 17:25
The following code disables SSL certificate checking for any new instances of HttpsUrlConnection
/**
* Disables the SSL certificate checking for new instances of {@link HttpsURLConnection} This has been created to
* aid testing on a local box, not for use on production.
*/
private static void disableSSLCertificateChecking() {
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
@aembleton
aembleton / treestyletabs.css
Last active June 7, 2023 21:16
Tree Style Tabs CSS styling
/*
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
:root {
--grey-10: #f9f9fa;
--grey-40: #b1b1b3;
--grey-90: #0c0c0d;
@aembleton
aembleton / docx2md.md
Last active May 17, 2023 07:04 — forked from vdavez/docx2md.md
Convert a Word Document into MD

Converting a Word Document to Markdown in One Move

The Problem

A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.

Installing Pandoc

On a mac you can use homebrew by running the command brew install pandoc.

The Solution

@aembleton
aembleton / userChrome.css
Created February 17, 2022 12:45
Put inside firefox/$profile/chrome directory
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* to hide the native tabs */
#TabsToolbar {
visibility: collapse;
}
/* to hide the sidebar header */
#sidebar-header {
visibility: collapse;
@aembleton
aembleton / grough.css
Created September 4, 2019 08:38
CSS improvements for grough.co.uk
#mai-rtmenu {
display: none;
}
#header {
display: none;
}
#main #mai-container #mai-content {
width: 100%;
#mai-rtmenu {
display: none;
}
#header {
display: none;
}
#main #mai-container #mai-content {
width: 100%;
@aembleton
aembleton / ListUtil.kt
Created August 5, 2017 23:51
pmap extension for List
public fun <I,O> List<I>.pmap(transform: (I) -> O): List<O> {
val asyncOperations = this.map{wrapTransorm(transform, it)}
return runBlocking { asyncOperations.map { it.await() } }
}
fun <I,O> wrapTransorm(transform: (I) -> O, input:I) = async(CommonPool) {transform(input)}
@aembleton
aembleton / ListExtension.kt
Created August 19, 2016 15:50
Create a map from a list of Strings. Split the string with a splitter String. Useful for reading in a list of comma seperated String and converting them into a map.
fun List<String>.mapWith(split:String) = this.map {
val components = it.split(split, limit=2)
components[0].trim() to components[1].trim()
}.toMap()
@aembleton
aembleton / MapExtension.kt
Created August 19, 2016 15:48
Find map keys that start with a given String
fun <V> Map<String,V>.startsWith(search:String):V? {
val reducedMap = this.toSortedMap().tailMap(search)
if (!reducedMap.isEmpty() && reducedMap.firstKey().startsWith(search)) {
return reducedMap.values.first()
}
return null
}