Skip to content

Instantly share code, notes, and snippets.

View kveratis's full-sized avatar

Daniel Petersen kveratis

View GitHub Profile
@kveratis
kveratis / counter.js
Created April 24, 2018 04:04
Example Jest Tests
import { createStore } from 'redux';
const INCREASE_COUNT = 'INCREASE_COUNT';
// Action Creator using ES5 Arrow Syntax
export const increaseCount = (amount = 1) => ({
type: INCREASE_COUNT,
payload: amount,
});
@kveratis
kveratis / .gitmessage.txt
Last active May 15, 2018 16:02
My Git Configuration
Subject line (try to keep under 50 characters)
Multi-line description of commit,
feel free to be detailed.
Related work items: #<TFS_ITEM#>
@kveratis
kveratis / WeeklyDateRanges.cs
Created July 1, 2014 15:19
Calculating first and last day of week in C#
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WeeklyDateRanges
{
@kveratis
kveratis / .gitignore
Last active May 16, 2017 04:17
Best Visual Studio gitignore
#OS junk files
[Tt]humbs.db
*.DS_Store
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
*.[Oo]bj
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stp_MaintainIndexesInDatabase]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[stp_MaintainIndexesInDatabase]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Daniel Petersen
@kveratis
kveratis / ExampleResultSet.php
Created September 23, 2013 19:31
PHP Examples with PDO
define('DB_HOST', 'localhost');
define('DB_PORT', '3306');
define('DB_NAME', 'mydb');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '...');
try {
$dsn = 'mysql:host=' . DB_HOST . ';port=' . DB_PORT .
';dbname=' . DB_NAME;
$pdo = new PDO($dsn, DB_USERNAME, DB_PASSWORD);
$pdo->setAttribute(PDO::ATTR_ERRMODE,
@kveratis
kveratis / FileProcessor.tt
Created August 20, 2013 01:09
My T4 Templates for String and File Handling
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ output extension=".generated.cs" #>
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
#region TextBlock
public partial class TextBlock : List<string>
@kveratis
kveratis / DefaultDatawarehouseSchema.sql
Created August 16, 2013 21:04
Basic data warehouse schema (SQLite code)
DROP INDEX IF EXISTS IDX_DimTimeZone_Conversion;
DROP TABLE IF EXISTS DimTimeZone;
CREATE TABLE DimTimeZone(
TimeZoneKey INT PRIMARY KEY,
Name VARCHAR(50) NOT NULL,
Description VARCHAR(150) NOT NULL,
StandardConversion INT NOT NULL DEFAULT 0,
DSTConversion INT NOT NULL DEFAULT 0,
ObservesDST TINYINT NOT NULL DEFAULT 0
);
@kveratis
kveratis / CreateDateDimension.sql
Last active November 14, 2022 01:50
Common Data Mart/Data Warehouse Code for creating Date and Time Dimensions. Note the Time Dimension is distinct from Date Dimension as it tracks time of day and time durations. The bucket fields are useful for analysis of data in blocks of time or duration and can be used as the buckets in a histogram.
DROP TABLE [dbo].[DimDate]
GO
CREATE TABLE [dbo].[DimDate] (
[DateKey] [int] NOT NULL PRIMARY KEY,
[FullDate] [date] NOT NULL,
[Year] [smallint] NOT NULL,
[Quarter] [tinyint] NOT NULL,
[MonthOfYear] [tinyint] NOT NULL,
[MonthName] [varchar](10) NOT NULL,
[WeekOfYear] [tinyint] NOT NULL,
@kveratis
kveratis / SQLNotes.md
Created August 16, 2013 20:47
Some basic notes on SQL Joins and Wildcards including some notes on UNION and Table Variables

Wildcards

% - A substitute for zero or more characters (can be in the middle) _ - A substitute for exactly on character [charlist] - Any single character in the list [!charlist] - Any single character not in the list

JOIN (INNER JOIN)

Returns rows when there is at least one match in both tables.