Skip to content

Instantly share code, notes, and snippets.

View ftp27's full-sized avatar
🛠️

Aleksei Cherepanov ftp27

🛠️
View GitHub Profile
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 / playground.swift
Created June 27, 2019 15:03
AutoLayout Hugging Priority and Compression Resistance Priority tests
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
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 September 6, 2017 14:13
Generation UIImage with first letters of two first words
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 = {
@ftp27
ftp27 / SelfsizingTableView.swift
Created August 27, 2017 17:54
Simple way for creating self sizing UITableViews
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 {
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 12:14
User Script for filtring arenda-piter
// ==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 / task_1_1.cpp
Last active December 16, 2015 07:17
Yanich Tasks
#include <stdio.h>
#include <math.h>
int main()
{
float x;
printf("Please, enter X: ");
scanf("%f", &x);
float y = pow((sin(x)+(7/3)),2/3);
printf("f(%4.2f) = %4.2f\n",x,y);
@ftp27
ftp27 / prepare_screens.sh
Created September 30, 2015 08:52
Resize screenshots for set of iPhone screen sizes
#!/bin/bash
convert -resize 640x960! $1 "3.5-"$1
convert -resize 640x1136! $1 "4-"$1
convert -resize 750x1334! $1 "4.7-"$1
convert -resize 1242x2208! $1 "5.5-"$1
package com.codename1.social;
import com.codename1.io.Oauth2;
import com.codename1.social.Login;
import java.util.Hashtable;
public class VkontakteConnect extends Login{
private static String scope = "email";
private static String tokenURL = "https://oauth.vk.com/access_token";