This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// first install this NuGet package: Install-Package ftplib | |
static void Main(string[] args) | |
{ | |
using (var tConn = new FtpConnection("00.000.00.000", "UserName", "Password")) | |
{ | |
tConn.Open(); | |
tConn.Login(); | |
if (tConn.DirectoryExists("/www")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#@ template debug="false" hostspecific="true" language="C#" #> | |
<#@ output extension=".cs" #> | |
<#@ assembly name="System" #> | |
<#@ assembly name="System.Xml" #> | |
<#@ assembly name="System.Xml.Linq" #> | |
<#@ import namespace="System.IO" #> | |
<#@ import namespace="System.Xml.Linq" #> | |
<#@ import namespace="System.Collections.Generic" #> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult Index(Model model) | |
{ | |
if (ModelState.IsValid) | |
{ | |
// do stuff here | |
} | |
else | |
{ | |
foreach (ModelState modelState in ViewData.ModelState.Values) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main() | |
{ | |
string s = "Hello Extension Methods"; | |
int i = s.WordCount(); | |
} | |
} | |
public static class MyExtensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main() | |
{ | |
IEnumerable<string> names = new string[] { "Ireland", "Brazil", "Iceland" }; | |
foreach (var name in names.Filter(predicate: StringThatStartWithI)) | |
{ | |
Console.WriteLine(name); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String Sha1(String plainText) | |
{ | |
Byte[] text, hashBytes; | |
using (SHA1Managed sha1 = new SHA1Managed()) | |
{ | |
text = Encoding.Unicode.GetBytes(plainText); | |
hashBytes = sha1.ComputeHash(text); | |
} | |
return Convert.ToBase64String(hashBytes); | |
} |
OlderNewer