Skip to content

Instantly share code, notes, and snippets.

View vgorloff's full-sized avatar

Vlad Gorlov vgorloff

View GitHub Profile
@vgorloff
vgorloff / js.concurrently.as.macOS.service.md
Last active November 17, 2022 08:58
Setting up concurrently as a macOS service to server dev and prod services in local environment.

Prerequesites

  • Your NodeJS app (express, fastify, etc.) is placed at /opt/mca/www/mca-backend/app path.

Setup

  1. Install concurrently: npm install -g concurrently

  2. Create a file ~/Library/LaunchAgents/mca.backend.plist

@vgorloff
vgorloff / aws.DynamoDB.as.macOS.service.md
Created November 14, 2022 19:03
Setting up AWS DynamoDB Local as macOS autostart service.
@vgorloff
vgorloff / aws.CloudFront.Functions.301Redirect.js
Last active August 29, 2021 14:11
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.
// 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 July 14, 2021 22:29
so.SwiftDeflate+NodeJSInflateRaw
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 September 14, 2022 03:39
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!

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