This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var itunes = document.getElementById("itunesEmbed"); | |
| itunes.addEventListener('download_progress', function(context, bytesLoaded, bytesTotal){ | |
| var pComplete = Math.round(bytesLoaded/bytesTotal) * 100; | |
| // Update a progress bar... | |
| }); | |
| itunes.addEventListener('download_complete', function(context, pathToDownloadedFile){ | |
| var song = songDict[context]; | |
| $('#song-'+context).find('span.progress').html('Moving to ipod...'); | |
| itunes.add_file_to_ipod( | |
| pathToDownloadedFile, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Extract a playlist from a daytrotter session page. | |
| */ | |
| tracks = []; | |
| var regex = /id(\d+)\.(\d+)\.(\d+)\.(\d+)/; | |
| var re = new RegExp(regex); | |
| var bitrate = '96'; // 96 or 192 | |
| var artist = jQuery('#SessionDetailArtistImage').attr('alt'); | |
| jQuery('#SessionPlayers ol.noformat li:not(.right)').each(function(){ | |
| var id = $(this).attr('id'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Clean way of testing for HTML5 audio support for jQuery. | |
| * | |
| * Example: | |
| * if(jQuery.support.audio.mp3){ | |
| * alert('Thanks guy. Enjoy the mp3 party in your browser.'); | |
| * } else { | |
| * alert('MP3 native playback not supported.'); | |
| * } | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Post to SOLR via celery async | |
| """ | |
| from celery.task.http import HttpDispatchTask | |
| res = HttpDispatchTask.apply_async(url="http://solr-server.com:8080/solr/main", method="POST", routing_key="solr.add", xml=xml) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import gevent | |
| from thrift.server.TServer import TServer | |
| # XXX Hackish, but should be safe: monkey patch gevent socket support into | |
| # Thrift. Overall I think this is cleaner than reimplementing all of TSocket. | |
| from thrift.transport import TSocket; TSocket.socket = gevent.socket | |
| from thrift.transport.TTransport import TTransportException | |
| class TGEventServer(TServer): | |
| """Gevent socket server.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [unix_http_server] | |
| file=/tmp/supervisor.sock ; path to your socket file | |
| [supervisord] | |
| logfile=/var/log/supervisord/supervisord.log ; supervisord log file | |
| logfile_maxbytes=50MB ; maximum size of logfile before rotation | |
| logfile_backups=10 ; number of backed up logfiles | |
| loglevel=info ; info, debug, warn, trace | |
| pidfile=/var/run/supervisord.pid ; pidfile location | |
| nodaemon=false ; run supervisord as a daemon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sqlalchemy.orm.query import Query | |
| from sqlalchemy.orm import exc as orm_exc | |
| def _scalar_all(self): | |
| """Same as scalar, but all() instead of one() | |
| Example: | |
| ids = Session.query(User.id).filter(User.username.in_(["joe", "sam"])).scalar_all() | |
| """ | |
| try: | |
| return [ret if not isinstance(ret, tuple) else ret[0] for ret in self.all()] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Compile gevent on OSX when deps are in non-standard paths. | |
| # Can't just use easy_install because we want to specify some additional include and lib paths for gcc. | |
| # | |
| # Assuming you've already installed the [gevent requirements](http://www.gevent.org/#installation): | |
| # sudo port install libev libevent greenlet | |
| cd setup/ | |
| wget http://pypi.python.org/packages/source/g/gevent/gevent-0.12.2.tar.gz#md5=97c75039a67593d3f5375fb77f73bbe7 | |
| tar -zxvf gevent-0.12.2.tar.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tableView: SC.TableView.design({ | |
| columns: [ | |
| SC.TableColumn.create({ | |
| key: 'title', | |
| label: '_Name'.loc(), | |
| width: 250, | |
| isReorderable: YES, | |
| isSortable: YES, | |
| }), | |
| ], |