This file contains 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
#!/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 |
This file contains 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
Host * | |
ServerAliveInterval 30 | |
ServerAliveCountMax 2 | |
ControlPath ~/.ssh/master-%r@%h:%p | |
ControlMaster auto |
This file contains 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
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| |
This file contains 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
require 'rubygems' | |
module Gem | |
class << self | |
def hacked_set_paths(gpaths) | |
@gem_path = gpaths | |
@gem_path << Gem.dir | |
end |
This file contains 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
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'] |
This file contains 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
@RequestMapping(POST_URL) | |
public String showPost(RequestParts parts) { | |
if (!parts.hasParts()) { | |
// show general page | |
} | |
else { | |
// Show specific page (parts.get(0)) | |
} | |
} |
This file contains 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
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. | |
} |
This file contains 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
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<ret.length; i++) { | |
ret[i] = m.group(i+1); | |
} | |
return ret; |
This file contains 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
public static final String URL_POST = "/post/*/"; | |
@RequestMapping(URL_POST) | |
public String showPost(HttpServletRequest req) { | |
... | |
} |
This file contains 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 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<3; i++) { | |
try { |