Skip to content

Instantly share code, notes, and snippets.

View natelowry's full-sized avatar
:shipit:

Nate Lowry natelowry

:shipit:
View GitHub Profile
@natelowry
natelowry / ImageToGrayscale.swift
Last active August 2, 2021 01:22 — forked from vlondon/ImageToGrayscale.swift
Convert UIImage to grayscale
func convertImageToGrayScale(image: UIImage) -> UIImage {
// Create image rectangle with current image width/height
let imageRect = CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)
// Grayscale color space
let colorSpace = CGColorSpaceCreateDeviceGray()
// Create bitmap content with current image size and grayscale colorspace
let context = CGContext(data: nil, width: Int(image.size.width), height: Int(image.size.height), bitsPerComponent: 8, bytesPerRow: 0, space: colorSpace, bitmapInfo: CGImageAlphaInfo.none.rawValue)!
@natelowry
natelowry / <Custom>DbContext.cs
Last active November 11, 2019 15:48 — forked from werwolfby/<Custom>DbContext.cs
EF Core DateTime Utc kind
public class CustomDbContext : DbContext
{
// ...
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
// Replace default materializer source to custom, to convert DateTimes
options.ReplaceService<IEntityMaterializerSource, DateTimeKindEntityMaterializerSource>();
base.OnConfiguring(options);