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
// Usage ValidateEmpty(x => x.Id), | |
public static ValidationResult ValidateEmpty<T, TProp>(this T o, Expression<Func<T,TProp>> propertySelector) | |
{ | |
MemberExpression body = (MemberExpression)propertySelector.Body; | |
var propInfo = body.Member as PropertyInfo; | |
var value = propInfo?.GetValue(o, null); | |
return value switch | |
{ |
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 string GetMimeTypeForFileExtension(string filePath) | |
{ | |
const string defaultContentType = "application/octet-stream"; | |
if (!new FileExtensionContentTypeProvider().TryGetContentType(filePath, out string contentType)) | |
{ | |
contentType = defaultContentType; | |
} | |
return contentType; | |
} |
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 glob = require('glob'); | |
const path = require('path'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const { CleanWebpackPlugin } = require('clean-webpack-plugin'); | |
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | |
const htmlPlugins = generateHtmlPlugins(); | |
function generateHtmlPlugins() { | |
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
<template> | |
<require from="styles.css" /> | |
<require from="tree-view" /> | |
<tree-view /> | |
</template> |
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 bool ValidateCertificateChain(X509Certificate certificate) | |
{ | |
var chain = new X509Chain(); | |
var root = new X509Certificate2("ca.cer"); // Root CA of Self signed cert | |
var cert = new X509Certificate2(certificate); | |
chain.Reset(); // Not sure is this is needed | |
chain.ChainPolicy.VerificationFlags = X509VerificationFlags.IgnoreRootRevocationUnknown; | |
chain.ChainPolicy.RevocationMode = X509RevocationMode.Online; // Check with our own CA if the cert has been revoked | |
chain.ChainPolicy.ExtraStore.Add(root); // Self signed Root CA |
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
/* | |
This code allows you to export BIP39 12 words phrase and use it with Ethereum/Loom | |
To check Popular derivative paths look here https://www.myetherwallet.com/#view-wallet-info | |
Or here is quick cheatsheet https://gyazo.com/a4199116750b57a02917eb255d4c033e | |
Dependency on very nice library https://github.com/MetacoSA/NBitcoin - clone and build it | |
*/ | |
using NBitcoin; |
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.IO; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
using Microsoft.EntityFrameworkCore; | |
using Microsoft.EntityFrameworkCore.Metadata; | |
using Microsoft.Extensions.Configuration; | |
namespace DalSoft.Data |
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 Startup | |
{ | |
public void Configuration(IAppBuilder app) | |
{ | |
var config = new HttpConfiguration(); | |
var jsonSerializerSettings = config.Formatters.JsonFormatter.SerializerSettings; | |
//Remove unix epoch date handling, in favor of ISO | |
jsonSerializerSettings.Converters.Add(new IsoDateTimeConverter { DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fff" }); |
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
// Method /createMessage https://www.pushwoosh.com/programming-push-notification/pushwoosh-push-notification-remote-api/#PushserviceAPI-Method-messages-create | |
dynamic pushwoosh = new RestClient("https://cp.pushwoosh.com/json/1.3"); | |
var pushWooshResponse = await pushwoosh.CreateMessage.Post(new | |
{ | |
request = new | |
{ | |
application = "APPLICATION_CODE", | |
auth = "API_ACCESS_TOKEN", | |
notifications = new[] { new { | |
send_date = "now", // YYYY-MM-DD HH:mm OR 'now' |
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
dynamic client = new RestClient("http://jsonplaceholder.typicode.com"); | |
var post = new { title = "foo", body = "bar", userId = 10 }; | |
var result = await client.Posts(1).Put(post); | |
Assert.That(result.title, Is.EqualTo(post.title)); | |
Assert.That(result.body, Is.EqualTo(post.body)); | |
Assert.That(result.userId, Is.EqualTo(post.userId)); | |
Assert.That(result.HttpResponseMessage.StatusCode, Is.EqualTo(HttpStatusCode.OK)); |
NewerOlder