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
| from datetime import datetime | |
| GITLAB_URL = "https://gitlab.example.com" # adjust | |
| PRIVATE_TOKEN = "your-token-here" | |
| AUTHOR_EMAIL = "[email protected]" | |
| SINCE = "2025-01-01T00:00:00Z" | |
| UNTIL = "2025-12-31T23:59:59Z" | |
| # Add project IDs you contribute to | |
| PROJECT_IDS = [123, 456] |
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 Heap<T> { | |
| selectMax: (l: T, r: T) => boolean; | |
| data: T[]; | |
| constructor(selectMax: (l: T, r: T) => boolean) { | |
| this.selectMax = selectMax; | |
| this.data = []; | |
| } | |
| length(): number { |
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
| /** | |
| * Given a start node and a function which provides an Iterable of adjacent nodes for any node, | |
| * perform a breadth-first traversal of the graph and yield each visited node together with | |
| * the minimum number of steps needed to reach that node from the start node. | |
| */ | |
| function *bft<T>(start: T, adjacent: (node: T) => Iterable<T>): IterableIterator<[T, number]> { | |
| const visited: Set<T> = new Set(); | |
| const queue: T[] = [start]; | |
| visited.add(start); | |
| var depth = 1; |
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
| module Lib | |
| ( playRepeatedly, | |
| firstStep | |
| ) where | |
| import System.IO | |
| data GameStep = Guess { animalName :: String } | |
| | Question { | |
| question :: String, |
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 itertools | |
| from urllib import request | |
| import os | |
| if not os.path.isfile('count_1w.txt'): | |
| request.urlretrieve( | |
| "https://norvig.com/ngrams/count_1w.txt", | |
| "count_1w.txt") |
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 String ofNullableExample(Map<String, String> map) { | |
| return Optional.ofNullable(map.get(key)) | |
| .orElseThrow(() -> new ItemNotFoundException(key)); | |
| } | |
| public String nullCheckingExample(Map<String, String> map) { | |
| String valueAtKey = map.get(key); | |
| if (valueAtKey == null) { | |
| throw new ItemNotFoundException(key); | |
| } |
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 final class Person { | |
| // Publicly accessible, all parameters validated. | |
| public static Person with(String name, int age, String favouriteColour) { | |
| checkArgument(age > 0, "age must be greater than 0"); | |
| return new Person( | |
| checkNotNull(name, "name must not be null"), | |
| age, | |
| checkNotNull(favouriteColour, "favouriteColour must not be null") |
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 { expect } from 'chai'; | |
| import 'mocha'; | |
| import { mock, instance, when, anyString, verify } from "ts-mockito"; | |
| class HelloEndpoint { | |
| constructor(private service: HelloService) {} | |
| async handle(evt: any): Promise<any> { | |
| const greeting = await this.service.sayHello(evt.queryStringParameters.name); | |
| return { |
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 { expect } from 'chai'; | |
| import 'mocha'; | |
| class HelloEndpoint { | |
| constructor(private service: HelloService) {} | |
| async handle(evt: any): Promise<any> { | |
| const greeting = await this.service.sayHello(evt.queryStringParameters.name); | |
| return { | |
| body: greeting |
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 { expect } from 'chai'; | |
| import 'mocha'; | |
| class HelloEndpoint { | |
| constructor(private service: HelloService) {} | |
| async handle(evt: any): Promise<any> { | |
| const greeting = await this.service.sayHello(evt.queryStringParameters.name); | |
| return { | |
| statusCode: 200, |
NewerOlder