Skip to content

Instantly share code, notes, and snippets.

View srleyva's full-sized avatar

Stephen Leyva srleyva

  • Seattle, WA
View GitHub Profile
from abc import ABC, abstractmethod
from copy import deepcopy
from dataclasses import dataclass, field
from enum import Enum
from itertools import cycle
from random import randint
from typing import ClassVar, List, Optional
from tabulate import tabulate
@srleyva
srleyva / sort.py
Created January 3, 2021 21:50
Messing around with sorting algos in python
from abc import ABC, abstractmethod
import unittest
from random import randint
import inspect
import sys
class Sort(ABC):
@abstractmethod
use std::iter::FromIterator;
use std::mem::replace;
pub enum Link<T> {
Empty,
More(Box<Node<T>>)
}
pub struct Node<T> {
item: T,
// This powerful wrapper provides the ability to store a positive integer value.
// Rewrite it using generics so that it supports wrapping ANY type.
struct Wrapper<T> {
value: T
}
impl<T> Wrapper<T> {
pub fn new(value: T) -> Wrapper<T> {
Wrapper { value }
@srleyva
srleyva / backoff.py
Created February 4, 2020 21:54
Pluggable backoff class
import time
class BackOff:
def __init__(self, backoff_type='fib', retries=10):
self._backoff_type = backoff_type
self.retries = retries
self._backoff_generator = None
package main
import (
"fmt"
"math/rand"
"time"
)
type Job struct {
Name string

Creating the toolchain

We must build from source as our OS does not have a package manager.

  • configure - will create a Makefile based off of user input. Checks for appropriate dependancies and compilers.
  • make - calls compilers and complies the code.
  • make install - copies compiled binaries to correct location

Bootstrapping is essentially using host OS tools (without creating dependancies on the host) to create a temporary toolchain in the LFS env. This allows us to use a temporary toolchain to build our OS.

Subnetting

What is an IP?

Unique address that machines have.

192 . 168 . 1 . 10 1100000.10101000.00000001.00001010

---
apiVersion: v1
kind: ConfigMap
metadata:
name: redis-cluster
labels:
app: redis-cluster
data:
fix-ip.sh: |
#!/bin/sh
package main
import (
"fmt"
"sort"
)
func main() {
cache := make(map[int]int)
for i := 1; i < 50; i++ {