Skip to content

Instantly share code, notes, and snippets.

View thesmith's full-sized avatar

Ben Smith thesmith

View GitHub Profile
@thesmith
thesmith / atlasapi-snippet.js
Created July 2, 2010 13:33
Facebook Latest Episode Bookmarklet
var pageTitle = urlencode($('#profile_name').text());
var currentLocation = 'us';
$.getJSON('http://atlasapi.org/2.0/brands.json?title='+pageTitle+'&availableCountries='+currentLocation+'&limit=1&callback=?',
function(data) {
console.log(data);
}
);
$.getJSON("http://atlasapi.org/2.0/brands.json?playlist.uri=http://www.channel4.com/programmes/4od/highlights&callback=?",
function(data){
console.log(data);
}
);
<html>
<script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
var addItem = function(item, i) {
var left = (i*200) % $("body").width();
var top = Math.floor(Math.random() * 500);
$("<img/>").css({ position: 'absolute', left: left, top: top, opacity: 0, width: 100}).attr("src", item.thumbnail).appendTo("body").animate({
ContentQuery query = query()
.equalTo(Attributes.PLAYLIST_URI, "http://ref.atlasapi.org/hotness/twitter")
.equalTo(Attributes.ITEM_IS_LONG_FORM, true)
.build();
List<Item> mentionedItems = client.items(query);
Message msg = new MessageBuilder()
.withRecipientJids(jid)
.withBody(video.toString())
.withMessageType(MessageType.CHAT).build();
boolean messageSent = false;
if (xmpp.getPresence(jid).isAvailable()) {
SendResponse status = xmpp.sendMessage(msg);
messageSent = (status.getStatusMap().get(jid) == SendResponse.Status.SUCCESS);
}
@thesmith
thesmith / drop_tmp_collections.js
Created February 2, 2011 22:07
Drop tmp MongoDB collections
var reg = new RegExp("^tmp");
var names = db.getCollectionNames();
for (var col in names) { var name = names[col]; if (name.match(reg)) { db[name].drop();} }
@thesmith
thesmith / jetty
Created March 15, 2011 13:56
shell script to start jetty
#! /bin/sh
cd `dirname "$0"`
USER=`whoami`
if [ $USER != 'jetty' ]
then
sudo -u jetty $0 $@
exit $?
@thesmith
thesmith / find_content.js
Created April 19, 2011 17:55
Find content in containers
var lookup = 'http://www.bbc.co.uk/programmes/p00fys8v';
var i=0;
var c=0;
var containers = db.content.find({lookup: lookup});
var found = null;
for (c=0; c<containers.length(); c++) {
var container = containers[c];
print("Currently processing "+container._id);
@thesmith
thesmith / delete_sub_items.js
Created April 19, 2011 17:56
Delete sub items from container
var lookup = 'http://pressassociation.com/brands/1166';
var i=0;
var container = db.content.findOne({lookup: lookup});
print('container currently has '+container.contents.length+' items.');
for (i=0; i<container.contents.length; i++) {
if (container.contents[i] != null && container.contents[i].specialization == 'film') {
print('removing episode at poisition '+i+': '+container.contents[i]._id+' - '+container.contents[i].title);
//eval('db.content.update({_id: container._id}, {$unset: {"contents.'+i+'": 1 }})');
@thesmith
thesmith / hack.sh
Created April 1, 2012 11:28 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2274799/hack.sh | sh
#