This file contains hidden or 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 SomeClassUnderTest: | |
| def some_method_under_test(self, value): | |
| match value: | |
| case str(): | |
| return f'{int(value):.2f}' | |
| case int(): | |
| return f'{value:.2f}' | |
| case float(): | |
| return f'{value:.2f}' | |
| case _: |
This file contains hidden or 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 SomeClassUnderTest { | |
| public String someMethodUnderTest(Object input) { | |
| return switch (input) { | |
| case Number number -> String.format("%.2f", number.doubleValue()); | |
| case String string -> String.format("%.2f", Double.parseDouble(string)); | |
| case null -> "null"; | |
| default -> input.toString(); | |
| }; | |
| } | |
| } |
This file contains hidden or 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
| # | |
| # To use this temlate, which sets RSpec as the testing framework: | |
| # | |
| # rails new my-app --skip-test -m ~/rspec_template.rb | |
| # | |
| gem_group :development, :test do | |
| gem "rspec-rails" | |
| end |
This file contains hidden or 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 SomeClassUnderTest | |
| def some_method_under_test(input) | |
| input.to_s | |
| end | |
| end |
This file contains hidden or 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
| handlers.findAll { name, handler -> | |
| if (handler.match.maximumNumberOfParameters == 1) { | |
| handler.match notification | |
| } else { | |
| handler.match notification, origin | |
| } | |
| }.each { name, handler -> | |
| if (handler.handle.maximumNumberOfParameters == 1) { | |
| handler.handle notification | |
| } else { |
This file contains hidden or 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
| #!/usr/bin/perl | |
| use Digest::SHA qw(hmac_sha1_hex); | |
| open(KEYFILE, "gitpull.secret"); | |
| chomp($secret = <KEYFILE>); | |
| close(KEYFILE); | |
| print "Content-type: text/plain\n"; | |
| print "\n"; |
This file contains hidden or 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
| package springpack.model | |
| import grails.rest.* | |
| @Resource(uri='/users', formats=['json', 'xml']) | |
| class User { | |
| String username | |
| String email |
This file contains hidden or 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
| Employee.withCriteria { | |
| projections { | |
| groupProperty "gender" | |
| rowCount() | |
| } | |
| }.inject([:]) { histo, row -> | |
| histo[row[0]] = row[1] | |
| histo | |
| } |
This file contains hidden or 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 org.apache.commons.lang.StringUtils | |
| class CopyMatcher { | |
| def triggerWord | |
| def matches(product) { | |
| product.productCopy.any { StringUtils.containsIgnoreCase it.copy, triggerWord } | |
| } |