Skip to content

Instantly share code, notes, and snippets.

View rubberduck203's full-sized avatar

Christopher McClellan rubberduck203

View GitHub Profile
@rubberduck203
rubberduck203 / consoletest.cs
Created April 30, 2018 16:10
Example of unit testing .Net console input/output
[Fact]
public void ExampleForTakingControlOfConsole()
{
var stream = new System.IO.MemoryStream();
using (var writer = new System.IO.StreamWriter(stream))
using (var reader = new System.IO.StreamReader(stream))
{
writer.WriteLine("quit");
writer.Flush();
stream.Position = 0; //reset stream before reading
@rubberduck203
rubberduck203 / keybindings.json
Created April 27, 2018 13:19
VS Code Swich Terminal Keybindings
// https://code.visualstudio.com/docs/editor/integrated-terminal#_terminal-key-bindings
[
{
"key": "ctrl+shift+pageup",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
},
{
"key": "ctrl+shift+pagedown",
"command": "workbench.action.terminal.focusNext",
@rubberduck203
rubberduck203 / main.c
Created April 21, 2018 15:37
AVR UART
#include <avr/io.h>
#include <util/delay.h>
/* 9600 8n1 com */
#define BAUD 9600
#define BAUDRATE ((F_CPU)/(BAUD*16UL)-1)
int main(void)
{
@rubberduck203
rubberduck203 / .bash_profile
Last active January 6, 2018 15:02
CentOS config
# .bash_profile
export CLICOLOR=1
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
@rubberduck203
rubberduck203 / .bash_profile
Created January 2, 2018 17:14
My bash profile
export CLICOLOR=1
# user@host:pwd$
# https://superuser.com/questions/239994/how-to-have-full-directory-path-always-shown-in-mac-terminal-like-linux-termina
# pwd and prompt are in the directory color (34 is blue, but homebrew theme displays it as light orange)
export PS1='\u@\h:\e[34m\w\$\e[0m '
export PATH=$PATH:~/Library/Android/sdk/platform-tools
export PATH=$PATH:~/Library/Android/sdk/emulator
@rubberduck203
rubberduck203 / SevenSegment.ino
Created October 15, 2017 20:58
Digital Thermometer Sketches
const uint8_t DATA = 7;
const uint8_t OUTPUT_ENABLE = 8;
const uint8_t LATCH = 9;
const uint8_t CLOCK = 10;
const uint8_t CLEAR = 11;
const uint8_t Zero = 0x3F;
const uint8_t One = 0x06;
const uint8_t Two = 0x5B;
const uint8_t Three = 0x4F;
#Summarize size of the contents of directories under current directory and sort
# get summarized human readable sizes | sort human readable numbers
du -sh ./* | sort -h
# total disk free per partition
df -h
def map = { collection, f ->
def result = []
collection.each { element ->
result.add(f(element))
}
result
}
def reduce = { collection, accumulator, f ->
def result = accumulator
@rubberduck203
rubberduck203 / PutzingWithMonads.cs
Last active August 6, 2017 03:22
Putzing with monads
public class Class1
{
[Fact]
public void applesauce()
{
Result<int> result =
new Success<int>(32)
.Bind(i => new Success<int>(i + 1));
result.OnSuccess(Console.WriteLine);
root@a9b8ec9a8ca9:~# dotnet bin/gitnstats/gitnstats.dll Rubberduck/ | head -103
Repository: Rubberduck/
Branch: next
Commits Path
1754 RetailCoder.VBE/Rubberduck.csproj
983 RetailCoder.VBE/UI/RubberduckUI.resx
965 RetailCoder.VBE/UI/RubberduckUI.Designer.cs
833 RetailCoder.VBE/App.cs
761 Rubberduck.Parsing/VBA/RubberduckParserState.cs