Skip to content

Instantly share code, notes, and snippets.

View chsami's full-sized avatar

chsami chsami

View GitHub Profile
@chsami
chsami / ExifDirectoryBase.cs
Last active October 3, 2020 09:48
There's a lot more metadata that you can pull from the picture
public abstract class ExifDirectoryBase : Directory
{
public const int TagInteropIndex = 1;
public const int TagImageNumber = 37393;
public const int TagSecurityClassification = 37394;
public const int TagImageHistory = 37395;
public const int TagSubjectLocationTiffEp = 37396;
public const int TagExposureIndexTiffEp = 37397;
public const int TagStandardIdTiffEp = 37398;
//
[HttpPost]
public ActionResult UploadFile()
{
var Files = Request.Form.Files; // Load File collection into HttpFileCollection variable.
//I ONLY TAKE THE FIRST FILE FOR EXAMPLE PURPOSES
var imageStream = Files[0].OpenReadStream();
var directories = ImageMetadataReader.ReadMetadata(imageStream);
var exifSubDirectory = directories.OfType<ExifSubIfdDirectory>().FirstOrDefault();
var originalDate = exifSubDirectory?.GetDescription(ExifDirectoryBase.TagDateTimeOriginal);
return Ok(originalDate)
builder.Register(x =>
{
var optionsBuilder = new DbContextOptionsBuilder<YOURDBCONTEXTCLASS>();
optionsBuilder.UseSqlServer(configuration.GetConnectionString("YOURCONNECTIONSTRING"));
return new YOURDBCONTEXTCLASS(optionsBuilder.Options);
}).InstancePerLifetimeScope()
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (/Edge/.test(navigator.userAgent) || msie > -1 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
applyPolyfills().then(() => {
defineCustomElements();
});
}
[TestClass]
public class MyServiceTests : BaseTest
{
[TestMethod]
public void TestMethod()
{
var result = _myService.myMethod()
Assert.IsNotNull(result);
}
}
[TestClass]
public abstract class BaseTest
{
public static ServiceProvider serviceProvider;
public IMyService _myService;
[AssemblyInitialize]
public static void SetUp(TestContext context)
{
IServiceCollection services = new ServiceCollection();
services.AddTransient<IMyService, MyService>();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Mediris Recipe API", Version = "v1" });
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description = "JWT Authorization header using the Bearer scheme. \r\n\r\n Enter 'Bearer' [space] and then your token in the text input below.\r\n\r\nExample: \"Bearer 12345abcdef\"",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey,
Scheme = "Bearer"
public class JsonStatusCodeMiddleWare
{
private readonly RequestDelegate _next;
public JsonStatusCodeMiddleWare(RequestDelegate next)
{
_next = next;
}
public async Task Invoke(HttpContext context)
{
if (context.Response.StatusCode == (int)HttpStatusCode.OK)
builder.UseMvc(routes =>
{
routes.MapRoute("apiDefault", "api/{*url}", new { controller = "Home", action = "ApiNotFound" });
routes.MapRoute("spa-routes", "{*anything}", new { controller = "Home", action = "Index" });
});
const webpack = require("webpack");
module.exports = {
outputDir: '../wwwroot/dist',
publicPath: "/dist/",
filenameHashing: false,
configureWebpack: {
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',