Skip to content

Instantly share code, notes, and snippets.

@bmeredith
bmeredith / Context.sol
Last active May 31, 2021 18:18 — forked from ebrahimasifismail/Context.sol
Sample Contracts
pragma solidity ^0.5.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
@bmeredith
bmeredith / Controller.cs
Created July 23, 2020 19:15
Autofac Keyed Services
public class MyController : ControllerBase
{
private readonly Func<int, IService> _serviceFactory;
public MyController(Func<int, IService> serviceFactory)
{
_serviceFactory = serviceFactory;
}
public ActionResult<string> GetSomething()
### Keybase proof
I hereby claim:
* I am bmeredith on github.
* I am bmeredith (https://keybase.io/bmeredith) on keybase.
* I have a public key ASA6LjRdfTa14oEMqKF-PNN5E0ri3_H1lWqan9TFRPakkQo
To claim this, I am signing this object:
// uses the nuget package:
// https://www.nuget.org/packages/System.Linq.Dynamic.Core/
//
// the real magic comes from here:
// https://github.com/StefH/System.Linq.Dynamic.Core/blob/master/src/System.Linq.Dynamic.Core/DynamicClassFactory.cs
public class DynamicSqlObjectFactory
{
// this will return a DynamicClass object which can be manipulated using straight reflection
// or using any of System.Dynamic.DynamicObject's methods as well
public DynamicClass Create(IDictionary<string, object> item, IEnumerable<DatabaseColumn> fields)
04e735c1e62eab4f988ad80c6a541f20b2c1fd4f6c54fa2a6e4f7de679774cfb7725e9a1f89e50e521adb600e7aa09c81e0b744ca2f438ac4f156b5925c3b62f93
public class AutofacCommandDispatcher : ICommandDispatcher
{
private readonly IComponentContext _context;
public AutofacCommandDispatcher(IComponentContext context)
{
_context = context;
}
public void Dispatch(ICommand command)
@bmeredith
bmeredith / FunctionOverride
Created July 5, 2015 03:49
Overriding jQuery Validate
$.validator.prototype.checkForm = function () {
this.prepareForm();
for (var i = 0, elements = (this.currentElements = this.elements()) ; elements[i]; i++) {
if (this.findByName(elements[i].name).length != undefined && this.findByName(elements[i].name).length > 1) {
for (var cnt = 0; cnt < this.findByName(elements[i].name).length; cnt++) {
this.check(this.findByName(elements[i].name)[cnt]);
}
} else {
this.check(elements[i]);