Skip to content

Instantly share code, notes, and snippets.

Avatar
🛠️

Aleksei Cherepanov ftp27

🛠️
View GitHub Profile
@ftp27
ftp27 / playground.swift
Created Jun 27, 2019
AutoLayout Hugging Priority and Compression Resistance Priority tests
View playground.swift
import PlaygroundSupport
import UIKit
func makeLabels(left: String, right: String) -> (UIView, UILabel, UILabel) {
let leftLb: UILabel = {
let label = UILabel(frame: .zero)
label.textAlignment = .left
label.backgroundColor = .blue
label.text = left
return label
View YoutubeCommentStats.swift
import Foundation
func getData(_ urlString: String) -> Data? {
guard let url = URL(string: urlString) else { return nil }
return try? Data(contentsOf: url)
}
struct Result {
var comments: Int
@ftp27
ftp27 / gist:8782988
Created Feb 3, 2014
RFID_RC522.ino
View gist:8782988
/*
* Name:RFID.pde
* Create:www.electrodragon.com
* Create date:2011.09.19
* Function:Mifare1 searching card →prevent conflict→ select card →read write pins
*/
// the sensor communicates using SPI, so include the library:
#include <SPI.h>
#define uchar unsigned char
@ftp27
ftp27 / SelfsizingTableView.swift
Created Aug 27, 2017
Simple way for creating self sizing UITableViews
View SelfsizingTableView.swift
class SelfsizingTableView: UITableView {
override var intrinsicContentSize: CGSize {
return CGSize(width: frame.width,
height: contentSize.height + contentInset.top + contentInset.bottom)
}
override var contentSize: CGSize {
didSet {
if oldValue != contentSize {
@ftp27
ftp27 / STM32L_Blink_Led.c
Last active Oct 7, 2018
Code for blinking led on board STM32L-Discovery
View STM32L_Blink_Led.c
View RepeatButton.swift
import UIKit
class RepeatButton: UIButton {
fileprivate let lineTop:CAShapeLayer = {
let layer = CAShapeLayer()
let linePath = UIBezierPath()
//25x25
linePath.move(to: CGPoint(x: 10.5, y: 2.5))
linePath.addLine(to: CGPoint(x: 22.5, y: 2.5))
@ftp27
ftp27 / UIImageLettersExtenstion.swift
Created Sep 6, 2017
Generation UIImage with first letters of two first words
View UIImageLettersExtenstion.swift
import UIKit
extension UIImage {
class func lettersPhoto(_ input: String,
size: CGSize = CGSize(width:100, height:100)) -> UIImage? {
// Color generation place
let bgColor = UIColor.black
let height = size.height/2
let letters:String = {
View pagination.playground
import PlaygroundSupport
import UIKit
extension NSLayoutConstraint {
class func equalConstraint(item: UIView, attribute: NSLayoutAttribute, toItem: UIView) -> NSLayoutConstraint{
return NSLayoutConstraint(item: item,
attribute: attribute,
relatedBy: .equal,
toItem: toItem,
attribute: attribute,
@ftp27
ftp27 / ArendaScanner.user.js
Created May 31, 2016
User Script for filtring arenda-piter
View ArendaScanner.user.js
// ==UserScript==
// @name Arenda scanner
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Change transparent blocks by filters
// @author ftp27
// @match http://www.arenda-piter.ru/workpage.php*
// @grant none
// ==/UserScript==
@ftp27
ftp27 / STM32makefile.sh
Created Jan 5, 2014
MakeFile for STM32L
View STM32makefile.sh
##############################################################################################
#
# On command line:
#
# make all = Create project
#
# make clean = Clean project files.
#
# To rebuild project do "make clean" and "make all".
#