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; | |
public class Test | |
{ | |
public static void Main() | |
{ | |
var amount = 39.105; | |
Console.WriteLine(Math.Round(amount, 2, MidpointRounding.AwayFromZero)); // 39.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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.3.0/knockout-min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="currentPerson" > |
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
ko.numericObservable = function(initialValue) { | |
var _actual = ko.observable(initialValue); | |
var result = ko.computed({ | |
read: function() { | |
return _actual(); | |
}, | |
write: function(newValue) { | |
var parsedValue = parseFloat(newValue); | |
_actual(isNaN(parsedValue) ? newValue : parsedValue); |
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
git diff upstream/develop -- **/Partial/Path/To/File.cs |
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 async Task<List<Notification>> Get() | |
{ | |
var uriBuilder = GetCouchUrl(); | |
using (var client = new MyCouchClient(uriBuilder.Build())) | |
{ | |
var notifications = await client.Views.QueryAsync<Notification>(new QueryViewRequest("notifications-doc", "all-notifications")); | |
return notifications.Rows.Select(r => r.Value).ToList(); | |
} | |
} |
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
function (doc) { | |
emit(doc._id, doc); | |
} |
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 async Task<List<Notification>> Get() | |
{ | |
var uriBuilder = GetCouchUrl(); | |
using (var client = new MyCouchClient(uriBuilder.Build())) | |
{ | |
var notifications = await client.Views.QueryAsync<Notification>(new QueryViewRequest("notifications-doc", "all-notifications")); | |
return notifications.Rows.Select(r => r.Value).ToList(); | |
} | |
} |
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 MyCouchUriBuilder GetCouchUrl() | |
{ | |
// assuming you're using cloudant | |
return new MyCouchUriBuilder("https://[username].cloudant.com/") | |
.SetDbName("notifications") | |
.SetBasicCredentials("[usename]", "[password]"); | |
} |
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 CouchWebApi.Models | |
{ | |
public class Notification | |
{ | |
public string Alert { get; set; } | |
public int Count { get; set; } | |
} | |
} |
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 async Task<Notification> Post(Notification notification) | |
{ | |
var uriBuilder = GetCouchUrl(); | |
using (var client = new MyCouchClient(uriBuilder.Build())) | |
{ | |
var response = await client.Entities.PostAsync(notification); | |
return response.Content; | |
} |