Skip to content

Instantly share code, notes, and snippets.

View roman-wb's full-sized avatar

Roman D roman-wb

  • Russia, Rostov-on-Don
View GitHub Profile
@roman-wb
roman-wb / ViewController.swift
Last active May 5, 2020 16:54
iOS collection view paging with custom line spacing & insets
import UIKit
extension UIView {
func debugLayout(_ color: UIColor = .red) {
layer.borderColor = color.cgColor
layer.borderWidth = 1
}
}
final class CollectionViewCell: UICollectionViewCell {
@roman-wb
roman-wb / ViewController.swift
Last active May 5, 2020 16:15
iOS collection view paging with custom line spacing & insets
//
// ViewController.swift
// TestCollecton
//
// Created by roman on 04.05.2020.
// Copyright © 2020 ROMAN DOBYNDA. All rights reserved.
//
import UIKit
@roman-wb
roman-wb / nginx.conf
Last active January 28, 2020 10:26
Telegram bot api with proxy nginx host
//
https://<domain>/bot<token>/sendMessage?chat_id=<chat_or_channel>&parse_mode=html&disable_notification=true&text=Test
server {
...
server_name <domain>;
...
@roman-wb
roman-wb / nginx.conf
Last active January 14, 2020 17:24
Nginx + Image filter (resize/crop) + Proxy cache (optional) + Secure link (optional)
# nginx.conf
load_module /etc/nginx/modules/ngx_http_image_filter_module.so;
# host.conf
proxy_cache_path /tmp levels=1:2 keys_zone=thumbs:10m inactive=24h max_size=100M;
server {
listen 80;
root /usr/share/nginx/html;
@roman-wb
roman-wb / .zshrc
Created June 28, 2019 17:29
RVM RPROMPT
plugins=(git rvm)
alias rvm-prompt=$HOME/.rvm/bin/rvm-prompt
RPROMPT="%{$fg[blue]%}\$(~/.rvm/bin/rvm-prompt s i v g)"
@roman-wb
roman-wb / Sample.swift
Created March 27, 2019 10:30
Horizontal CollectionView with paging and center content inset (with shadow) (Variant 2: Cell with subview)
import UIKit
class CollectionCell: UICollectionViewCell {
static let reuseIdentifier = "CollectionCell"
var card: UIView!
var label: UILabel!
var isInstalled = false
@roman-wb
roman-wb / Sample.swift
Created March 27, 2019 09:04
Horizontal CollectionView with paging and center content inset (Variant 1: Multiple sections)
import UIKit
class CollectionCell: UICollectionViewCell {
static let reuseIdentifier = "CollectionCell"
static let inset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
var label: UILabel!
@roman-wb
roman-wb / app.conf
Created March 10, 2019 19:08
Nginx Rails App Sample
upstream puma_app_production {
server unix:/home/user/app/shared/tmp/sockets/puma.sock fail_timeout=0;
}
server {
listen 80;
listen 443 ssl spdy;
server_name app.com www.app.com;
ssl_stapling on;
@roman-wb
roman-wb / logrotate
Created March 10, 2019 18:59
Logrotate sample for user and app
/home/user/app/shared/log/*.log {
su root root
rotate 10
size=10M
compress
copytruncate
missingok
daily
notifempty
}
@roman-wb
roman-wb / MyUIButton.swift
Created March 1, 2019 08:11
iOS custom UIButton with roundedRect, shadow and highlight.
import UIKit
class MyUIButton: UIButton {
var highlightTitle = false
var highlightBackground = false
var highlightLayer = false
override open var isHighlighted: Bool {
didSet {