Skip to content

Instantly share code, notes, and snippets.

@laidback
laidback / c_nostd.txt
Created October 27, 2024 16:53 — forked from tcoppex/c_nostd.txt
Writing C software without the standard library [Linux Edition] - Franc[e]sco's Gopherspace
###################################################################
Writing C software without the standard library
Linux Edition
###################################################################
There are many tutorials on the web that explain how to build a
simple hello world in C without the libc on AMD64, but most of them
stop there.
I will provide a more complete explanation that will allow you to
build yourself a little framework to write more complex programs.
#!/usr/bin/env bash
# create the base lint result
spectral lint --quiet --format json --output lint.json code/build/api-spec/openapi3.yaml
# process to code quality format
jq -c '[.[] | { description: .message, original: ., location: { path: .source, lines: { begin: .range.start.line }}}]' lint.json > base.json
jq -c '.[]' base.json | while read -r line ; do
sum=$(echo "$line" | md5sum | cut -d' ' -f1);
#!/usr/bin/env bash
# Filename: ${filename}
# Description: ${filedesc}
# Maintainer: Lukas Ciszewski <lukas.ciszewski@gmail.com>
# set shell options
# * fail immediately on the first error occuring
# * allow clean trapping for ERR
# * fail also if the call to nested functions fails
@laidback
laidback / go-json.go
Created April 28, 2018 21:30
go-json created by laidback - https://repl.it/@laidback/go-json
package main
import (
"encoding/json"
"fmt"
)
type resp struct {
Fname string `json:"fname, string"`
}

Forwarding Rsyslog

We want to forward messages using an intermediate rsync forwarder/broker. We do not want the broker to save any messages from the clients and we also want to forward the broker messages to the Rsyslog Sink.

Useful Links

@laidback
laidback / java_cars_detail.java
Created February 17, 2018 17:28
java_cars_detail created by laidback - https://repl.it/@laidback/javacarsdetail
interface SubSystem {
public void startSystem();
public void stopSystem();
public SubSystemState getState();
}
interface SubSystemState {}
enum Color { WHITE, BLACK, RED, BLUE, GREEN; }
enum EngineType { DIESEL, GASOLINE; }
@laidback
laidback / go-routines.go
Created February 17, 2018 17:28
go-routines created by laidback - https://repl.it/@laidback/go-routines
package main
import "os"
import "fmt"
import "time"
import "runtime/debug"
import "runtime/pprof"
var _ = os.Stdout
var _ = debug.PrintStack
@laidback
laidback / go-factorial.go
Created February 17, 2018 17:27
go-factorial created by laidback - https://repl.it/@laidback/go-factorial
// Provide simple time measured factorial function versions
// * iterative
// * recursive
// * tail recursive
package main
import (
"fmt"
"time"
)
# some converge rest api
curl http://127.0.0.1:4774/api/v1/resources/modules/hello.hcl
curl http://127.0.0.1:4774/api/v1/resources/binary -H "Accept: text/plain" | shasum
# download converge binary
curl http://127.0.0.1:4774/api/v1/resources/binary -H "Accept: text/plain" -O
# use the binary
chmod +x binary
./binary
$ python -c "import os; print('\n'.join(os.environ['PATH'].split(':')))"