This file contains hidden or 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
[HttpPost] | |
public HttpResponseMessage CreateCustomer(string name, string billingInfo) | |
{ | |
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo); | |
Result<CustomerName> customerNameResult = CustomerName.Create(name); | |
return Result.Combine(billingInfoResult, customerNameResult) | |
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value)) | |
.OnSuccess(() => new Customer(customerNameResult.Value)) | |
.OnSuccess( |
This file contains hidden or 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
# To enable ANSI sequences in a PowerShell console run the following commands. | |
# After that you can use wttr.in in you PowerShell just lake that: | |
# (curl http://wttr.in/ -UserAgent "curl" ).Content | |
# | |
# More on it: | |
# http://stknohg.hatenablog.jp/entry/2016/02/22/195644 (jp) | |
# | |
Add-Type -MemberDefinition @" | |
[DllImport("kernel32.dll", SetLastError=true)] |
This file contains hidden or 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
#!/bin/bash | |
# Usage: slackpost <token> <channel> <message> | |
# Enter the name of your slack host here - the thing that appears in your URL: | |
# https://slackhost.slack.com/ | |
slackhost=PUT_YOUR_HOST_HERE | |
token=$1 |
This file contains hidden or 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
param( | |
[Parameter(Mandatory=$true)][string]$TaskPath, | |
[Parameter(Mandatory=$true)][string]$TfsUrl, | |
[PSCredential]$Credential = (Get-Credential), | |
[switch]$Overwrite = $false | |
) | |
# Load task definition from the JSON file | |
$taskDefinition = (Get-Content $taskPath\task.json) -join "`n" | ConvertFrom-Json | |
$taskFolder = Get-Item $TaskPath |
This file contains hidden or 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
dynamic samplefootballLegendObject = new ExpandoObject(); | |
samplefootballLegendObject.FirstName = "Joro"; | |
samplefootballLegendObject.LastName = "Beckham-a"; | |
samplefootballLegendObject.Team = "Loko Mezdra"; | |
samplefootballLegendObject.Salary = 380.5m; | |
samplefootballLegendObject.AsString = new Action( | |
() => | |
Console.WriteLine("{0} {1} {2} {3}", | |
samplefootballLegendObject.FirstName, |
This file contains hidden or 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
#r "../packages/Neo4jClient.1.1.0.28/lib/net45/Neo4jClient.dll" | |
#r "../packages/Newtonsoft.Json.6.0.4/lib/net45/Newtonsoft.Json.dll" | |
open System | |
open System.Collections.Generic | |
open System.Linq | |
open Microsoft.FSharp.Quotations | |
open Microsoft.FSharp.Linq.RuntimeHelpers | |
open System.Linq.Expressions |
This file contains hidden or 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
#!/bin/bash | |
[ "$#" -eq 1 ] || { echo >&2 "Requires single text file (with youtube links on each line) name as argument."; exit 1; } | |
command -v youtube-dl >/dev/null 2>&1 || { echo >&2 "Install youtube-dl first."; exit 1; } | |
if [ ! -d "downloads" ]; then | |
mkdir downloads | |
fi |
This file contains hidden or 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 you want to give owner access to the whole server to a particular user account this is how | |
exec sp_addrolemember 'db_owner', 'NT AUTHORITY\NETWORK SERVICE'; | |
GO | |
# If you want to idempotently ensure a particular database with name DatabaseName exists this is how | |
IF NOT db_id('DatabaseName') IS NOT NULL BEGIN | |
PRINT 'Creating database...' | |
CREATE DATABASE [DatabaseName] | |
PRINT 'Created database.' |
This file contains hidden or 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
# Run this in an elevated PowerShell prompt | |
<# This script worked on a fresh Windows Server 2012 VM in Azure and the following were the latest versions of each package at the time: | |
* Chocolatey 0.9.8.27 | |
* java.jdk 7.0.60.1 | |
* apache.ant 1.8.4 | |
* android-sdk 22.6.2 | |
* cordova 3.5.0-0.2.6 | |
* nodejs.install 0.10.29 | |
#> | |
# Note: there is one bit that requires user input (accepting the Android SDK license terms) |
This file contains hidden or 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.Text.RegularExpressions; | |
using FluentValidation; | |
using WpfFluentValidationExample.ViewModels; | |
namespace WpfFluentValidationExample.Lib | |
{ | |
public class UserValidator : AbstractValidator<UserViewModel> | |
{ | |
public UserValidator() | |
{ |