Skip to content

Instantly share code, notes, and snippets.

View karoltheguy's full-sized avatar

Carol Ouellet karoltheguy

View GitHub Profile
@karoltheguy
karoltheguy / cross apply xml columns.sql
Last active November 30, 2017 00:01
Read from XML column (varchar type)
SELECT
CONVERT(varchar(19), t.completed AT TIME ZONE 'UTC' AT TIME ZONE 'US Eastern Standard Time') AS 'Completed'
,m.n.value('./@value', 'varchar(100)') AS One_Bill_Account_Number
,p.n.value('./@value', 'varchar(100)') AS Suspension_Start_Date
,o.n.value('./@value', 'varchat(100)') AS Suspension_End_Date
FROM (SELECT status, completed, queueident, loaded, CAST(data AS xml) AS data FROM BPAWorkQueueItem)t
CROSS APPLY t.data.nodes('/collection/row/field[./@name="One Bill Account Number"]')m(n)
CROSS APPLY t.data.nodes('/collection/row/field[./@name="Suspension Start Date"]')p(n)
CROSS APPLY t.data.nodes('/collection/row/field[./@name="Suspension End Date"]')o(n)
@karoltheguy
karoltheguy / urlencoreExt.cs
Created June 18, 2018 16:01
StringExtension URLEncode
public static string UrlEncode(this string input)
{
const int maxLength = 32766;
if (input == null)
throw new ArgumentNullException("input");
if (input.Length <= maxLength)
return Uri.EscapeDataString(input);
@karoltheguy
karoltheguy / webfocus.xml
Created June 18, 2018 18:33
Webfocus Notepad++ Language
<NotepadPlus>
<UserLang name="Focus Procedure" ext="fex" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">03 03 04 04 00-* 00$ 00$$ 01 02</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
class Program
{
static void Main(string[] args)
{
string mainkey = "ghRag3Svho6nMYBbyCnEJc4wVRTkGX82";
string result = Encrypt("EncryptMe", mainkey);
Console.WriteLine(result);
Console.ReadKey();
@karoltheguy
karoltheguy / 3DES encrypt-decrypt.ps1
Created September 19, 2018 22:14
TripleDES encode-decode in powershell
$TDESKEY = 'fhEzg3Svho6nMYPcyCnEJc4qVRTkGY82'
##ENCODE
$password = "Im a password"
$MS = New-Object System.IO.MemoryStream
$keyb = [Convert]::FromBase64String($TDESKEY)
$TD = New-Object System.Security.Cryptography.TripleDESCryptoServiceProvider
$CS = New-Object System.Security.Cryptography.CryptoStream($MS,$TD.CreateEncryptor($keyb, $TD.IV), [System.Security.Cryptography.CryptoStreamMode]::Write)
$Writer = New-Object System.IO.StreamWriter($CS)
@karoltheguy
karoltheguy / set-acl.ps1
Created February 12, 2019 21:40
Powershell Set folder permission
$aclfolder "C:\MyFolder"
$acl = Get-Acl $aclfolder
$ar = New-Object System.Security.AccessControl.FileSystemAccessRule("username", "FullControl", "Allow")
$acl.SetAccessRule($ar)
Set-Acl -Path $aclfolder -AclObject $acl
@karoltheguy
karoltheguy / flatfile to dt.cs
Created March 4, 2019 22:13
Simple Flat File to Datatable
static DataTable Parsing(string path, string[] delimiter, bool HasHeader, bool HasFieldsinQuotes)
{
DataTable dt = new DataTable();
using (TextFieldParser reader = new TextFieldParser(path))
{
reader.TextFieldType = FieldType.Delimited;
reader.SetDelimiters(delimiter);
reader.HasFieldsEnclosedInQuotes = HasFieldsinQuotes;
@karoltheguy
karoltheguy / Convert RTF to Plain.cs
Created March 5, 2019 23:29
Convert RTF file content to plain text string
string path = @"C:\test\test rich.rtf";
System.Windows.Forms.RichTextBox rtBox = new System.Windows.Forms.RichTextBox();
// Get the contents of the RTF file. Note that when it is
// stored in the string, it is encoded as UTF-16.
string s = System.IO.File.ReadAllText(path);
// Convert the RTF to plain text.
rtBox.Rtf = s;
@karoltheguy
karoltheguy / ldapsearch.ps1
Created May 6, 2019 18:57
Powershell LDAP Search
([ADSISearcher]”Name=Carol Ouellet”).FindAll().Properties
@karoltheguy
karoltheguy / GacInstall
Created July 5, 2019 15:36
Register to GAC
string path = @"full path of dll";
Publish obj = new Publish();
obj.GacInstall(path);