Skip to content

Instantly share code, notes, and snippets.

View justinmusgrove's full-sized avatar

Justin Musgrove justinmusgrove

View GitHub Profile
@justinmusgrove
justinmusgrove / gist:9019613
Last active August 29, 2015 13:56
CombinationGenerator
@Test
public void test () {
Set<Integer> test = Sets.newHashSet(1, 2, 3, 4);
Set<Set<Integer>> elements = Sets.powerSet(test);
List<Integer> test2 = elements.stream().filter(p -> p.size() == 3).collect(Collectors.toList());
System.out.println(test2);
@justinmusgrove
justinmusgrove / gist:9655266
Created March 20, 2014 01:07
Concat two streams, distinct, sum
IntStream stream1 = IntStream.of(1, 2, 3);
IntStream stream2 = IntStream.of(1, 2, 3);
int val = IntStream.concat(stream1, stream2).distinct().sum();
System.out.println(val);
sudo gem install jekyll --pre
Password:
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... yes
checking for sys/select.h... yes
checking for poll.h... yes
In markdown page:
{% assign titleScrubbed = page[1] | scrubPageTitle %}
Jekyll plugin:
module Jekyll
module ScrubPageTitle
def scrubPageTitle(input)
map = {"Java -" => "", "| Level Up Lunch" => ""}
re = Regexp.new(map.keys.map { |x| Regexp.escape(x) }.join('|'))
input = input.gsub(re, map)
List<String> strings = new ArrayList<String>();
strings.add("one");
strings.add("two");
strings.add("three");
String firstElement = null;
if (!strings.isEmpty() && strings.size() == 1) {
firstElement = strings.get(0);
}
@justinmusgrove
justinmusgrove / ConvertListToMap.java
Created September 3, 2013 23:57
ConvertListToMap.java
@Test
public void test_convertListToMap () {
// create a list
List<Movie> movies = Lists.newArrayList();
movies.add(new Movie(1, "The Shawshank Redemption"));
movies.add(new Movie(2, "The Godfather"));
// convert list to map
Map<Integer,Movie> mappedMovies = Maps.uniqueIndex(movies, new Function <Movie,Integer> () {
static String bmiDescription (double bmi) {
if (bmi < 18.5) {
return "You are underweight.";
} else {
if (bmi > 25) {
return "You are overweight.";
} else {
return "Your weight is optimal.";
}
}
[
{
"context":"org.springframework.web.context.WebApplicationContext:/post-configure-actuator-non-boot-app",
"parent":null,
"beans":[
{
"bean":"componentConfig",
"scope":"singleton",
"type":"com.levelup.spring.config.ComponentConfig$$EnhancerByCGLIB$$13013792",
"resource":"file [/Users/justinm/Documents/springsource/vfabric-tc-server-developer-2.9.3.RELEASE/base-instance/wtpwebapps/post-configure-actuator-non-boot-app/WEB-INF/classes/com/levelup/spring/config/ComponentConfig.class]",
# This is a sample build configuration for Ruby.
# Check our guides at https://confluence.atlassian.com/x/VYk8Lw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: ruby:2.3.0
pipelines:
default:
- step: