Skip to content

Instantly share code, notes, and snippets.

🏠
Happily Working from home

Garrett Serack fearthecowboy

🏠
Happily Working from home
Block or report user

Report or block fearthecowboy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View peek.ps1
-HttpPipelineAppend { param($req, $callback, $next )
Write-Host -fore white "Inserted my code in the http pipeline on the way to:`n $($req.RequestUri)."
Write-Host -fore yellow "`n---------------------`n Before We Go!`n---------------------"
Write-host -fore white "Request Headers:";
$($req.Headers) |% { if ($_.Key -ne "Authorization") { Write-host -nonewline -fore cyan " $($_.Key): "; Write-Host -fore green "$($_.Value)" } }
# call the next step in the Pipeline
@fearthecowboy
fearthecowboy / install.ps1
Last active Feb 27, 2019
Setup Test Sandbox for AutoRest
View install.ps1
Set-ExecutionPolicy -Scope LocalMachine Unrestricted -force
$ProgressPreference=0
function ResolvePath {
param (
[string] $FileName
)
$FileName = Resolve-Path $FileName -ErrorAction SilentlyContinue `
-ErrorVariable _frperror
@fearthecowboy
fearthecowboy / new-alias.ps1
Created Feb 1, 2019
A better new-alias for PowerShell
View new-alias.ps1
<#
.SYNOPSIS
Creates a new alias. Better than original New-Alias
.DESCRIPTION
Creates a new Function Alias. Unlike the original New-Alias, this will let you
create an alias that can be a command line or script, in a single command.
View switch.h
#pragma once
#include "device.h"
// this device represents a switch that can be open or closed.
class Switch : public Device {
protected:
// the pin the switch is connected to.
const uint8_t pin;
public:
View blinker.h
#pragma once
#include "device.h"
// our Blinker class, just blinks a light on and off on continually.
class Blinker : public Device {
private:
bool state = false;
public:
// constructor -- pass in the interval for flipping the light.
@fearthecowboy
fearthecowboy / setup.cpp
Last active Dec 9, 2018
Setup Arduino sketch
View setup.cpp
// Setup the sketch.
void setup() {
// we're going to spit some messages out to the serial port.
Serial.begin(19200);
// create the device instances
// blink on and off every two seconds.
bc = new Blinker(2000);
@fearthecowboy
fearthecowboy / app.cpp
Last active Dec 9, 2018
State-machine Arduino example
View app.cpp
// include references to the devices that we'd like to use
#include "blinker.h" // an automated blinker
#include "switch.h" // a device that supports events for a switch (ie, closed, open)
#include "freeMemory.h" // an automated poller that reports teh free memory back to the serial console.
// Handy for debugging and seeing how much memory is getting sucked up.
// First, declare the states we want in our state machine:
States( starting, processing, cleanup ); // these can be anything you'd like.
@fearthecowboy
fearthecowboy / simplest.cpp
Created Dec 9, 2018
Simple Arduino Example
View simplest.cpp
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
@fearthecowboy
fearthecowboy / Append.ps1
Created Jul 30, 2018
HttpPipelineAppend
View Append.ps1
Get-Redis -HttpPipelineAppend { param($req, $callback, $next )
Write-Host -fore white "Inserted my code in the http pipeline on the way to:`n` $($req.RequestUri)."
Write-Host -fore yellow "`n---------------------`n Before We Go!`n---------------------"
Write-host -fore white "Request Headers:";
$($req.Headers) |% { if ($_.Key -ne "Authorization") { Write-host -nonewline -fore cyan " $($_.Key): "; Write-Host -fore green "$($_.Value)" } }
# call the next step in the Pipeline
@fearthecowboy
fearthecowboy / intersect.ts
Last active Jun 13, 2018
Intersection Proxy for Typescript
View intersect.ts
/**
* Creates an intersection object from two source objects.
*
* Typescript nicely supports defining intersection types (ie, Foo & Bar )
* But if you have two seperate *instances*, and you want to use them as the implementation
* of that intersection, the language doesn't solve that for you.
*
* This function creates a strongly typed proxy type around the two objects,
* and returns members for the intersection of them.
You can’t perform that action at this time.