View configutil.java
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 <A, B> Optional<Map<B, Set<A>>> tryReverse(final Map<A, Set<B>> maybeInput) { | |
return Optional.ofNullable(maybeInput).map(ConfigUtil::reverse); | |
} | |
private static <A, B> Map<B, Set<A>> reverse(final Map<A, Set<B>> input) { | |
return filterNullValues(input) | |
.flatMap(kvp -> filterNullValues(kvp).map(v -> mkEntry(v, kvp.getKey()))) | |
.collect(groupingBy(x -> x.getKey(), HashMap::new, mapping(y -> y.getValue(), toSet()))); | |
} |
View Lunky's day 11.fs
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
namespace adventofcode | |
open System.Text.RegularExpressions | |
module Day11 = | |
let abc = ['a'..'z'] | |
let succ (c: char) = int c |> (+) 1 |> char | |
let incChar = function |
View Invert statement.cs
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 double RefDoingCalculations() | |
{ | |
if (!_firstGuard) | |
{ | |
return 0; | |
} | |
if (!_secondGuard) | |
{ | |
return FirstCalculation(); |
View viewmodel_spec.coffee
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
describe "ChildrenCheckinViewModel", -> | |
beforeEach -> | |
spyOn(jQuery, 'getJSON') | |
@actualChildren = ko.observableArray() | |
@subject = new Childcarepro.ChildrenCheckinViewModel @actualChildren | |
@response = [ | |
{FIRSTNAME:'John',LASTNAME:'Locke',BIRTHDATE:12312312312}, | |
{FIRSTNAME:'Matt',LASTNAME:'Zandstra',BIRTHDATE:12312312312} | |
] |
View line_spec.rb
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_relative 'bowling' | |
describe Line do | |
def roll_balls(line, frames) | |
frames.each { |pins| line.knock pins } | |
end | |
def self.should_behave_like_a_bowling_game(result, frames, descr=nil) | |
context descr || "when doing a game with #{frames}" do |
View demo.coffee
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 interpolation | |
result = "The result is #{3}" | |
console.log result | |
movieId = 452 | |
url = "http://movies/#{movieId}" | |
console.log url | |
# Functions | |
square = (x) -> x * x |
View fluent_build.cs
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
Build.UsingCsc(config => config | |
.Target(Library) | |
.Sources(....) | |
.References(....) | |
.OutputTo(.....)); |
View wpsh_review.rb
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 File.expand_path(File.dirname(__FILE__) + "/spec_helper") | |
require 'word_press_security_hardening' | |
describe WordPressSecurityHardening do | |
# when method is an instance method use "#" | |
# when is a class method use "." | |
describe '#harden' do | |
let(:db) { double(WordPressDatabase) } | |
let(:config) { double(WordPressConfigFile) } |
View C# NumberFor
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
using System; | |
using System.Linq.Expressions; | |
using System.Web.Mvc; | |
using System.Web.Mvc.Html; | |
using System.Text.RegularExpressions; | |
namespace Website.Extensions | |
{ | |
public static class HtmlExtensions | |
{ |
View expression_property_name.cs
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
// Given the class | |
class PropertyId { | |
public int Id {get;set;} | |
public int StateCode {get;set;} | |
} | |
var id = new PropertyId { Id = 1, StateCode = "NY" }; | |
// call the method | |
SetProperty(id => id.StateCode, "CA"); |
NewerOlder