This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
FILES="fruits.txt veggies.txt" | |
EXCLUSION_FILE="nope-list.txt" | |
COMBINED=$(cat $FILES) | |
FOODS=$(grep -vx -f $EXCLUSION_FILE <(echo $COMBINED | tr ' ' '\n')) | |
TOTAL_FOODS=$(echo "$FOODS" | wc -l | awk '{print $1}') | |
CURRENT_FOOD=1 | |
echo "about to eat $TOTAL_FOODS foods" | |
echo "---------------------------------" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
) | |
type Formatter interface { | |
Format() any | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RoundableRectangle.swift | |
// Created by Tiemen Waterreus on 20/12/2021. | |
// | |
import SwiftUI | |
/// RoundableRectangle is a shape (rounded rectangle) where each | |
/// corner of the rectangle can be rounded with a separate radius | |
struct RoundableRectangle: Shape { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Case<'a> { | |
title: &'a str, | |
max_amount: usize, | |
wanted_amounts: Vec<usize>, | |
} | |
fn main() { | |
// Setup the various cases | |
let simulations = vec![ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Huffman do | |
defmodule Node do | |
defstruct [:left, :right] | |
end | |
defmodule Leaf do | |
defstruct [:value] | |
end | |
def encode(text \\ "cheesecake") do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
// define pins and other variables | |
const int latchPin = 8; | |
const int clockPin = 13; | |
const int dataPin = 11; | |
const int NUMBER_OF_CONNECTED_LEDS = 16; | |
// global array that keeps track of the LEDs brightnesses | |
bool brightnessMask_layer1[NUMBER_OF_CONNECTED_LEDS*4]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void refresh(){ | |
// Loop over each LED | |
for (int cycle = 0; cycle < 16; cycle++) { | |
for (int currentLed = 0; currentLed < NUMBER_OF_CONNECTED_LEDS; currentLed++) { | |
int maskPosition = currentLed * 4; | |
if (cycle == 1 && brightnessMask_layer1[maskPosition]) { | |
turnOnLed(currentLed, 0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void led(int x, int y, int z, int brightness){ | |
// ensure 4-bit limited brightness | |
brightness = constrain(brightness, 0, 15); | |
int ledNr = y*4+x; | |
// turn 4-bit brightness into brightness mask | |
for (int i = 3; i >= 0; i--) { | |
if (brightness - (1 << i) >= 0) { | |
brightness -= (1 << i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool brightnessMask_layer1[NUMBER_OF_CONNECTED_LEDS*4]; | |
bool brightnessMask_layer2[NUMBER_OF_CONNECTED_LEDS*4]; | |
bool brightnessMask_layer3[NUMBER_OF_CONNECTED_LEDS*4]; | |
bool brightnessMask_layer4[NUMBER_OF_CONNECTED_LEDS*4]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// turn on correct LED using 595's | |
void turnOnLed(int ledNr, int layer) { | |
digitalWrite(latchPin, LOW); | |
SPI.transfer(1<<layer); | |
if (ledNr >= 8) { | |
SPI.transfer(1<<ledNr-8); | |
SPI.transfer(0); | |
} | |
else { |
NewerOlder