Skip to content

Instantly share code, notes, and snippets.

@snerpton
snerpton / IProductService.cs
Created November 10, 2020 00:06 — forked from Shazwazza/IProductService.cs
Example of creating a custom lucene index in Umbraco 8
/// <summary>
/// Custom service to work with products
/// </summary>
public interface IProductService
{
IEnumerable<Product> GetAll();
}
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Odin.MemberReport.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Http.Results;
using System.Web.Mvc;
using Odin.MemberReport.Utilities;
@snerpton
snerpton / unixCommands.sh
Last active October 15, 2019 09:47
Useful UNIX commands
#OSX: Query when a password was last set
dscl . read /Users/<username> | grep --context=3 passwordLastSetTime
#OSX: Set password policy
#https://drpebcak.svbtle.com/managing-local-password-policy-with-pwpolicy
//Not my code, but not sure where it came from.
using System;
using System.Net;
public static class IPAddressExtensions
{
public static IPAddress GetBroadcastAddress(this IPAddress address, IPAddress subnetMask)
{
byte[] ipAdressBytes = address.GetAddressBytes();
@snerpton
snerpton / whois.sh
Created March 29, 2016 15:11
Do a whois on a list of IP addresses
while read ip; do org=$(whois $ip | grep Organization); netname=$(whois $ip | grep netname); amey=$(whois $ip | grep -i amey); ent=$(whois $ip | grep -i enterprise); echo "$ip: $org -- $netname -- $amey -- $ent"; done < ipaddress.txt
#ipaddress.txt is a list of IP addresses to check
#
#
@snerpton
snerpton / ScanFileForNumberOfTextMatches.ps
Created March 17, 2016 11:15
Scan file for number of text matches
$process = Get-Process -Id $pid
$process.PriorityClass = 'BelowNormal'
#$process.PriorityClass = 'Idle'
function GetOccurrenceInFile($1)
{
@snerpton
snerpton / SQL scratch pad.sql
Last active October 15, 2019 09:49
SQL scratch pad
DROP TABLE [dbo].[iislog]
CREATE TABLE [dbo].[iislog] (
[date] [varchar] (50) NULL,
[time] [varchar] (50) NULL ,
[c-ip] [varchar] (50) NULL ,
[cs-method] [varchar] (50) NULL ,
[cs-uri-stem] [varchar] (255) NULL ,
[cs-uri-query] [varchar] (2048) NULL ,
[sc-status] [varchar] (50) NULL ,
@snerpton
snerpton / ImportIISLogsIntoSQLServer.sql
Last active October 15, 2019 09:49
Import IIS logs into SQL server
-- Source: https://support.microsoft.com/en-us/kb/296085
-- Note: I hade to make some of the fields longer
CREATE TABLE [dbo].[tablename] (
[date] [datetime] NULL,
[time] [datetime] NULL ,
[c-ip] [varchar] (50) NULL ,
[cs-method] [varchar] (50) NULL ,
[cs-uri-stem] [varchar] (255) NULL ,
[cs-uri-query] [varchar] (2048) NULL ,
@snerpton
snerpton / .hgignore
Last active October 15, 2019 09:49
HG ignore file for Umbraco projects
# Blueprint Web Tech .hgignore file
#
# Thanks to Offroadcode for the inspiration
#
# CA, 11 March 2016
#
# Offroadcode's Mercurial Ignore file
# visit /blog/2012/4/5/mercurial-ignore-file-for-umbraco/ for updates/additions
# Thanks!
#
@snerpton
snerpton / ConvertMetersPerSecondIntoMilesPerHour.cs
Last active October 15, 2019 09:50
Convert meters per second to miles per hour
/// <summary>
/// Convert meters per second to miles per hour
/// </summary>
/// <param name="metersPerSecond"></param>
/// <returns></returns>
private double ConvertMetersPerSecondIntoMilesPerHour(double metersPerSecond)
{
//1 m/s = 2.23694 miles/hour
return metersPerSecond * 2.23694;
}