Skip to content

Instantly share code, notes, and snippets.

@rajrao
rajrao / SqlUtilities.GetDotnetType.cs
Last active April 23, 2023 16:59 — forked from JerryNixon/SqlUtilities.GetDotnetType.cs
Convert SQL Type to .NET Type
public static class SqlUtilities
{
readonly static SqlDataTypeOption[] unsupportedTypes = new[]
{
SqlDataTypeOption.Sql_Variant,
SqlDataTypeOption.Timestamp,
SqlDataTypeOption.Rowversion,
};
public static string GetDotnetType(this SqlDataTypeOption sqlDataType, bool isNullable = false)
@rajrao
rajrao / lz77.cs
Created July 4, 2020 14:28 — forked from mjs3339/lz77.cs
C# Implementation LZ77 Compression Algorithm
public static class Lz77
{
private const int RingBufferSize = 4096;
private const int UpperMatchLength = 18;
private const int LowerMatchLength = 2;
private const int None = RingBufferSize;
private static readonly int[] Parent = new int[RingBufferSize + 1];
private static readonly int[] LeftChild = new int[RingBufferSize + 1];
private static readonly int[] RightChild = new int[RingBufferSize + 257];
private static readonly ushort[] Buffer = new ushort[RingBufferSize + UpperMatchLength - 1];
@rajrao
rajrao / button.py
Created August 1, 2016 02:46 — forked from ecaron/button.py
Python script for listening to Raspberry Pi button push
import requests
import time
import RPi.GPIO as GPIO
url = 'http://nightlight/' # I map this to my internal DNS hosting the node app
gpio_pin=18 # The GPIO pin the button is attached to
longpress_threshold=5 # If button is held this length of time, tells system to leave light on
GPIO.setmode(GPIO.BCM)
GPIO.setup(gpio_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)