Skip to content

Instantly share code, notes, and snippets.

@caelifer
caelifer / build-datadog-agent-rpm_x64-7.50.3.sh
Last active February 14, 2024 00:47
Full Datadog Agent RPM Build
#!/bin/bash
set -xeuo pipefail
RELEASED_VERSION_TAG=${DD_VERSION:-7.50.3}
PRESERVE_WORKSPACE=${KEEP_BUID_WS:-yes}
BUILD_BUILDER=${NEED_BUILDER:-""}
# Create a workspace
WS=$(mktemp --tmpdir=. -d)
@caelifer
caelifer / japh.pl
Created October 16, 2023 18:38
JAPH (just another perl hacker)
#!/usr/bin/env perl
undef$/;$_=<DATA>;y/ODA\n / /ds; @yoda=map{length}split;print chr
oct join('',splice(@yoda,0,3))-111 while@yoda;
__DATA__
DDOOODOOODOOODOOODOOODOOODOOODOOODOOODOOODOOODOOODOOODOOODOOODOOOOOD
D D
D 00O00O000O00O0000 000O DD000000O0 D
D 0DO0000000O0000O00 O00000 00O00000O0O D
D 0000 0O0 O00 O00 00D 0DO D
D 00O0 0O0 00D 000 DO0D00000D D
@caelifer
caelifer / generic-fib.go
Last active May 24, 2022 19:32
Fibonacci number calculator implemented using Go generics.
// Live code - https://go.dev/play/p/EqW-c0gbRqr
package main
import (
"errors"
"fmt"
)
func main() {
@caelifer
caelifer / cpu6502.go
Last active March 5, 2021 01:22
Toy 6502 CPU emulator
// A toy 6502 CPU emulator (WIP). Inspired by a series of lessons by Ben Eater:
// - https://www.youtube.com/channel/UCS0N5baNlQWJCUrhCEo8WlA
// - https://youtu.be/LnzuMJLZRdU
package main
import (
"flag"
"fmt"
"log"
"os"
// Go implementation for the "Functions and Fractals - Recursive Trees - Bash!" problem.
// https://www.hackerrank.com/challenges/fractal-trees-all/problem
package main
import (
"fmt"
"strings"
)
const h = 15 // half-heigth of the Y pattern
@caelifer
caelifer / phone.go
Created January 7, 2020 22:56
Figure out if the phone number is correct without asking for it directly.
// This program provides an answer for one of the Google interview questions described here:
// https://www.businessinsider.com/answers-to-google-interview-questions-2011-11#you-need-to-check-that-your-friend-bob-has-your-correct-phone-number-10
package main
import (
"fmt"
"strings"
)
func main() {
package disruptor
import (
"encoding/binary"
"log"
"runtime"
"sync/atomic"
"time"
)
@caelifer
caelifer / change.go
Last active December 10, 2019 04:55
Calculate change from available pool of coins simulating automatic cash register.
package main
import (
"fmt"
"log"
"strings"
)
func main() {
b := NewBank(map[Coin]int{
import (
"io"
"io/ioutil"
"os"
"path/filepath"
)
// moveFile safely moves files across different file systems.
func moveFile(src, dest string) error {
// Fast path: use os.Rename().
package main
import (
"fmt"
)
func main() {
for i := 0; i <= 45; i++ {
fmt.Printf("%3d %10d\n", i, memFib(i))
}