Skip to content

Instantly share code, notes, and snippets.

View sampsyo's full-sized avatar

Adrian Sampson sampsyo

View GitHub Profile
diff --git a/beets/importer.py b/beets/importer.py
index 0fc11f6..52e06a4 100644
--- a/beets/importer.py
+++ b/beets/importer.py
@@ -254,7 +254,6 @@ class ImportSession(object):
for stage_func in plugins.import_stages():
stages.append(plugin_stage(self, stage_func))
stages += [manipulate_files(self)]
- stages += [finalize(self)]
pl = pipeline.Pipeline(stages)
@sampsyo
sampsyo / rn.py
Created February 21, 2014 18:52
import re
import sys
import os
for path in sys.argv[1:]:
with open(path) as f:
contents = f.read()
m = re.search(r'created_at: (.*)', contents)
d, m, y = map(int, m.group(1).split('/'))
>>> import chromaprint
>>> chromaprint.decode_fingerprint('AQADnpmURJG44mheHKKWZDhxpAOcZ0foDeeF51AkyfAD0i8aHmQeY9KP5g-h60QeLXiCsiExHV_w53iyE1ryBpQeB714TA8a9Th5nAkuW8GV6QmiNkdy_EeZ_WhqB1PUH9X2o-J4NHpy_FpwPwj07chzVNmJSivKRIl0NFeSA8uxT0Wc6EiWKMkd-Id_9BeuXMWVGBdFI6ZzImmkB54e43hYNGGObhuaP6geJE-J-MKTPMK1hPip4AyFonlwTe3wHMmvIufxLLvwFP8Hl3gSJZGKK3sQp_SgC-ld_AqeS-gFj9MRXhQ0xUca8fDya_grPCnSHyLCL8UuHWcOKmFyTAlFtAtL4m3wwL2J_NDxkQiv4Mc_NM9w4krxw19yxA60HH2KXNOPNcGtH8xnFX5Q5senyGAsZfDB8MccbkOCME3soD6OxznKPC18J-jz4MeLh9HxnKgfNE0u_HiQvvihEhFDHXTEY09N_EO-pBz6HFqq_MiZB1d2JfiD-4dfIw-HS9iP72Dk9HgefB9y3LiG18LBI0g4KcVBHcdPOCn6hAef6_iNMx58HfzCB6GTEVpuIfvx6EnwS8N34zmYXMrQ79gXnDlDfNtDWFWSEXeCo33RNPiO3EpC6HPw_IgyHz9xgsmZBEl0WsiP67gQXGJK9El0aIkf5BZ-VMdx4tJwHdsL5sMR8YdGHmFe1FngZMpc-JgYC7kkGXxe6Bh_yDkiRx0P1wlx8DkO98eZMEgeIedwinh2NFWO6TmamEaVOT5-IcwYlOkX6Dlu_HhYCX8GzT_CpMmCZzp-7Dt4zdiTBveUoImOKokOJEdO4U2D9zgTlOFR_fjxJEdTPkfl4QeSKst85A8H9B9-NM-PH0-CH1-Oc8ePMP_Q5xF07EqEE7yQh09xYs9mNHWM74ErijiTo4mV4BdxjsTjETuP5D3C7mhGpvic48xS4suD1fhoPFGSI7-QU
{
"width": 300,
"height": 150,
"data": [
{
"name": "performance",
"values": [
{
"component": "compile",
"prog": "foo",
#!/usr/bin/env python3
import requests
import json
BASE_URL = 'http://www.comicvine.com/api'
API_KEY = 'c7f4481e0a6154b8ac39580747ca8c91c3d4a321'
def dump(jo):
@sampsyo
sampsyo / approxcode.py
Created August 1, 2013 23:44
simulate analog storage/transmission errors
import bitstring
import random
import json
# Randomness.
def bernoulli(param):
return random.random() <= param
@sampsyo
sampsyo / non-mb-thoughs.md
Created May 26, 2013 04:16
thoughts on penalizing non-MB sources

First of all, I like the change that sorts MB candidates above non-MB ones. Thanks for that -- this prioritization definitely seems like something we want to do in general.

Thinking about how to do this kind of thing more generally got me thinking about how the matching logic was originally designed and how we can keep it simple. Specifically, the matching logic gets a lot of simplicity out of segregating the core matching/ranking stuff from the distance components. Because all the comparison stuff is complicated and messy, it's really helpful to have it hidden behind a single abstraction: distance. This also lets us add on new distance components easily without affecting the core logic.

Every time we add new special cases to the ranking and recommendation logic, we break a little bit of this abstraction. That's fine, especially when it brings features that aren't possible otherwise (like the max_rec feature), but for th

@sampsyo
sampsyo / config.yaml
Last active January 5, 2016 11:02
trigger/recommendation idea
match:
recommendations:
partial: low
tracknumber: medium
tracklength: medium
@sampsyo
sampsyo / tal.py
Created September 20, 2012 17:42
send This American Life episodes to Huffduffer
#!/usr/bin/env python3
"""Simple scraper for adding This American Life episodes to Huffduffer.
TAL has the most amazing app on the App Store, but some stuff broke on
iOS 6 and it doesn't seem to get bug fixes very often. This is my ad-hoc
solution.
"""
import urllib.request
import urllib.parse
import sys
@sampsyo
sampsyo / CopyMachine.java
Created July 31, 2012 19:28
Java object cloning for Jikes RVM
import java.lang.reflect.Array;
import org.vmmagic.unboxed.Address;
import org.vmmagic.unboxed.ObjectReference;
import org.vmmagic.unboxed.Offset;
import org.mmtk.vm.VM;
import org.vmmagic.pragma.Uninterruptible;
import org.jikesrvm.classloader.RVMType;
import org.jikesrvm.runtime.RuntimeEntrypoints;
import org.jikesrvm.runtime.Memory;