Skip to content

Instantly share code, notes, and snippets.

View patsissons's full-sized avatar
🏗️
Always be building!

Pat Sissons patsissons

🏗️
Always be building!
View GitHub Profile
@patsissons
patsissons / .deps...npm...@openzeppelin...contracts@4.8.3...access...AccessControl.sol
Created May 24, 2023 16:24
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=undefined&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
@patsissons
patsissons / accountQuery.graphql
Created June 19, 2020 23:17
the future of Libra & GraphQL
{
# fetch an account by its public address
accountState(address: "3584d309264da2a85991b2bcdc44b7c7") {
sequenceNumber
authenticationKey
# scan sent events for this addresss
sentEvents(limit: 1) {
sequenceNumber
data {
@patsissons
patsissons / __main__.py
Created May 19, 2017 18:27
TeamCity python test suite loader/runner
from teamcity import is_running_under_teamcity
from teamcity.unittestpy import TeamcityTestRunner
import os
import unittest
# update these variables to configure how the test runner loads the test suite
testsPath = './tests'
testsPattern = '*_test.py'
@patsissons
patsissons / Extensions.cs
Created September 9, 2014 02:37
Extension methods to easily and efficiently convert a file to a compressed, password encrypted byte array (and back)
// I had a requirement to read a file from local storage, compress the content, the encrypt the data with a password.
// There are many ways to do this, but I wanted to do it the most efficient and elegant way possible.
// This method takes advantage of using Streams (which pipe data between streams), which gives us a clean and efficient solution.
// I am using all the generally accepted best practices to accomplish the task at hand.
// I have implemented the solution as an extension method to simplify usage.
public static partial class ExtensionMethods
{
#region File Encryption / Decryption
// WARN: this is an empty salt, create your own random salt using
// handy extension method to reduce a DateTime to the precision of a T-SQL DATETIME so that you can compare it with
// CLR DateTime's in unit tests
public static partial class ExtensionMethods
{
public static DateTime ToSqlDateTimePrecision(this DateTime source)
{
using (var ctx = new Data.DataContext())
{
return ctx.ExecuteQuery<DateTime>(string.Format("SELECT CONVERT(DATETIME, '{0}', 0)", source)).Single();
}
@patsissons
patsissons / INotifyPropertyChangedExtensions.cs
Created May 20, 2014 04:44
INotifyPropertyChanged to Observable (portable FromPropertyChangedPattern)
namespace Test
{
public static class INotifyPropertyChangedExtensions
{
public static IObservable<EventPattern<PropertyChangedEventArgs>> FromPropertyChangedPattern(this INotifyPropertyChanged source)
{
return Observable.FromEventPattern<PropertyChangedEventHandler, PropertyChangedEventArgs>(
x => source.PropertyChanged += x,
x => source.PropertyChanged -= x);
}