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
static void Main(string[] args) | |
{ | |
Console.WriteLine("started ClockCounter example"); | |
var clockCounter = new ClockCounter(22, 59, 59); | |
Console.WriteLine(clockCounter.Time); | |
clockCounter.IncreaseSecond(); | |
Console.WriteLine(clockCounter.Time); | |
Console.WriteLine("now let's try again"); | |
clockCounter = new ClockCounter(23, 59, 59); |
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.Threading; | |
namespace Pepperoni.Lib | |
{ | |
public class SafeValueSeldomWrites<T> | |
{ | |
private T innerValue; | |
private readonly ReaderWriterLockSlim locker = new ReaderWriterLockSlim(); | |
public SafeValueSeldomWrites() |
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
void Application_Start(object sender, EventArgs e) | |
{ | |
MyGlobals.Wish.Value = 1234; | |
MyGlobals.Wall.Value = "numb"; | |
} |
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.Threading; | |
using System.Threading.Tasks; | |
namespace Bronze.Lib | |
{ | |
public class ParallelWithInterlock | |
{ | |
public int Sum(int[,] matrix) | |
{ | |
var outerUpperBound = matrix.GetLength(0); |
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
private static char[] digits = new[] | |
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; | |
public static char ToChar(int digit) | |
{ | |
return digits[digit]; | |
} |
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 class CustomersFetcher | |
{ | |
public IEnumerable<CustomerDetails> GetSleepingCustomers() | |
{ | |
List<CustomerDetails> result = new List<CustomerDetails>(); | |
var connectionString = "..."; | |
using (var connection = new OleDbConnection(connectionString)) | |
{ | |
connection.Open(); | |
var command = new OleDbCommand("select * from Customers where LastPurchasedAt < ?", connection); |
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
namespace Canberra.InterfacesDemo.Lib | |
{ | |
public class CustomersReminder | |
{ | |
public void Remind(ICustomersFetcher customersFetcher, IEmailSender emailSender) | |
{ | |
foreach (var customer in customersFetcher.GetSleepingCustomers()) | |
{ | |
emailSender.SendRemindMessage(customer.FirstName, customer.LastName, customer.EmailAddress); | |
} |
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
Pattern phoneNumber = Pattern.With | |
.AtBeginning.Choice.Either( | |
Pattern.With.Literal("02"), | |
Pattern.With.Literal("03"), | |
Pattern.With.Literal("04"), | |
Pattern.With.Literal("08"), | |
Pattern.With.Literal("09"), | |
Pattern.With.Literal("072"), | |
Pattern.With.Literal("073"), | |
Pattern.With.Literal("074"), |
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
const http = require('http'); | |
const incomingRequests = []; | |
const requestListener = function (req, res) { | |
let data = ''; | |
req.on('data', chunk => { | |
data += chunk; | |
}); | |
req.on('end', () => { |
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 LinkedQueue { | |
constructor() { | |
this._newest = null; | |
this._oldest = null; | |
this._size = 0; | |
} | |
enqueue(item) { | |
if (this._size === 0) { | |
this._newest = {value: item, next: null}; |
NewerOlder