Skip to content

Instantly share code, notes, and snippets.

View imlucas's full-sized avatar
⚒️

Lucas Hrabovsky imlucas

⚒️
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" addedToStage="init();">
<fx:Script>
<![CDATA[
private function init():void{
var handlers:Array = [
new Route(/\/api\/track\/(\d+)\/?/, TrackHandler, 'get')
];
var app:Application = new Application(handlers);
var http_server:HttpServer = new HttpServer(app);
import eventlet
from thrift.server.TServer import TServer
from thrift.transport import TSocket;
from thrift.transport.TTransport import TTransportException
class TEventletServer(TServer):
"""Eventlet Thrift Server. Each client gets its own green thread."""
running = False
backdoor = 0
def __init__(self, *args, **kwargs):
#!/usr/bin/env python
import os
import sys
import appscript
import sys
import xmlrpclib
import textwrap
import pkg_resources
import pip.download
from pip.basecommand import Command
"""
Monkey patch the Last.fm Python Library (http://code.google.com/p/pylast/)
to add some useful track methods.
"""
import pylast
def monkey_patch_pylast():
def _pylast_get_lastfm_album(self):
"""Get an Album instance from a Track instance."""
// Based on Backbone.localStorage.
// Idea is when offline, write to localstorage
// and queue changes to send to the remote when
// we come back online.
//
// @todo (lucas) Implement rev-ish tracking and
// first in conflict resolution ala couch.
//
// @todo (lucas) Throttle repl calls?
//
// ==================================================
// Friends
// ==================================================
$('#friends a').live('click', function(){
$('.artists').remove();
var period = $(this).attr('id');
username = $(this).text();
$.ajax({
data: 'user='+username+'&api_key='+api_key+'&format=json&limit=25&period='+period,
url: topArtists,
var Artist = Backbone.Model.extend({
defaults: {
'name': 'An Artist',
'image': 'images/loading.gif'
}
});
var ArtistList = Backbone.Collection.extend({model: Artist});
var User = Backbone.Model.extend({
import re
import simplejson
def camelize(value):
ret = "".join([w.title() for w in re.split(re.compile("[\W_]*"), value)])
lower = ret[0].lower()
return "%s%s" % (lower, ret[1:])
def decamelize(value):
return re.sub(r'([a-z])([A-Z])', r'\1_\2', value).lower()
from flaskext.celery import Celery
from flask import current_app
celery = Celery(current_app)
@celery.task
def add(x, y):
return x+y
from flaskext.celery import Celery
def init(app):
celery = Celery(app)
@celery.task
def add(x, y):
return x+y