Skip to content

Instantly share code, notes, and snippets.

View costr's full-sized avatar
📈

Adam Costenbader costr

📈
View GitHub Profile
@costr
costr / gist:894473fc982f59c23526
Created January 10, 2015 04:40
CSS CALC() Example
#pageTitle {
margin-left: 50px; width: calc(100% - 50px);
...
}
private string RandomString
{
get
{
var path = String.Empty; // returns random string of 11 chars
for (int i = 0; i < 9; i++)
{
path += Path.GetRandomFileName();
}
return path.Replace(".", "");
public static class RepositoryTestingHelper
{
public static DbSet<T> GetQueryableMockDbSet<T>(List<T> sourceList) where T : class
{
var dbSet = GetMockDbSet(sourceList);
return dbSet.Object;
}
public static Mock<DbSet<T>> GetMockDbSet<T>(List<T> entities) where T : class
{
@costr
costr / ExecutionBuilder.cs
Last active May 30, 2019 03:44
Retry Utility
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Configuration;
namespace Utiltiies
{
public class ExecutionBuilder
{
@costr
costr / Node-Red-WebScrapper_to_Home_Assistant_Example.js
Created June 29, 2019 15:10
As someone who fishes near Okoboji, IA I wanted fishing reports but I found that the IA DNR site had annoying modals and required several clicks to get what I wanted. Instead I wanted to compile the fishing information and pump the information into Home Assistant for faster digestion.
[
{
"id": "338f10b4.b5013",
"type": "tab",
"label": "Fishing",
"disabled": false,
"info": ""
},
{
"id": "c551c71b.11cd28",
@costr
costr / ___readme.md
Last active January 8, 2020 14:55
Slack Slash Command Issuing From Home Assistant

The Problem

I am in multiple Slack teams and have messages coming in frequently throughout the day. I am also on phone calls with clients all day who don't want to feel like I'm distracted during the call. I could put myself DND (do not disturb) on each slack instance but that's time consuming and I cannot always predict when I'll have a call.

My Current Solution

I found a brilliant Slack app, called "OTTT", that allows you to issue slash commands to set your DND for a specified amount of time. To make this more awesome it also allows you, for a modest service fee, to link your Slack team instances so that one slash command sets all of your workspaces to DND. [u]This is what I need![/u]

Now with use of the Ariela app call state sensor and the Slack notify component, with a few small tweaks, I can auto DND when I'm on a call....ah, sweet silence.

Home School Schedule

8:30 - Breakfast

9:00 - Specials Video on Fridays

9:30 - Short Movement Time (Go Noodle or yoga)

9:45 - Morning Announcements

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@costr
costr / ExecutionTimeLogger.cs
Last active July 8, 2021 21:02
Execution time logging in C# with usings
using System;
using System.Diagnostics;
namespace Tools.Debugging
{
public class ExecutionTimeLogger : IDisposable
{
private readonly Stopwatch watch;
private readonly string _titleForWhatIsBeingTracked;
private readonly string _callingMethodName;
@costr
costr / FindSqlTableByColumnName.sql
Last active May 3, 2021 15:46
Find SQL Table by Column Name
SELECT
COLUMN_NAME AS 'ColumnName'
,TABLE_SCHEMA AS 'TableSchema'
,TABLE_NAME AS 'TableName'
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
COLUMN_NAME LIKE '%COLUMN_NAME_HERE%' -- <-- REPLACE COLUMN FILTER
ORDER BY
TableSchema