Skip to content

Instantly share code, notes, and snippets.

View whaley's full-sized avatar

Jason Whaley whaley

  • Asheville, NC
View GitHub Profile
public class FizzBuzz {
public static void main(String... args) {
for (int i = 1; i <= 100; i++) {
StringBuilder sb = new StringBuilder();
if (i % 3 == 0) { sb.append("Fizz"); }
if (i % 5 == 0) { sb.append("Buzz"); }
if (sb.length() == 0) { sb.append(i); }
System.out.println(sb.toString());
}
public class FizzBuzz {
public static void main(String... args) {
for (int i = 1; i <= 100; i++) {
StringBuilder sb = new StringBuilder();
if (i % 3 == 0) { sb.append("Fizz"); }
if (i % 5 == 0) { sb.append("Buzz"); }
if (sb.length() == 0) { sb.append(i); }
System.out.println(sb.toString());
}
#!/bin/bash
rootDirectory="$1"
stringToMatch="$2"
for jarfile in $(find "$rootDirectory" -name '*.jar')
do
grepOut=$(jar tvf "$jarfile" | grep "$stringToMatch")
if [[ $grepOut ]]
then
public <T> T publishEndpointAndReturnProxy(Class<T> jaxWsAnnotatedInterface, T serviceImplementation) {
if (jaxWsAnnotatedInterface.isInterface() &&
jaxWsAnnotatedInterface.getAnnotation(WebService.class) != null &&
jaxWsAnnotatedInterface.isInstance(serviceImplementation)) {
String endpointUrl = getAvailableEndpointUrl();
endpoint = Endpoint.publish(endpointUrl, serviceImplementation);
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
@whaley
whaley / gist:1193944
Created September 5, 2011 02:43
brew install macvim failure
brew install -v macvim > /tmp/brew_install_v_macvim.txt
/private/tmp/homebrew-macvim-7.3-61-tfg2/b4winckler-macvim-af13572/src/configure: line 5558: Python: command not found
** BUILD FAILED **
The following build commands failed:
CompileC build/MacVim.build/Release/MacVim.build/Objects-normal/x86_64/MMFullscreenWindow.o MMFullscreenWindow.m normal x86_64 objective-c com.apple.compilers.gcc.4_2
(1 failure)
make[1]: *** [macvim] Error 65
make: *** [first] Error 2
@whaley
whaley / App.java
Created September 24, 2011 00:51
Message Groups in Camel
package com.brinksys.camel;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.camel.component.ActiveMQComponent;
import org.apache.activemq.pool.PooledConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
@whaley
whaley / message_groups_output.txt
Created September 24, 2011 12:45
Message Groups in Camel Output
2445 [Camel (camel-1) thread #0 - JmsConsumer[Message.Group.Test]] INFO Route A - Received: 0
2447 [Camel (camel-1) thread #0 - JmsConsumer[Message.Group.Test]] INFO Route A - Received: 1
2460 [Camel (camel-1) thread #0 - JmsConsumer[Message.Group.Test]] INFO Route A - Received: 2
2466 [Camel (camel-1) thread #0 - JmsConsumer[Message.Group.Test]] INFO Route A - Received: 3
2472 [Camel (camel-1) thread #0 - JmsConsumer[Message.Group.Test]] INFO Route A - Received: 4
2479 [Camel (camel-1) thread #0 - JmsConsumer[Message.Group.Test]] INFO Route A - Received: 5
2482 [Camel (camel-1) thread #0 - JmsConsumer[Message.Group.Test]] INFO Route A - Received: 6
2485 [Camel (camel-1) thread #0 - JmsConsumer[Message.Group.Test]] INFO Route A - Received: 7
2488 [Camel (camel-1) thread #0 - JmsConsumer[Message.Group.Test]] INFO Route A - Received: 8
2490 [Camel (camel-1) thread #0 - JmsConsumer[Message.Group.Test]] INFO Route A - Received: 9
@whaley
whaley / gmvn
Created September 25, 2011 14:33
Passing mvn output through awk.
#! /bin/bash
mvn $* | awk '
{
print;
if($0 ~ ".*ERROR.*") system("/usr/local/bin/growlnotify -n mavenError -t Maven Error -m\""$0 "\"")
if($0 ~ ".*BUILD SUCCESSFUL.*") system("/usr/local/bin/growlnotify -n mavenComplete -t Maven Goals Complete -m\""$0 "\"")
}
END {
}'
@whaley
whaley / error
Created September 25, 2011 14:34
mvnsh error
mvnsh(/):rice> mvn clean
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
role: org.apache.maven.settings.building.SettingsBuilder
roleHint:
@whaley
whaley / Ternary.java
Created September 25, 2011 14:35
The problem with the ternary operator in Java
Number n = isTrue() ? Integer.valueOf(1) : Double.valueOf(1.0);