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
[Test] | |
public void Create_farrowing_for_gestating_sow() | |
{ | |
byte parity = 1; | |
var farrowing = new Farrowing | |
{ | |
Id = Guid.NewGuid(), | |
Date = new DateTime(2011, 3, 22), | |
Farm = new PigX.Farms.Farm(), |
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
// the business logic for the creation of a new litter | |
Find the pig with the given id to make sure it's on the user's farm, female and pregnant. If not, return error. | |
Find the pig's most recent mating, which should be in a gestating state. If not, return error. | |
If it's been less than 100 days or more than 130 days since the mating, return error. | |
Update the mating to a successful state. |
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.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Data.Entity; | |
namespace ConsoleApplication5 | |
{ | |
public interface IFoo | |
{ |
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
// if this is not a mention or I follow you, this won't be spam | |
if (IsMention && !_host.Friends.Any(u => u.ScreenName == User.ScreenName)) | |
{ | |
SpamProbability += 0.1; | |
// if they haven't tweeted much, good chance | |
if (item.User.StatusCount < 100) SpamProbability += 0.2; | |
// if they're a recent user, also a sign | |
if (item.User.CreatedAt > DateTime.Today.Subtract(TimeSpan.FromDays(7))) SpamProbability += 0.2; |
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
<Window x:Class="WpfApplication1.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="MainWindow" Height="350" Width="525"> | |
<Grid> | |
<ListBox x:Name="foo"> | |
<ListBox.Resources> | |
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Orange" /> | |
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" /> |
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
// in MainWindow.xaml: | |
<Grid> | |
<ListBox ItemsSource="{Binding Items}" /> | |
</Grid> | |
// in MainWindow.xaml.cs | |
public MainWindow() | |
{ |
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
// before | |
public class Foo : IComparable<Foo> | |
{ | |
int Id { get; set; } | |
public int CompareTo(Foo other) | |
{ | |
if (other == null) return -1; | |
return this.Id.CompareTo(other.Id); |
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 partial class MainWindow : Window | |
{ | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
this.Loaded += MainWindow_Loaded; | |
} | |
async void MainWindow_Loaded(object sender, RoutedEventArgs e) |
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) | |
{ | |
var pattern = new Regex(@"(?:((c|sh|w)ould|might)\s+)of", RegexOptions.IgnoreCase); | |
var client = new TwitterAnonymousClient(); | |
long? last = null; | |
while (true) | |
{ | |
client.SearchAsync("\"should of\" OR \"would of\" OR \"could of\" OR \"might of\" -RT", since: last).ContinueWith(t => | |
{ |
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 async Task<WebAuthenticationResult> AuthenticateUser(string twitterClientID, string twitterCallbackUrl | |
{ | |
if (string.IsNullOrWhiteSpace(twitterClientID)) | |
throw new ArgumentException("TwitterClientID must be specified", twitterClientID); | |
if (string.IsNullOrWhiteSpace(twitterCallbackUrl)) | |
throw new ArgumentException("TwitterCallbackUrl must be specified", twitterCallbackUrl); | |
if (string.IsNullOrWhiteSpace(twitterClientSecret)) | |
throw new ArgumentException("TwitterClientSecret must be specified", twitterClientSecret); | |
var sinceEpoch = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()); |