Skip to content

Instantly share code, notes, and snippets.


Vlad Gorlov vgorloff

View GitHub Profile
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:
- The request Specs:
function makeRedirectResponse(location) {
var response = {
statusCode: 301,
vgorloff / Compress.swift
Created Jul 14, 2021
View Compress.swift
let data = "HelloZip!".data(using: .utf8)!
let compressedData = (data as NSData).compressed(using: .zlib) as Data
let compressedDataAsBase64EncodedString = compressedData.base64EncodedString()
// Prints: 80jNycmPyixQBAA=
vgorloff /
Last active Jul 1, 2021
Deleted SO question: NSTextView: Visually indent wrapped lines (aka IDE editor) without modifying text storage attributes.

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 {