Skip to content

Instantly share code, notes, and snippets.

@rabestro
rabestro / Bob.pq
Created March 23, 2024 18:29
Bob. Solution for Power Query M language
(message as text) as text =>
let
yelling = Text.Upper(phrase) = phrase and Text.Lower(phrase) <> phrase,
question = Text.EndsWith(phrase, "?"),
phrase = Text.Trim(message)
in if phrase = "" then
"Fine. Be that way!"
else if yelling and question then
"Calm down, I know what I'm doing!"
else if yelling then
@rabestro
rabestro / test.java
Last active September 9, 2023 08:07
FizzBuzz Filter
IntStream ints = rangeClosed(1, 20);
IntPredicate fizz = i->i%3==0;
IntPredicate buzz = i->i%5==0;
IntPredicate fizzBuzz =...
assertThat(ints.filter(fizzBuzz))
.containsExactly(4,7,8,9,13,14,19);
@rabestro
rabestro / post
Last active August 31, 2023 16:40
GPT-4 Session to Markdown
#!/usr/bin/env bash
#
# Copyright (c) 2023 Jegors Čemisovs
# License: MIT
# Repository: https://github.com/rabestro/gpt4-session-to-markdown
#
# Converts GPT-4 chat session JSON data to markdown format and
# adds YAML front matter to the top of the file to prepare it
# for publishing on the Jekyll site.
#
@rabestro
rabestro / bob.go
Created July 17, 2023 08:32
Bob - AI implementation
func Hey(remark string) string {
remark = strings.TrimSpace(remark)
if remark == "" {
return "Fine. Be that way!"
}
isQuestion := strings.HasSuffix(remark, "?")
isYelling := strings.ToUpper(remark) == remark && strings.ToLower(remark) != remark
@rabestro
rabestro / bob.go
Created July 17, 2023 08:22
Bob - bob.go
// Package bob implements a solution for the bob exercise from the Exercism Go track.
package bob
// Hey takes a message as input, and returns Bob's response to that remark.
func Hey(message string) string {
remark := newRemark(message)
switch {
case remark.isSilence():
return "Fine. Be that way!"
@rabestro
rabestro / Remark.go
Last active July 17, 2023 08:20
Bob - Remark.go
package bob
import (
"strings"
"unicode"
)
type Remark string
func newRemark(remark string) Remark {
@rabestro
rabestro / roman_numerals.go
Last active July 14, 2023 19:27
Roman Numerals
// Package romannumerals provides methods for manipulating numbers into roman numerals
package romannumerals
import "errors"
type RomanNumeral struct {
Value int
Symbol string
}
package com.epam.flipflop;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.function.Predicate;
class CopilotTest {
@Test
@rabestro
rabestro / README.md
Last active March 16, 2023 21:35
Matching Brackets

Given a string containing brackets [], braces {}, parentheses (), or any combination thereof, verify that any and all pairs are matched and nested correctly.

How to run

sed -Enf parentheses.sed parentheses.txt

Output

def word_key: ascii_downcase | explode | sort;
(.subject | length) as $size |
(.subject | ascii_downcase) as $subject |
(.subject | word_key) as $subject_key |
def is_candidate: length == $size and ascii_downcase != $subject;
def is_anagram: word_key == $subject_key;
[