Skip to content

Instantly share code, notes, and snippets.

View cronjob.go
/*
Copyright 2022 The Kubernetes authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
View turing
// Input: a binary number n
// Ouput: accepts if n mod 3 == 0
// Example: accepts 110 (=6)
//
// ------- States -----------|
// q0 - mod3 == 0 |
// q1 - mod3 == 1 |
// q2 - mod3 == 2 |
// qaccept - accepting state |
//---------------------------|
@arriqaaq
arriqaaq / dp.md
Last active Nov 23, 2021
Golang Design Patterns in Kubernetes [WIP]
View dp.md

Design patterns are typical solutions to common problems in software design. The most universal and high-level patterns are architectural patterns. Developers can implement these patterns in virtually any language. Unlike other patterns, they can be used to design the architecture of an entire application.

In addition, all patterns can be categorized by their intent, or purpose. We covers two main groups of patterns:

  • Creational patterns provide object creation mechanisms that increase flexibility and reuse of existing code.
  • Structural patterns explain how to assemble objects and classes into larger structures, while keeping the structures flexible and efficient.
  • Behavioral patterns take care of effective communication and the assignment of responsibilities between objects.

Creational Patterns

@arriqaaq
arriqaaq / vb.sh
Created Sep 10, 2021
setting up ubuntu bionic vagrant image
View vb.sh
vagrant init ubuntu/bionic64
vagrant up
vagrant ssh
@arriqaaq
arriqaaq / ns.sh
Created Sep 9, 2021
Network namespaces [Bridge + VETH]
View ns.sh
#!/usr/bin/env bash
if [[ $EUID -ne 0 ]]; then
echo "You must be root to run this script"
exit 1
fi
BR_ADDR="10.10.0.1"
BR_DEV="br0"
View commands.md

Commands

Pseudo file systems

The command ‘uname‘ displays the information about the system.

Syntax:

uname [OPTION]

View error-1.go
type error interface {
Error() string
}
View Dependency-layer
FROM mockingbird/application-go-image
RUN git clone https://github.com/dgraph-io/badger
WORKDIR /badger
WORKDIR /badger
RUN make VERBOSE=1 && make install
View gist:9cc948c0c57fcfa6dca49a80d1b809b3
FROM mockingbird/base-image
ENV LANG=C.UTF-8
RUN curl -LO https://dl.google.com/go/go1.12.2.linux-amd64.tar.gz \
&& chown root:root go1.12.2.linux-amd64.tar.gz \
&& tar -xzf go1.12.2.linux-amd64.tar.gz \
&& rm go1.12.2.linux-amd64.tar.gz \
&& mv go /usr/local
View mysql-dependency-layer
FROM mockingbird/base-image
ENV MYSQL_MAJOR 5.6
ENV MYSQL_VERSION 5.6.44-1debian9
RUN echo "deb http://repo.mysql.com/apt/debian/ stretch mysql-${MYSQL_MAJOR}" > /etc/apt/sources.list.d/mysql.list
# the "/var/lib/mysql" stuff here is because the mysql-server postinst doesn't have an explicit way to disable the mysql_install_db codepath besides having a database already "configured" (ie, stuff in /var/lib/mysql/mysql)
# also, we set debconf keys to make APT a little quieter
RUN { \