Skip to content

Instantly share code, notes, and snippets.

View pedroreys's full-sized avatar

Pedro Reys pedroreys

View GitHub Profile
@pedroreys
pedroreys / vice_highlight.css
Created March 2, 2020 20:34
Generated with `pygmentize -S vice -f html -a .highlight > vice_highlight`
.highlight .hll { background-color: #ffffcc }
.highlight { background: #000000; color: #ffffff }
.highlight .c { color: #afafd7 } /* Comment */
.highlight .err { color: #ffffff } /* Error */
.highlight .esc { color: #ffffff } /* Escape */
.highlight .g { color: #ffffff } /* Generic */
.highlight .k { color: #87ffff } /* Keyword */
.highlight .l { color: #ffffff } /* Literal */
.highlight .n { color: #ffffff } /* Name */
.highlight .o { color: #ffffff } /* Operator */
@pedroreys
pedroreys / Message.cs
Created April 12, 2013 20:18
Defining a custom JsonConverter and using it with the built-in JsonConverterAttribute
public class Message
{
[JsonConverter(typeof(SHA256StringJsonConverter))]
public string Password { get; set; }
}
@pedroreys
pedroreys / query.sql
Last active February 11, 2021 07:38
SQL Server version of this recursive query example to traverse a tree depth-first http://jakub.fedyczak.net/post/postgresql-with-recursive-tree-traversing-example/
declare @empl table(name nvarchar(max) null, boss nvarchar(max) null);
insert into @empl values ('Paul',null);
insert into @empl values ('Luke','Paul');
insert into @empl values ('Kate','Paul');
insert into @empl values ('Marge','Kate');
insert into @empl values ('Edith','Kate');
insert into @empl values ('Pam','Kate');
insert into @empl values ('Carol','Luke');
insert into @empl values ('John','Luke');
@pedroreys
pedroreys / gist:2963187
Created June 21, 2012 00:45
Alias to generate pretty git log with graph of all branches
[alias]
    lg = log --graph --pretty=format:'%C(yellow)%d%Creset %C(cyan)%h%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=short --all

This alias is going to generate an output like this:

git log example output

@pedroreys
pedroreys / boxstarter.ps1
Last active December 9, 2019 19:36 — forked from jessfraz/boxstarter.ps1
Boxstarter Commands for a new Windows box.
# Description: Boxstarter Script
# Author: Jess Frazelle <jess@linux.com>
# Last Updated: 2017-09-11
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:

Yes, assuming all four machines' Dispense and Deposit methods share the same contract, all you need is to create an interface that they all implement:

public interface IMachine
{
    void Dispense();
    void Deposit();
}

Keybase proof

I hereby claim:

  • I am pedroreys on github.
  • I am pedroreys (https://keybase.io/pedroreys) on keybase.
  • I have a public key ASArm9QdTrzFw6VyQzQe25SpFbdA74G78NRCkRSuqjHz3Qo

To claim this, I am signing this object:

public class PurchaseItemValidator : IValidator<PurchaseItem>
{
private IEnumerable<IValidationRule<PurchaseItem>> _rules;
public PurchaseItemValidator(IEnumerable<IValidationRule<PurchaseItem>> rules)
{
_rules = rules;
}
public IEnumerable<ValidationResult> Validate(PurchaseItem command)
@pedroreys
pedroreys / NullAction.cs
Created June 20, 2012 16:35
Null Action
public class NullAction
{
public static readonly Action DoNothing = () => { };
}
//This allows you to do (callback ?? NullAction.DoNothing)() instead of (callback ?? () => { })()
@pedroreys
pedroreys / chat_log
Created April 24, 2013 03:44
Amazon customer service rocks
You are now connected to Hernan from Amazon.com.
Me: I'm a Prime Member and Free Shipping is not available for an item that is shipped and sold by amazon.
Hernan:Hi there! I'm Hernan. I hope you're doing well! I'm really sorry about this issue, Pedro. I'd be glad to help you clarify this, What is the item you're referring to?
Me:Hey, I'm trying to buy this set of books: <url> and I have a Prime Membership but I don't know why it's not available for Free Shipping
Hernan:What is the address you're selecting?