Skip to content

Instantly share code, notes, and snippets.

@jordanfarrer
jordanfarrer / .woff MIME type web.config fix
Created October 2, 2013 16:41
Prevent messages in the Chrome debugger for .woff fonts when served from IIS
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
</system.webServer>
@jordanfarrer
jordanfarrer / Web.config for State Server
Created October 10, 2013 20:27
The necessary elements in a web.config to use a ASP.NET State Server instead of the default InProc mode.
<system.web>
<sessionState
mode="StateServer"
stateConnectionString="tcpip=localhost:42424"
cookieless="false"
timeout="120" />
</system.web>
@jordanfarrer
jordanfarrer / Full_Database_Backup_Script
Created November 22, 2014 15:55
Full Database Backup Script
DECLARE @BackupPath nvarchar(512) = '<Directory Path of Destination Folder>'
DECLARE @BackupName nvarchar(512) = '<Name of Backup File>'
DECLARE @FullBackupPath nvarchar(512) = @BackupPath + '\' + @BackupName + '.bak'
BACKUP DATABASE <Database Name>
TO DISK = @FullBackupPath
WITH FORMAT,
MEDIANAME = @BackupName,
NAME = '<Backup Name>'
-- REMEMBER: Add the SQL Server user to be able to write to the destination directory
@jordanfarrer
jordanfarrer / ps-set-reset-dns
Created July 9, 2015 17:25
PowerShell Set/Reset DNS
# This will give a list of interfaces (along with index)
Get-DnsClient
Set-DnsClientServerAddress -InterfaceIndex <Interface Index> -ServerAddresses ("<IP Address>", "<IP Address 2>")
Set-DnsClientServerAddress -InterfaceIndex <Interface Index> -ResetServerAddresses
@jordanfarrer
jordanfarrer / Calculate-MovieDuration.ps1
Created October 16, 2015 15:31
Calculates total duration of movies within a directory
$totalSeconds = 0
$wmp = New-Object -ComObject wmplayer.ocx
ls {{movieDirectoryPathHere}} -Recurse -Filter *.m4v | %{
$movie = $wmp.newMedia($_.FullName)
$totalSeconds += $movie.duration
}
Write-Host "$totalSeconds seconds."
@jordanfarrer
jordanfarrer / lambda-security-group-change-notification.js
Last active February 17, 2018 21:21
Sends an email using SES to an email (provided by OwnerDL tag) when changes are made to an AWS Security Group.
var fromAddress = "[email protected]"; // TODO: Change this to your desired from address
var aws = require('aws-sdk');
var ses = new aws.SES({ apiVersion: '2010-12-01' });
exports.handler = function (event, context) {
// Validate the incoming event
if (!event.Records
|| event.Records.length == 0
|| !event.Records[0].Sns
@jordanfarrer
jordanfarrer / IAM-Lambda-SES-Full-Access
Last active November 3, 2015 20:18
IAM Role Policy for a Lambda function that needs to be able to send email using SES.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
@jordanfarrer
jordanfarrer / aws-lambda-ami-lookup.js
Created November 11, 2015 06:38
A sample Lambda function that looks up the latest AMI ID for a given region and architecture.
/**
* A sample Lambda function that looks up the latest AMI ID for a given region and architecture.
**/
// Map instance architectures to an AMI name pattern
var archToAMINamePattern = {
"PV64": "amzn-ami-pv*.x86_64-ebs",
"HVM64": "amzn-ami-hvm*.x86_64-gp2",
"HVMG2": "amzn-ami-graphics-hvm-*x86_64-ebs*"
};
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation AMI Look Up Sample Template: Demonstrates how to dynamically specify an AMI ID. This template provisions an EC2 instance with an AMI ID that is based on the instance's type and region. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters": {
"InstanceType" : {
"Description" : "EC2 instance type",
"Type" : "String",
"Default" : "t2.micro",
@jordanfarrer
jordanfarrer / sample-template.py
Created May 19, 2016 16:03
troposphere-sample
from troposphere import Ref, Template
import troposphere.ec2 as ec2
t = Template()
instance = ec2.Instance("myinstance")
instance.ImageId = "ami-951945d0"
instance.InstanceType = "t1.micro"
t.add_resource(instance)
print(t.to_json())