Skip to content

Instantly share code, notes, and snippets.

@mastry
mastry / colors.scss
Created June 28, 2023 21:06
SASS color definitions (borrowed from Tailwind)
$color-slate-50: #f8fafc;
$color-slate-100: #f1f5f9;
$color-slate-200: #e2e8f0;
$color-slate-300: #cbd5e1;
$color-slate-400: #94a3b8;
$color-slate-500: #64748b;
$color-slate-600: #475569;
$color-slate-700: #334155;
$color-slate-800: #1e293b;
$color-slate-900: #0f172a;
@mastry
mastry / WebBrowserBahaviors.cs
Last active October 12, 2022 13:03
Use this to data bind the Source property to a URL
static class WebBrowserBehaviors
{
public static readonly DependencyProperty BindableSourceProperty =
DependencyProperty.RegisterAttached(
"BindableSource",
typeof(string),
typeof(WebBrowserBehaviors),
new UIPropertyMetadata(null, BindableSourceChanged));
static void BindableSourceChanged(object sender, DependencyPropertyChangedEventArgs e)
@mastry
mastry / Get-MSMQDepth.ps1
Last active June 15, 2019 17:02
Continuously sample the queue depth of a single queue on multiple servers. Handy for troubleshooting.
param(
[string[]]
$ComputerName,
[string]
$QueueName,
[int]
$SampleRate = 5 # once every 5 seconds
)
@mastry
mastry / Get-CurrentIISLogs.ps1
Last active May 28, 2019 01:29
Retrieves the most recent IIS log file from a list of servers. Assumes the logs are in the default location (change first line of PROCESS section if needed).
[CmdletBinding()]
Param(
[Parameter(Position=0, ValueFromPipeline = $true, Mandatory = $true)]
[string[]] $ComputerName,
[switch] $Compress
)
BEGIN {
@mastry
mastry / AppSettings.cs
Last active May 28, 2019 01:36
Strongly Typed Configuration in a DotNet Core EXE
class AppSettings
{
private IConfigurationRoot _configuration;
public AppSettings()
{
// Build the config with support for reload on change
_configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
@mastry
mastry / stripxml.py
Last active November 11, 2015 21:41
#!/usr/bin/env python3
# stripxml.py
#
# Usage: stripxml.py
# or
# python stripxml.py
# Prints the text from the specified XML file (all tags are filtered out). The input file is unaltered.
#
import sys
from enum import Enum
@mastry
mastry / ElasticIndex.cs
Created November 10, 2015 22:16
Simple Elasticsearch Index Management Class in C#
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
namespace Mastry.Elasticsearch
{
public class ElasticIndex
@mastry
mastry / es-on-centos7.md
Last active May 13, 2023 21:24
Installing Elasticsearch 2.0 on CentOS 7

#Installing Elasticsearch 2.0 on CentOS 7

##Overview This gist describes how to install Elasticsearch 2.0 on CentOS 7. Some of this information is straight from the Elasticsearch site, some of it is specific to CentOS 7, and a lot of it is specific to the enviroment I was creating at the time for syslog capture. YMMV.

If you are using a different OS you can probably adapt these instructions, but I recommend going over the official documentation first.

##Assumptions and Background Each node in the cluster was a clean install of CentOS 7. I used the "Compute Node" installation option with no additional packages.