Skip to content

Instantly share code, notes, and snippets.

View plamere's full-sized avatar

Paul Lamere plamere

View GitHub Profile
@plamere
plamere / tweetSetup.html
Created November 27, 2012 11:23
dynamically adapting the tweet button
<body>
The tweet button:
<span id='tweet-span'>
<a href="https://twitter.com/share" id='tweet'
class="twitter-share-button"
data-lang="en"
data-count='none'>Tweet</a>
<script>!function(d,s,id){varjs,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
@plamere
plamere / lyrical_playlist.py
Created February 17, 2012 20:46
Example of using LyricFind and Echo Nest to generate a playlist with lyrics
import sys
import urllib
import json
from pyechonest import playlist
def show_playlist(seed_artist):
for s in playlist.basic(artist=seed_artist, type='artist-radio', ]
buckets=['id:lyricfind-US'], results=10, limit=True):
print '=================================================================='
"""
combine.py
alternate between two audiofiles, beat by beat
By Paul Lamere, 2013-01-25
"""
import echonest.audio as audio
usage = """
@plamere
plamere / gist:5004349
Created February 21, 2013 12:14
Loudness and Confidence filter
function runLength(quanta, confidenceThreshold, loudnessThreshold, lookAhead, lookaheadMatch) {
var lastState = false;
for (var i = 0; i < quanta.length; i++) {
quanta[i].needsDrums = false;
}
for (var i = 0; i < quanta.length -1; i+=2) {
@plamere
plamere / acrostic.py
Created October 25, 2013 23:24
Generates playlists that embed a secret message as an acrostic
#
# Generates an acrostic playlist
#
# This was built at the Tufts Hackathon Fall 2013
#
# Creates a playlist in the given genre, where the
# first letter in each song spells out a secret
# message
@plamere
plamere / all_genres.py
Created January 16, 2014 12:23
Example of listing all Echo Nest genres along with their descriptions
import pyen
en = pyen.Pyen()
response = en.get('genre/list', bucket=['description'])
for g in response['genres']:
print g['name'], '-', g['description']
@plamere
plamere / genre_list.txt
Created January 16, 2014 12:25
Output from all_genres.py
a cappella - A cappella is singing without instrumental accompaniment. From the Italian for "in the manner of the chapel," a cappella may be performed solo or by a group.
abstract hip hop -
acid house - From house music came acid house, developed in the mid-'80s by Chicago DJs experimenting with the Roland TB-303 synthesizer. That instrument produced the subgenre's signature squelching bass, used to create a hypnotic sound.
acid jazz - Acid jazz, also called club jazz, is a style of jazz that takes cues from a number of genres, including funk, hip-hop, house, and soul.
...
@plamere
plamere / top_artists_for_genre.py
Created January 16, 2014 12:32
Shows the top artists for a genre
import pyen
import sys
en = pyen.Pyen()
if len(sys.argv) > 1:
genre = ' '.join(sys.argv[1:])
response = en.get('genre/artists', name=genre)
for artist in response['artists']:
print artist['name']
@plamere
plamere / sim_genres.py
Last active January 3, 2016 11:09
Get similar genres to any genre
import pyen
import sys
en = pyen.Pyen()
if len(sys.argv) > 1:
genre = ' '.join(sys.argv[1:])
response = en.get('genre/similar', name=genre)
for genre in response['genres']:
print genre['name']
@plamere
plamere / genre_playlist.py
Created January 16, 2014 12:44
example of using creating genre radio
import pyen
import sys
en = pyen.Pyen()
if len(sys.argv) < 2:
print 'Usage: python genre_playlist.py seed genre name'
else:
genre = ' '.join(sys.argv[1:])
response = en.get('playlist/static', type='genre-radio', genre_preset='core-best', genre=genre)