Skip to content

Instantly share code, notes, and snippets.

View imlucas's full-sized avatar
⚒️

Lucas Hrabovsky imlucas

⚒️
View GitHub Profile
import os, sys, getopt, zipfile
from elementtree import ElementTree as ET
"""
Build a zip for your app to test it.
Make sure to install ET so we can read attributes of our app from the descriptor
file. This makes sure that you only have to edit things in one place and the
behaviour of packagaing your app will always be what you want it to ( that is of
course you dont't update your descriptor file :))
import os, sys, json, urllib2, time, urllib
class AmieStreet:
def __init__(self, gateway_url):
self.gateway_url=gateway_url
def __doRequest(self, service, method, params=None):
param_string = ''
if params!=None:
param_string = urllib.urlencode(params)
class Bag: pass
def unmarshal(element):
rc = Bag()
if isinstance(element, minidom.Element):
for key in element.attributes.keys():
setattr(rc, key, element.attributes[key].value)
childElements = [e for e in element.childNodes \
if isinstance(e, minidom.Element)]
if childElements:
<?
// The infamous michael buble case
// takes "michael da buble" and turns that into "buble, michael da"
// which is how amg stores it
$lastname = substr($name, strrpos($name, " ")+1);
$firstname = str_replace(" ".$lastname, "", $name);
$assembled = $lastname.", ".$firstname;
$k = new self;
$k->whereAddEqual('key_name', $assembled);
{if $pane}
{ui_script}
$(document).one('amie.ready', function(){ldelim}$('#basics-{$pane}').trigger('click').find('a').trigger('click');{rdelim});
{/ui_script}
{/if}
$('#blue-box').remove();
$('#account-nav').css('left', $('#account-nav').position().left+'px');
$('#account-nav').css('position', 'absolute');
$('#account-nav').prepend('<div id="blue-box" style="color: #FFFFFF;background-color: #3671B2;height: 90px;display:none;padding:4px;"><form><label>Username or email:</label><br /><input type="text" /><br /><label>Password:</label><br /><input type="password" /><br /><input type="submit" value="Login"/> <a href="javascript:void(0);" onclick="$(\'#blue-box\').slideUp();">Cancel</a></form><div style=""></div></div>');
$('#blue-box').slideDown();
$('#myDiv').find('table').find('tr').each(function() {
var tr = $(this), w = 0;
tr.find('td').each(function() {
w += $(this).outerWidth();
});
if (w > tr.width()) {
$('#myDiv').find('table').css('table-layout', 'auto');
return false;
}
});
/**
* Play a song from Amie Street
*/
var songId = '2ajVBbF1YOUx';
var url = 'http://amiestreet.com/stream/song/'+songId+'.mp3';
var sound = Titanium.Media.createSound(url);
var listenerId = sound.addEventListener('complete', function() {
sound.removeEventListener('complete', listenerId);
$(function(){
var wrapper = '<div class="album-wrapper" style="background: transparent url(\'http://farm4.static.flickr.com/3496/3959854070_21f80b9dbc_o.png\');min-height:466px; min-width:500px;"></div>';
$('img.album').wrap(wrapper);
$('img.album').css({'position':'absolute','height':'452px','width':'452px','margin':'7px 0px 0px 42px'});
var playBtn = '<div class="play-button" style="position:absolute;height:72px; width:72px;margin:400px 0px 0px 440px;"><img src="http://farm4.static.flickr.com/3440/3959945892_d06b593c2d_o.png" /></div>';
$(playBtn).appendTo('.album-wrapper');
});
$.player = {__items: [],__index: 0, __nowPlaying: null,__visible: true,__playing: false,__streamUrlResolver: null,__progressInterval: 0};
$.player.init = function(opts){};
//------------------------------------------------------------------//
// All events triggered by $.player (as3 style)
//------------------------------------------------------------------//
$.player.EVENTS = {
ITEMS_CHANGED : 'player:items_changed',
NOW_PLAYING_SET : 'player:now_playing_set',
SOUND_MANAGER_READY : 'player:sound_manager_ready',
PLAYLIST_COMPLETE: 'player:playlist_complete'