Skip to content

Instantly share code, notes, and snippets.

Avatar

Vlad Gorlov vgorloff

View GitHub Profile
@vgorloff
vgorloff / aws.CloudFront.Functions.301Redirect.js
Last active Aug 29, 2021
Example how to redirect client to new location with AWS CloudFront Function. E.g. when you deleted NextJS page, but still want to redirect clients (Native app or Search index) to new location.
View aws.CloudFront.Functions.301Redirect.js
// NOTE: Choose "viewer request" for event trigger when you associate this function with CloudFront distribution.
/** See also:
- JS Specs: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-javascript-runtime-features.html
- The request Specs: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-event-structure.html
*/
function makeRedirectResponse(location) {
var response = {
statusCode: 301,
@vgorloff
vgorloff / Compress.swift
Created Jul 14, 2021
so.SwiftDeflate+NodeJSInflateRaw
View Compress.swift
let data = "HelloZip!".data(using: .utf8)!
let compressedData = (data as NSData).compressed(using: .zlib) as Data
let compressedDataAsBase64EncodedString = compressedData.base64EncodedString()
print(compressedDataAsBase64EncodedString)
// Prints: 80jNycmPyixQBAA=
@vgorloff
vgorloff / so.NSATSTypesetter.WithWrappedLines.md
Last active Jul 1, 2021
Deleted SO question: NSTextView: Visually indent wrapped lines (aka IDE editor) without modifying text storage attributes.
View so.NSATSTypesetter.WithWrappedLines.md

Say I have NSTextView and custom NSRulerView:

[![enter image description here][1]][1]

Now I want every wrapped line to indent say on 3 spaces (like on image below).

[![enter image description here][2]][2]

How to achieve it without modifying text storage attributes (i.e. Paragraph style)? Should I use NSLayoutManager? Thanks!

View so.CoreData.observeEntityChangesViaNotifications.swift
//: [Previous](@previous)
import PlaygroundSupport
import Cocoa
import CoreData
PlaygroundPage.current.needsIndefiniteExecution = true
extension NSManagedObject {