Skip to content

Instantly share code, notes, and snippets.

View RomanEsin's full-sized avatar
🎯
Focusing

Roman Esin RomanEsin

🎯
Focusing
View GitHub Profile
@konnnn
konnnn / UILabel+Padding.swift
Last active February 22, 2024 13:24
Swift 4: Adding space/padding to a UILabel Programmatically and Storyboard
/*
If you use Storyboard, don't forget to set UIlabel to PaddingLabel
*/
import UIKit
class PaddingLabel: UILabel {
var topInset: CGFloat
var bottomInset: CGFloat
@HugoPoi
HugoPoi / Resize virtual machine partition.md
Last active June 22, 2024 19:14
How to resize virtual machine partition after extend the disk

Resize a VM system disk

Introduction

  • You have a VM with small disk
  • You have GPT partition table
  • You NOT USE LVM (you should)
  • You need to extend a partition on the main drive
  • You use Debian 8.x aka Jessie

Extend the disk

@andrey-str
andrey-str / replaceColor.swift
Created April 22, 2016 00:05
Replace color in UIImage with give tolerance value
// color - source color, which is must be replaced
// withColor - target color
// tolerance - value in range from 0 to 1
func replaceColor(color:SKColor, withColor:SKColor, image:UIImage, tolerance:CGFloat) -> UIImage{
// This function expects to get source color(color which is supposed to be replaced)
// and target color in RGBA color space, hence we expect to get 4 color components: r, g, b, a
assert(CGColorGetNumberOfComponents(color.CGColor) == 4 && CGColorGetNumberOfComponents(withColor.CGColor) == 4,
"Must be RGBA colorspace")
- (void)rotatePath:(UIBezierPath *)path degree:(CGFloat)degree {
CGRect bounds = CGPathGetBoundingBox(path.CGPath);
CGPoint center = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds));
CGFloat radians = (degree / 180.0f * M_PI);
CGAffineTransform transform = CGAffineTransformIdentity;
transform = CGAffineTransformTranslate(transform, center.x, center.y);
transform = CGAffineTransformRotate(transform, radians);
transform = CGAffineTransformTranslate(transform, -center.x, -center.y);
[path applyTransform:transform];