Skip to content

Instantly share code, notes, and snippets.

View SidShetye's full-sized avatar

Sid Shetye SidShetye

View GitHub Profile
@SidShetye
SidShetye / StripeWebhookController.cs
Created October 25, 2012 04:36
Receiving Stripe.com's Webhooks in ASP.NET C#, MVC4
using System;
using System.IO;
using System.Web;
using System.Web.Mvc;
using Stripe; // you need this library https://github.com/jaymedavis/stripe.net
using System.Net;
namespace StripeSampleMVC.Controllers
{
public class StripeWebhookController : Controller
class Program
{
static void Main(string[] args)
{
Application app = new Application();
app.Run();
}
}
public class Application
@SidShetye
SidShetye / genEcCert.bat
Last active December 12, 2015 10:29
A quick but powerful way to create Elliptic curve cryptography certificates and keys using OpenSSL. The keys, certificates are also exported into a .PFX file for exporting into the target environment. The certificates are self signed in this case. Read the batch file comments and modify as you need (eg: from 521 bit key curve to 256 bit key curv…
@echo off
@echo.
@echo Description: Uses OpenSSL to create a 521 bit EC certificate (PEM). Also creates the PKCS#12 file to export the cert as well as the private key (AES256 encrypted)
@echo.
if [%1]==[] goto usage
SET paramFile=%1-param-key.pem
SET keyFile=%1-param-key.pem
SET reqFile=%1-req.pem
@SidShetye
SidShetye / TestSql2012AesEnc_CreateTable.sql
Created February 19, 2013 23:19
Test script to create a dummy table to check SQL server 2012's AES crypto
USE [TestDb]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CreditCard](
[CreditCardID] [int] IDENTITY(1,1) NOT NULL,
[CardType] [nvarchar](50) NOT NULL,
USE TestDb
;
--If there is no master key, create one now.
IF NOT EXISTS
(SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101)
CREATE MASTER KEY ENCRYPTION BY
PASSWORD = 'WeakPassword1234'
GO
CREATE CERTIFICATE Sales09
This file has been truncated, but you can view the full file.
[Tue Dec 10 23:42:47 2013] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:openshift_t:s0:c3,c667
[Tue Dec 10 23:42:47 2013] [error] (2)No such file or directory: mod_mime_magic: can't read magic file /var/lib/openshift/52a7ece65973ca24cf000026/mono/conf/magic
[Tue Dec 10 23:42:47 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Tue Dec 10 23:42:47 2013] [error] (2)No such file or directory: mod_mime_magic: can't read magic file /var/lib/openshift/52a7ece65973ca24cf000026/mono/conf/magic
[Tue Dec 10 23:42:48 2013] [notice] Digest: generating secret for digest authentication ...
[Tue Dec 10 23:42:48 2013] [notice] Digest: done
[Tue Dec 10 23:42:48 2013] [warn] pid file /var/lib/openshift/52a7ece65973ca24cf000026/mono/run/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Tue Dec 10 23:42:48 2013] [notice] Apache/2.2.22 (Unix) mod_mono/2.10 DAV/2 configured -- resuming normal operations
Listening on: /tmp/mod_mono_server_global
Root directory:
@SidShetye
SidShetye / SerializerAvro
Last active November 5, 2021 11:42
Shows how to use the Apache Avro serializer very easily. It assumes that 1) you have already defined the Avro DTO objects in the Avro IDL 2) You've run those IDL files into the code-generator to create your C# classes 3) You've added these code-gen'd Avro classes to your Visual Studio Project
// Copyright 2013, Sid Shetye
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@SidShetye
SidShetye / JiraSQLServer.sql
Last active July 24, 2021 00:40
This is the SQL Server script for creating a Jira compatible SQL Server database/login
-- Outline https://confluence.atlassian.com/display/JIRA/Connecting+JIRA+to+SQL+Server+2012
-- Create the database
CREATE DATABASE jiradb;
GO
ALTER DATABASE jiradb COLLATE SQL_Latin1_General_CP437_CI_AI;
GO
ALTER DATABASE jiradb
SET READ_COMMITTED_SNAPSHOT ON
WITH ROLLBACK IMMEDIATE;
public class Entropy
{
private const long Prime = 179426549;
private const long Prime2 = 46633; // another prime
public static long GetEntropySeed()
{
return Ticks ^ ProcessInfoKey() ^ MemorySizeKey() ^ EnvironmentKey();
}
@SidShetye
SidShetye / HardenSSL.ps1
Last active November 15, 2024 12:07
Script to harden SSL/TLS on Azure Cloud Service
# Call this from inside a startup task/batch file as shown in the next two lines (minus the '# ')
# PowerShell -ExecutionPolicy Unrestricted .\HardenSsl.ps1 >> log-HardenSsl.txt 2>&1
# EXIT /B 0
# Credits:
# http://azure.microsoft.com/blog/2014/10/19/how-to-disable-ssl-3-0-in-azure-websites-roles-and-virtual-machines/
# http://lukieb.blogspot.com/2014/11/tightening-up-your-azure-cloud-service.html
$nl = [Environment]::NewLine
$regkeys = @(