Skip to content

Instantly share code, notes, and snippets.

@KyleGobel
KyleGobel / SqlQueryExtensions.cs
Last active August 29, 2015 14:05
This will take an embedded .sql resource file and return it's string contents. Auto mapping dtos to sql queries that can be easily run
public static class SqlQueryExtensions
{
public static string GetSqlQuery<T>(this T requestDto, Action<string> queryFilter = null, string queryNamespace = null, string filename = null) where T : class
{
const string delimiter = "--start";
var sqlStatement = string.Empty;
//expects the namespace of this file to be the same namespace as the sql query file
var namespacePart = queryNamespace ?? typeof(SqlQueryExtensions).Namespace;
@KyleGobel
KyleGobel / something.json
Created September 2, 2014 18:37
exampledata
window.data = {"startDate":"2014-08-01T00:00:00.0000000-04:00","endDate":"2014-09-02T18:07:51.8644829Z","data":[{"date":"2014-09-02T00:00:00.0000000","revenue":105.4000},{"date":"2014-09-01T00:00:00.0000000","revenue":142.4100},{"date":"2014-08-31T00:00:00.0000000","revenue":133.3000},{"date":"2014-08-30T00:00:00.0000000","revenue":144.8600},{"date":"2014-08-29T00:00:00.0000000","revenue":87.5900},{"date":"2014-08-28T00:00:00.0000000","revenue":112.9100},{"date":"2014-08-27T00:00:00.0000000","revenue":144.5700},{"date":"2014-08-26T00:00:00.0000000","revenue":182.9400},{"date":"2014-08-25T00:00:00.0000000","revenue":124.4300},{"date":"2014-08-24T00:00:00.0000000","revenue":120.4000},{"date":"2014-08-23T00:00:00.0000000","revenue":112.2500},{"date":"2014-08-22T00:00:00.0000000","revenue":131.1500},{"date":"2014-08-21T00:00:00.0000000","revenue":119.6500},{"date":"2014-08-20T00:00:00.0000000","revenue":152.2900},{"date":"2014-08-19T00:00:00.0000000","revenue":106.5800},{"date":"2014-08-18T00:00:00.0000000","rev
@KyleGobel
KyleGobel / upsert.sql
Last active June 27, 2016 16:37
Insert/Update Upsert Trigger in Postgres
CREATE OR REPLACE FUNCTION upsert_user()
RETURNS trigger AS
$upsert_user$
declare
existing record;
begin
if (select EXISTS(select 1 from users where user_id = NEW.user_id)) then
select user_name, user_class, user_age into strict existing from users where user_id = new.user_id;
@KyleGobel
KyleGobel / zip_upload_logs.ps1
Created January 29, 2015 22:07
Zip and upload logs to S3 - Powershell
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
$logFile = Join-Path "C:\inetpub\logs\LogFiles\W3SVC2" "upload_logs.logFile"
Try
{
$files = Get-ChildItem -Filter *.log | where-object {$_.lastwritetime -lt (Get-Date).AddHours(-1)}
$processedDir = Join-Path $scriptPath "uploaded_to_s3"
if ($files.count -gt 0) {
Write-Output "Starting Uploads to S3" | Out-File $logFile -Append
@KyleGobel
KyleGobel / packages.config
Last active August 29, 2015 14:14
Chocolatey Setup Server Script
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="GoogleChrome" />
<package id="SublimeText3" />
<package id="SublimeText3.PowershellAlias" />
<package id="SpaceSniffer" />
<package id="Powershell" />
<package id="pscx" />
<package id="Putty" />
<package id="7zip.commandline" />
<!DOCTYPE html>
<meta charset='utf-8'>
<style>
</style>
@KyleGobel
KyleGobel / data.tsv
Last active August 29, 2015 14:15
sameChart
date product gross_profit
2/19/2015 4 -1397.05
2/18/2015 4 -1834.9384
2/18/2015 9 166.3
2/17/2015 9 134.75
2/17/2015 10 -5.32
2/17/2015 4 -3034.26
2/16/2015 4 -2905.1718
2/16/2015 9 115.7
2/16/2015 10 6.35
@KyleGobel
KyleGobel / instructions.md
Last active August 29, 2015 14:17
Redis Setup

###Instructions

####Setup Sentinel

  1. Copy the sentinel.conf file to /etc/redis/sentinel.conf
  2. Copy the redis-sentinel.sh script to /etc/init.d/redis-sentinel
  3. Give the script execute permissions sudo chmod +x /etc/init.d/redis-sentinel
  4. Start script at boot time sudo update-rc.d redis-sentinel defaults
  5. Copy sentinel to /usr/local/bin/ if you haven't yet
  6. Start sentinel sudo /etc/init.d/redis-sentinel start
<OBJECT ID="DISystemMonitor1" WIDTH="100%" HEIGHT="100%"
CLASSID="CLSID:C4D2D8E0-D1DD-11CE-940F-008029004347">
<PARAM NAME="_Version" VALUE="458755"/>
<PARAM NAME="_ExtentX" VALUE="21087"/>
<PARAM NAME="_ExtentY" VALUE="16193"/>
<PARAM NAME="DisplayType" VALUE="3"/>
<PARAM NAME="ReportValueType" VALUE="0"/>
<PARAM NAME="MaximumScale" VALUE="100"/>
<PARAM NAME="MinimumScale" VALUE="0"/>
<PARAM NAME="ShowLegend" VALUE="1"/>
<form action="http://www.metroeguide.net/search/" method="get" target="meg_menu_display">
<p align="center">
<input type="text" name="q" />
<input type="hidden" name="clientID" value="459" />
<input type="submit" value="Search" />
</p>
</form>