Skip to content

Instantly share code, notes, and snippets.

View FernandoVezzali's full-sized avatar

Fernando Ayrosa Vezzali FernandoVezzali

  • 04:13 (UTC -03:00)
View GitHub Profile
@FernandoVezzali
FernandoVezzali / format Dates
Created April 3, 2013 09:39
This example shows how to use custom formatting strings to format Dates
d - Short date
%d - Day number
M?d - Month and day number
dd - Day number, two digits
ddd - Abbreviated day name
dddd - Full day name
f - Full (long date, short time)
%f - Fractions of second, one digit
s^f - Seconds and fractions of second, one digit
ff - Fractions of second, two digits
public static byte[] Foo()
{
using (var memStream = new MemoryStream())
using (var streamWriter = new StreamWriter(memStream))
{
for (int i = 0; i < 6; i++)
streamWriter.WriteLine("TEST");
streamWriter.Flush();
return memStream.ToArray();
@FernandoVezzali
FernandoVezzali / ExtensionsAndDelegates
Last active December 14, 2015 12:59
Extensions with delegates
class Program
{
static void Main()
{
IEnumerable<string> names = new string[] { "Ireland", "Brazil", "Iceland" };
foreach (var name in names.Filter(predicate: StringThatStartWithI))
{
Console.WriteLine(name);
}
@FernandoVezzali
FernandoVezzali / Extension Methods
Created February 26, 2013 14:46
Extension Methods
class Program
{
static void Main()
{
string s = "Hello Extension Methods";
int i = s.WordCount();
}
}
public static class MyExtensions
@FernandoVezzali
FernandoVezzali / gist:5029517
Last active December 14, 2015 04:39
hosts file - how to make the internet not suck (as much)
# This hosts file is brought to you by Dan Pollock and can be found at
# http://someonewhocares.org/hosts/
# You are free to copy and distribute this file, as long the original
# URL is included. See below for acknowledgements.
# Please forward any additions, corrections or comments by email to
# hosts@someonewhocares.org
# Last updated: Feb 17th, 2013 at 13:37
@FernandoVezzali
FernandoVezzali / ModelState.cs
Last active October 3, 2015 15:58
Model State
public ActionResult Index(Model model)
{
if (ModelState.IsValid)
{
// do stuff here
}
else
{
foreach (ModelState modelState in ViewData.ModelState.Values)
{