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
class TokenNotPresent(Exception): | |
""" | |
The token is missing from the URL | |
""" | |
pass | |
class ValidationError(Exception): | |
""" | |
This is an exception from a library like [Pydantic](https://docs.pydantic.dev/latest/) | |
""" |
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()))); | |
} |
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 |
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(); |
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} | |
] |
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 |
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 |
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(.....)); |
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) } |
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 | |
{ |
NewerOlder