Skip to content

Instantly share code, notes, and snippets.

@sergeytimoshin
sergeytimoshin / letsencrypt_2020.md
Created April 29, 2021 07:00 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

import LinkPresentation
import Combine
extension LPMetadataProvider {
func startFetchingMetadataPublisher(for url: URL) -> AnyPublisher<LPLinkMetadata?, Error> {
Future<LPLinkMetadata?, Error> { completion in
self.startFetchingMetadata(for: url) { meta, error in
guard let error = error else {
return completion(.success(meta))
}
@sergeytimoshin
sergeytimoshin / build_spine_macos.sh
Created December 16, 2020 13:49 — forked from Wizermil/build_spine_macos.sh
Script to compile spine runtime static library for macOS
#!/bin/bash
SPINE_VERSION="3.7.83"
ARCHS=("x86_64")
SDK_VERSION="10.14"
ROOT_DIR=$(pwd)
WORKER=$(getconf _NPROCESSORS_ONLN)
BUILD_DIR="build/macos/spine"
LOG_FILE="$ROOT_DIR/$BUILD_DIR/build.log"
@sergeytimoshin
sergeytimoshin / libdispatch-efficiency-tips.md
Created November 23, 2020 20:14 — forked from tclementdev/libdispatch-efficiency-tips.md
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@sergeytimoshin
sergeytimoshin / min-char-rnn.py
Created June 29, 2018 07:29 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@sergeytimoshin
sergeytimoshin / atomic.m
Created October 31, 2012 22:05 — forked from markd2/atomic.m
Exploring the 'atomic' keyword in properties.
#import <Foundation/Foundation.h>
// clang -g -Wall -framework Foundation -o atomic atomic.m
// gcc -g -Wall -framework Foundation -o atomic atomic.m
@interface Blah : NSObject
@property (assign, NS_NONATOMIC_IOSONLY) NSInteger frobnozzle;
@property (assign, ) NSInteger commaAtEnd;
// @property (, assign) NSInteger commaAtBeginning; // Syntax error
@property (atomic, assign) NSInteger blah; // complains in gcc
@sergeytimoshin
sergeytimoshin / clean_assets.rb
Created October 19, 2012 21:11 — forked from soffes/clean_assets.rb
Rake task to clean unused images in your iOS project
desc 'Remove unused images'
task :clean_assets do
require 'set'
all = Set.new
used = Set.new
unused = Set.new
# White list
used.merge %w{Icon Icon-29 Icon-50 Icon-58 Icon-72 Icon-114}