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 class SelectListExtensionMethods | |
{ | |
//// simple Enum for demonstration in the examples | |
//enum Colors { | |
// Red = 1, | |
// Green = 2, | |
// Blue = 3 | |
//} | |
//// Simple Class for demonstration in the examples |
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
using Microsoft.AspNetCore.Identity; | |
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; | |
using System.Linq; | |
namespace My.App.Data | |
{ | |
public class DbInitializer : IDbInitializer | |
{ | |
private readonly ApplicationDbContext _context; | |
private readonly UserManager<ApplicationUser> _userManager; |
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
$content = Get-Content 'C:\img_urls.csv' | |
$outpath = 'C:\OutFolder' | |
foreach ($line in $content) | |
{ | |
wget $line -outfile $outpath$line.Substring($line.LastIndexOf("/") + 1) | |
} |
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
# ----------------------------------------------------------------- | |
# .gitignore for WordPress | |
# Bare Minimum Git | |
# http://ironco.de/bare-minimum-git/ | |
# ver 20150227 | |
# | |
# This file is tailored for a WordPress project | |
# using the default directory structure | |
# | |
# This file specifies intentionally untracked files to ignore |
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(string sortOrder, string q, int page = 1, int pageSize = 25) | |
{ | |
ViewBag.searchQuery = String.IsNullOrEmpty(q) ? "" : q; | |
page = page > 0 ? page : 1; | |
pageSize = pageSize > 0 ? pageSize : 25; | |
ViewBag.NameSortParam = sortOrder == "name" ? "name_desc" : "name"; | |
ViewBag.AddressSortParam = sortOrder == "address" ? "address_desc" : "address"; | |
ViewBag.DateSortParam = sortOrder == "date" ? "date_desc" : "date"; |
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
@model PagedList.IPagedList<My.App.Model> | |
@using PagedList.Mvc; | |
@{ | |
ViewBag.Title = "Title"; | |
string currentFilter = ViewBag.CurrentFilter; | |
string currentSort = ViewBag.CurrentSort; | |
if (string.IsNullOrEmpty(currentSort)) | |
{ | |
currentSort = "date_desc"; |
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
using System.Collections.Specialized; | |
using System.Web; | |
using System.Web.Mvc; | |
using System.Web.Routing; | |
namespace My.App | |
{ | |
public static class Extensions | |
{ | |
/// <summary> |
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
using System; | |
using System.Data.Entity; | |
using System.Linq; | |
namespace My.Data.Annotations | |
{ | |
/// <summary> | |
/// The Precision class allows us to decorate our Entity Models with a Precision attribute | |
/// to specify decimal precision values for the database column | |
/// </summary> |
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
string plainText = "This will be encrypted."; | |
RijndaelManaged aesAlg = new RijndaelManaged(); | |
aesAlg.Key = new byte[32] { 118, 123, 23, 17, 161, 152, 35, 68, 126, 213, 16, 115, 68, 217, 58, 108, 56, 218, 5, 78, 28, 128, 113, 208, 61, 56, 10, 87, 187, 162, 233, 38 }; | |
aesAlg.IV = new byte[16] { 33, 241, 14, 16, 103, 18, 14, 248, 4, 54, 18, 5, 60, 76, 16, 191}; | |
ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV); | |
msEncrypt = new MemoryStream(); | |
using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write)) { | |
using (StreamWriter swEncrypt = new StreamWriter(csEncrypt)) { | |
swEncrypt.Write(plainText); |
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 List<Comment> toThreadedComments(List<Comment> comments){ | |
//comments should be sorted by date first | |
//The resulting array of threaded comments | |
List<Comment> threaded = new ArrayList<Comment>(); | |
//An array used to hold processed comments which should be removed at the end of the cycle | |
List<Comment> removeComments = new ArrayList<Comment>(); |
NewerOlder