Skip to content

Instantly share code, notes, and snippets.

View thebentern's full-sized avatar

Ben Meadors thebentern

View GitHub Profile
@thebentern
thebentern / missing_indexes.sql
Last active August 16, 2016 14:22
SQL Server View missing indexes
-- Credit to https://basitaalishan.com/2013/03/13/find-missing-indexes-using-sql-servers-index-related-dmvs/
SELECT CAST(SERVERPROPERTY('ServerName') AS [nvarchar](256)) AS [SQLServer]
,db.[database_id] AS [DatabaseID]
,db.[name] AS [DatabaseName]
,id.[object_id] AS [ObjectID]
,id.[statement] AS [FullyQualifiedObjectName]
,id.[equality_columns] AS [EqualityColumns]
,id.[inequality_columns] AS [InEqualityColumns]
,id.[included_columns] AS [IncludedColumns]
,gs.[unique_compiles] AS [UniqueCompiles]
@thebentern
thebentern / s3-upload.ps1
Last active August 1, 2016 14:23
S3 Uploader Powershell
$key = "mykey"
$secretKey = "mysecretkey"
$bucketName = "bucketName"
Set-AWSCredentials -AccessKey $key -SecretKey $secretKey -StoreAs MyProfileName
foreach ($file in Get-ChildItem "D:\Exceed Extracts\Batch")
{
if ($file.Length -gt 0)
{
@thebentern
thebentern / screen.sh
Last active August 1, 2016 14:07
Screen commands in linux
screen -S "my screen name"
# Ctrl-A + D will detach you from that screen
# Show the list of available screens
screen -r
# To reattach to that screen
screen -r "screen id"
Add-Type -AssemblyName System.Web
function New-Title {
param(
[Parameter(ValueFromPipeline=$true)]
$title
)
Process {
@{title=$title}
}
@thebentern
thebentern / model-callbacks.rb
Created August 18, 2016 14:08
Display model callbacks for :save :after
pp Model
._save_callbacks
.select {|cb| cb.kind == :after}
.map{|cb| { key: cb.instance_variable_get(:@key), name: cb.instance_variable_get(:@name)}
@thebentern
thebentern / grafan-run.sh
Last active December 17, 2022 07:18
Setup InfluxDB (docker), Telegraf, and Grafana (docker) for metrics
# Pull dockerfile
docker pull grafana/grafana
# Run the docker container
docker run -i -p 3000:3000 grafana/grafana
@thebentern
thebentern / GetHtmlFromViewResult.cs
Last active October 3, 2016 13:00
Gets html content from View result
private async Task<string> GetHtml(Controller controller, ViewResult viewResult)
{
using (var stringWriter = new StringWriter())
{
var viewEngineResult = viewResult.ViewEngine.FindView(controller.ControllerContext,
viewResult.ViewName,
false);
var viewContext = new ViewContext(
controller.ControllerContext,
@thebentern
thebentern / gulpfile.js
Last active October 7, 2016 14:32
.NET Core App Coverage and Report gulp
var gulp = require("gulp"),
rimraf = require("rimraf"),
concat = require("gulp-concat")
exec = require("gulp-exec");
gulp.task('report', ['test'], function(cb) {
return exec('ReportGenerator.exe -reports:coverage.xml" -targetdir:"coverage\"');
});
gulp.task('test', function(cb) {
@thebentern
thebentern / hummus.md
Last active March 3, 2017 01:59
Black-eyed pea hummus

Black-eyed pea hummus

Ingredients

  • 2 x 15.5 oz cans of Trappy's jalapeno black-eyed peas cooked and rinsed
  • 3/4 cup of tahini
  • 3 cloves of fresh garlic
  • 1/4 cup of oil (I used avocado)
  • 1 lemon juiced
  • 2 tsp salt
@thebentern
thebentern / launch.json
Created December 8, 2016 22:08
Ruby on Rails launch.json
configurations": [
{
"name": "Rails server",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/rails",
"args": ["server"]
}
]