This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Security.Cryptography; | |
using System.Text; | |
public class RSACryptoServiceProviderHelper | |
{ | |
// code from here: | |
// - https://stackoverflow.com/questions/23734792/c-sharp-export-private-public-rsa-key-from-rsacryptoserviceprovider-to-pem-strin | |
// - https://stackoverflow.com/questions/28406888/c-sharp-rsa-public-key-output-not-correct/28407693#28407693 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class AesKeyGenerator | |
{ | |
public static string GenerateKey(int bitStrength) | |
{ | |
// note: valid bit strength for aes: 128, 192, or 256 bits (16, 24, or 32 bytes) | |
var random = new System.Security.Cryptography.RNGCryptoServiceProvider(); | |
var keyArray = new byte[bitStrength / 8]; | |
random.GetBytes(keyArray); | |
var base64key = Convert.ToBase64String(keyArray); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Records": [ | |
{ | |
"EventSource":"aws:sns", | |
"EventVersion":"1.0", | |
"EventSubscriptionArn":"arn:aws:sns:us-west-2:xxxx:xxxx", | |
"Sns": { | |
"Type":"Notification", | |
"MessageId":"88B1B251-2E92-4FC3-BFAA-E3BBD0BAB10A", | |
"TopicArn":"arn:aws:sns:us-west-2:881222951025:survey-tool-ses-delivery", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- script to generate sp_rename commands for all check constraints | |
select | |
ck.name as current_name | |
,po.name as ParentObject | |
,po.type_desc as ParentType | |
,ISNULL(pc.name, N'') as ColumnName | |
,'exec sp_rename @objname = N''[' + ps.name + '].[' + ck.name + ']'', @newname = ''CK_' + po.name + '_' + pc.name + '''' as rename_cmd | |
from | |
sys.check_constraints ck | |
left join sys.objects po on (ck.parent_object_id = po.object_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# delete all bin,obj,node_modules,bower_components,packages,.vs, and *proj.user files and directories | |
Get-ChildItem . -include bin -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } | |
Get-ChildItem . -include obj -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } | |
Get-ChildItem . -include node_modules -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } | |
Get-ChildItem . -include bower_components -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } | |
Get-ChildItem . -include packages -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } | |
Get-ChildItem . -include .vs -Hidden -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } | |
Get-ChildItem . -include *proj.user -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Linq; | |
public class TrivialJsonConverter : JsonConverter | |
{ | |
public override bool CanConvert(Type objectType) | |
{ | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GoogleContactService | |
{ | |
public void CreateContact() | |
{ | |
var cr = this.CreateContactsRequest(); | |
var groups = cr.GetGroups().Entries.ToList(); | |
var myContactsSystemGroup = groups.FirstOrDefault(x => x.SystemGroup == "Contacts"); | |
var newContact = new Contact(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub FindNextValueChangeInColumn() | |
' | |
' FindNextValueChangeInColumn Macro | |
' | |
On Error GoTo ErrHandler | |
Dim currentValue As String | |
Dim compareValue As String | |
currentValue = ActiveCell.Value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table [dbo].[AspNetRoleClaims] ( | |
[Id] int IDENTITY(1, 1) not null, | |
[RoleId] nvarchar(450) not null, | |
[ClaimType] nvarchar(MAX) null, | |
[ClaimValue] nvarchar(MAX) null, | |
constraint [PK_AspNetRoleClaims] primary key clustered ([Id] asc) | |
); | |
go | |
create nonclustered index [IX_AspNetRoleClaims_RoleId] on [dbo].[AspNetRoleClaims] ([RoleId] asc); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copy files older than a given date | |
$items = Get-ChildItem -Path ".\" | Where-Object { $_.CreationTime -le "12/31/2017" } | |
Write-Output "count $($items.Length)" | |
foreach ($item in $items) | |
{ | |
Move-Item -Path $item.FullName -Destination "c:\destination\$($item.Name)" | |
} |