Skip to content

Instantly share code, notes, and snippets.

View garthgilmour's full-sized avatar

Garth Gilmour garthgilmour

View GitHub Profile
@garthgilmour
garthgilmour / SpringPuzzle.java
Last active October 19, 2022 07:36
Spring DI Puzzle
@SpringBootApplication
public class PuzzleApplication {
@Bean
public CommandLineRunner startup(List<String> data) {
return args -> System.out.println("Result is: " + data.get(0));
}
public static void main(String[] args) {
SpringApplication.run(PuzzleApplication.class, args);
@garthgilmour
garthgilmour / hello_ocaml.ml
Created October 16, 2022 12:45
Hello World in Ocaml
let add a b = a + b
let () = add 12 13 |> Int.to_string |> print_endline
import arrow.core.zip
data class Employee(
val name: String,
val age: Int,
val married: Boolean,
val salary: Double
) {
companion object {
data class Employee(
val name: String,
val age: Int,
val married: Boolean,
val salary: Double
) {
companion object {
fun buildAll(
names: List<String>,
def only_accepts_ints(the_func):
def wrapper(*args):
for position, argument in enumerate(args):
if type(argument) is not int:
raise RuntimeError(f"Invalid argument at position {position}!")
return the_func(*args)
return wrapper
class Person:
def __init__(self, name, age):
self.__name = name
self.__age = age
def __str__(self):
return f"{self.__name} of age {self.__age}"
p1 = Person("Jane", 30)
class Person:
def __init__(me, name, age):
me.name = name
me.age = age
def __str__(me):
return f"{me.name} of age {me.age}"
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def __str__(self):
return f"{self.name} of age {self.age}"
def sample():
print("sample")
return 123
var1 = sample()
var2 = sample
var3 = {sample(): sample}
var2()
myvar1 = bool
myvar2: bool
print(myvar1)
print(myvar2)