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 C : IDisposable | |
{ | |
private bool _disposed; | |
protected virtual void Dispose(bool disposing) | |
{ | |
if (_disposed || !disposing) return; | |
//dispose objects here. | |
_disposed = true; | |
} |
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
//orignal post - http://joelabrahamsson.com/twitter-style-paging-with-aspnet-mvc-and-jquery/ | |
public static class PagerHelper | |
{ | |
public static MvcHtmlString BootstrapPager(this HtmlHelper helper, int currentPageIndex, int totalItems, | |
int pageSize = 10, int numberOfLinks = 5) | |
{ | |
if (totalItems <= 0) return MvcHtmlString.Empty; | |
var totalPages = (int)Math.Ceiling(totalItems / (double)pageSize); |
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 void Main() | |
{ | |
var account = new StripeAccount | |
{ | |
Email = "abc@gmail.com", | |
Managed = false, | |
StripeExternalAccount = new StripeExternalAccount | |
{ | |
AccountNumber = "000123456789", | |
RoutingNumber = "110000000", |
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 T Deserialize<T>(Stream stream) | |
{ | |
if (stream == null || !stream.CanRead) return default(T); | |
using (var reader = new StreamReader(stream)) | |
{ | |
using (var json = new Newtonsoft.Json.JsonTextReader(reader)) | |
{ | |
return new Newtonsoft.Json.JsonSerializer().Deserialize<T>(json); | |
} |
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 WebApiConfig | |
{ | |
public static void Register(HttpConfiguration config) | |
{ | |
// Json settings | |
config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; | |
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); | |
config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented; | |
JsonConvert.DefaultSettings = () => new JsonSerializerSettings() | |
{ |
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
//code snippet to charge transaction fee from customer side. | |
//https://support.stripe.com/questions/can-i-charge-my-stripe-fees-to-my-customers | |
static void Main() | |
{ | |
//Total fee for platform and stripe would be 5% + .30 Cents | |
const decimal fixedFee = .30M; //.30 cents | |
const decimal fixedFeePercentage = 5M; // 5% = Percentage fees for Stripe and Platform (ex : stripe fee 2.9 + 2.1 platform fee = 5%) |
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
= "update table set name = '" & B1 & "' where namefk = '" & A1 & "'" |
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
https://blogs.msdn.microsoft.com/benjaminperkins/2016/06/16/lab-19-debugging-a-high-cpu-hang-w3wp-process-using-windbg/ | |
https://stackify.com/using-windbg-to-analyze-net-crash-dumps-async-crash/ | |
.sympath srv*C:\Projects\Workshop\Sym*http://msdl.microsoft.com/download/symbols;C:\Projects\publish\ProcDumpTest\bin (IIS path) | |
.load C:\Windows\Microsoft.NET\Framework64\v4.0.30319\sos.dll | |
!threadpool | |
!runaway – The once consuming the most amount of time are of most interest, but not always the reason for the problem |
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
//copied from here | |
//https://stackoverflow.com/questions/29137708/how-to-delete-all-the-documents-in-documentdb-through-c-sharp-code | |
//https://stackoverflow.com/questions/43587572/how-to-clear-the-collection-in-documentdb-through-query-explorer | |
/** | |
* A DocumentDB stored procedure that bulk deletes documents for a given query.<br/> | |
* Note: You may need to execute this sproc multiple times (depending whether the sproc is able to delete every document within the execution timeout limit). | |
* | |
* @function | |
* @param {string} query - A query that provides the documents to be deleted (e.g. "SELECT * FROM c WHERE c.founded_year = 2008") |