Skip to content

Instantly share code, notes, and snippets.

@hubgit
hubgit / ampache-resolver.php
Created December 14, 2009 00:07
Ampache resolver for Playdar
#!/usr/bin/env php
<?php
require dirname(__FILE__) . '/../phpresolver/playdarresolver.php';
class AmpacheResolver extends PlaydarResolver {
protected $name = 'ampache resolver';
protected $targetTime = 50;
protected $weight = 100;
protected $localonly = FALSE;
@hubgit
hubgit / ElasticSearch.php
Created February 16, 2010 17:20
ElasticSearch class for PHP
<?php
// http://www.elasticsearch.com/docs/elasticsearch/rest_api/
class ElasticSearch {
public $index;
function __construct($server = 'http://localhost:9200'){
$this->server = $server;
}
@hubgit
hubgit / elasticsearch-bus-stops.php
Created February 16, 2010 17:22
indexing TfL bus stops data in ElasticSearch
<?php
require 'ElasticSearch.php';
$e = new ElasticSearch;
$e->index = 'tfl'; // name of the index
/* run this section once to fetch and index the data */
$e->create(); // create the index
@hubgit
hubgit / facebook-login.sh
Created February 17, 2010 14:08
Login to Facebook using cURL
#!/bin/bash
# If it redirects to http://www.facebook.com/login.php at the end, wait a few minutes and try again
EMAIL='YOUR_EMAIL' # edit this
PASS='YOUR_PASSWORD' # edit this
COOKIES='cookies.txt'
USER_AGENT='Firefox/3.5'
@hubgit
hubgit / bbc-programmes-rdfa-tracklist.php
Created February 25, 2010 16:55
Extract artist + track information from BBC programmes playlists
<?php
$pid = 'b00qx16f'; // example
$dom = @DOMDocument::loadHTMLFile('http://www.bbc.co.uk/programmes/' . $pid);
$xpath = new DOMXpath($dom);
$items = array();
$nodes = $xpath->query("//*[@typeof='mo:Track']");
foreach ($nodes as $node)
@hubgit
hubgit / ami-to-ebs.sh
Created March 11, 2010 23:20
creating an EBS AMI from a running Instance
# in web browser
# http://uec-images.ubuntu.com/releases/karmic/release/
# canonical karmic 64-bit AMI:
# ami-55739e3c
# canonical karmic 32-bit AMI:
# ami-bb709dd2
# https://console.aws.amazon.com/ec2/home#c=EC2&s=Instances
# Launch Instance > Community AMIs
@hubgit
hubgit / wikipedia.xml
Created March 17, 2010 14:30
Tomcat Context fragment for Solr
<Context docBase="/solr/solr.war" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="/solr/wikipedia" override="true" />
</Context>
@hubgit
hubgit / solrconfig.xml
Created March 17, 2010 14:38
solrconfig.xml for MoreLikeThis and CSV import
<?xml version="1.0" encoding="UTF-8"?>
<config>
<indexDefaults>
<useCompoundFile>false</useCompoundFile>
<mergeFactor>10</mergeFactor>
<ramBufferSizeMB>256</ramBufferSizeMB>
<maxFieldLength>100000000</maxFieldLength>
<writeLockTimeout>1000</writeLockTimeout>
<commitLockTimeout>10000</commitLockTimeout>
<lockType>native</lockType>
@hubgit
hubgit / schema.xml
Created March 17, 2010 14:39
schema.xml for storing Wikipedia data in Solr
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="wikipedia" version="1.2">
<types>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="1" splitOnCaseChange="0" splitOnNumerics="0" stemEnglishPossessive="1"/>
@hubgit
hubgit / efetch-pubmed.wsdl
Created March 28, 2010 11:10
a WSDL 2.0 description of the EUtils EFetch web service
<?xml version="1.0"?>
<description xmlns="http://www.w3.org/ns/wsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2007/06/wsdl/wsdl20.xsd http://www.w3.org/2007/06/wsdl/wsdl20.xsd" xmlns:eutils="http://www.ncbi.nlm.nih.gov/eutils" targetNamespace="http://www.ncbi.nlm.nih.gov/eutils">
<service name="eFetchService" interface="eutils:eFetchInterface">
<endpoint name="eFetchEndpoint" binding="eutils:eFetchBindingHTTP" address="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi"/>
</service>
<binding name="eFetchBindingHTTP" interface="eutils:eFetchInterface" type="http://www.w3.org/ns/wsdl/http" xmlns:whttp="http://www.w3.org/ns/wsdl/http" whttp:methodDefault="GET">
<operation ref="eutils:eFetch"/>
</binding>