Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
if [[ -z `which cc` ]]; then
echo "Please install Xcode from the app store, then install the command line tools."
read -p "Press enter when done"
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
fi
if [[ -z `which gcc-4.2` ]]; then
Host *
ServerAliveInterval 30
ServerAliveCountMax 2
ControlPath ~/.ssh/master-%r@%h:%p
ControlMaster auto
proj_id = 10010
search_svc = jira.component_mgr.getSearchService
q = search_svc.parseQuery(jira.user('eanderson'), "project=qa and Customer is not empty").getQuery
res = search_svc.search(jira.user('eanderson'), q, com.atlassian.jira.web.bean.PagerFilter.getUnlimitedFilter())
res.getIssues.each do |issue|
cf = jira.custom_field(issue, "Customer")
issue.getCustomFieldValue(cf).split(",").map{|x| x.strip.gsub(' ', '_')}.each do |label|
require 'rubygems'
module Gem
class << self
def hacked_set_paths(gpaths)
@gem_path = gpaths
@gem_path << Gem.dir
end
require 'rubygems'
gem_path = "/some/path"
if ENV['GEM_PATH']
ENV['GEM_PATH'] = gem_path + File::PATH_SEPARATOR + ENV['GEM_PATH']
else
ENV['GEM_PATH'] = gem_path
end
p ENV['GEM_PATH']
@RequestMapping(POST_URL)
public String showPost(RequestParts parts) {
if (!parts.hasParts()) {
// show general page
}
else {
// Show specific page (parts.get(0))
}
}
String[] parts = UrlUtils.breakUri(req.getRemoteUri(), URL_POST);
if (parts == null) {
// Do code to show an archive or whatever you want when the * part is missing
}
else {
// parts[0] will have what you want.
}
public class UrlUtils {
public static String[] breakUri(final String uri, final String expectedUrl) {
Pattern p = Pattern.compile(expectedUrl.replace("*", "(.*?)"));
Matcher m = p.matcher(uri);
if (m.find()) {
String[] ret = new String[m.groupCount()];
for (int i=0; i&lt;ret.length; i++) {
ret[i] = m.group(i+1);
}
return ret;
public static final String URL_POST = "/post/*/";
@RequestMapping(URL_POST)
public String showPost(HttpServletRequest req) {
...
}
import junit.framework.TestCase;
public class StrategyTest extends TestCase {
public void testSequentialStrategy() {
GuessTheNumber guesser = new GuessTheNumber(5, 100);
SequentialStrategy strategy = new SequentialStrategy(guesser);
for (int i=0; i&lt;3; i++) {
try {