Skip to content

Instantly share code, notes, and snippets.

Sam samjgriffin89

Block or report user

Report or block samjgriffin89

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
samjgriffin89 / DatabaseExtensions
Created May 1, 2015
Check to see if a column exists in a datareader
View DatabaseExtensions
public static bool HasColumn(this IDataRecord dr, string columnName)
for (int i = 0; i < dr.FieldCount; i++)
if (dr.GetName(i).Equals(columnName, StringComparison.InvariantCultureIgnoreCase)) return true;
return false;
samjgriffin89 / RsaEncryptionHelper
Created Jun 26, 2015
RSA Encryption/Decryption with X509 Certificates
View RsaEncryptionHelper
private X509Certificate2 RsaCertificate
var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
var certs = store.Certificates.Find(X509FindType.FindBySubjectDistinguishedName, ConfigurationManager.AppSettings.Get("CertificateSubjectName"), false);
return certs[0];
View DateTimeExtensions
public static DateTime Truncate(this DateTime dateTime, TimeSpan timeSpan)
if (timeSpan == TimeSpan.Zero) return dateTime; // Or could throw an ArgumentException
return dateTime.AddTicks(-(dateTime.Ticks % timeSpan.Ticks));
You can’t perform that action at this time.