Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Setup and start Sauce Connect for your TravisCI build
# This script requires your .travis.yml to include the following two private env variables:
# SAUCE_USERNAME
# SAUCE_ACCESS_KEY
# Follow the steps at https://saucelabs.com/opensource/travis to set that up.
#
# Curl and run this script as part of your .travis.yml before_script section:
# before_script:
@robyoung
robyoung / xmlbug.go
Created April 2, 2013 19:54
Go's XML parser seems to have trouble with empty elements. Tested with: 1.0.3 and 16533:7cfa82648086
package xmlparse
import (
"encoding/xml"
"fmt"
"io"
"strings"
"testing"
)
# install virtualenv
sudo pip install virtualenv
cd [location of ghtools clone]
# Create and activate a new virtual environment
virtualenv venv
source venv/bin/activate
# Install the current directory in the virtual environment
@robyoung
robyoung / gist:4100502
Created November 17, 2012 21:38
Find files generator
func findFiles(paths []string) <-chan string {
files := make(chan string)
// Start a go routine to feed the channel
go func(files chan <- string, paths []string) {
// Walk the filesystem for each path, calling the annonymous
// function provided for each subpath.
for _, path := range paths {
filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
// Do not send paths if they're directories
@robyoung
robyoung / index.html
Created October 24, 2012 11:18
Collision detection
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="scripts/d3.v2.js"></script>
<script type="text/javascript" src="scripts/jquery-1.7.2.js"></script>
<script type="text/javascript">
var height = 400,
width = 800,
pathData,
theLoop, theLoopCount = 0;
Scenario Outline:
When I search for "<query>"
Then I <imperative> see "<path>" in the top <n> results
Examples:
| query | imperative | path | n |
| jobs | should | /jobs-jobsearch | 2 |
| jobs | should | /find-job | 2 |
| job search | should | /jobs-jobsearch | 2 |
| find a job | should | /jobs-jobsearch | 2 |
@robyoung
robyoung / gist:3092498
Created July 11, 2012 19:12
Elasticsearch document structure
{
"title": "Example title",
"format": "Answer",
"section": "Example",
"additional_links": [
{"title": "title one", "link": "/one"},
{"title": "title two", "link": "/two"}
]
}
@robyoung
robyoung / gist:3092478
Created July 11, 2012 19:11
Solr document structure
{
"title": "Example title",
"format": "Answer",
"section": "Example",
"additional_links__title": ["title one", "title two"],
"additional_links__link": ["/one", "/two"]
}
@robyoung
robyoung / gist:3092083
Created July 11, 2012 18:06
Solr Query
curl -XGET 'http://localhost:8983/solr/rummager/select?qt=dismax&q=bank+hoildays&fl=title%2Clink%2Cdescription%2Cformat&bq=format%3A%28transaction+OR+recommended-link%29%5E3.0&hl=true&hl.fl=description%2Cindexable_content&hl.simple.pre=HIGHLIGHT_START&hl.simple.post=HIGHLIGHT_END&start=0&rows=50&mm=75%25'
@robyoung
robyoung / gist:3092079
Created July 11, 2012 18:06
Elasticsearch Query
curl -XGET 'http://localhost:9200/rummager/_search' -H 'Content-type: application/json' -d '{
"from": 0, "size": 50,
"query": {
"bool": {
"must": {
"query_string": {
"fields": ["title", "description", "indexable_content"],
"query": "bank holidays",
"minimum_should_match": "75%"
}