Skip to content

Instantly share code, notes, and snippets.

View mkj-is's full-sized avatar
📱
Building iOS apps

Matěj Kašpar Jirásek mkj-is

📱
Building iOS apps
View GitHub Profile
@mkj-is
mkj-is / index.html
Created September 22, 2014 08:23
HTML template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>---</title>
<meta name="description" content="---">
<meta name="author" content="Matěj Kašpar Jirásek">
<link rel="stylesheet" href="styles.css">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
@mkj-is
mkj-is / yii-locales-min.php
Last active December 16, 2015 18:59
List of current yii locales in PHP array
<?php return array(
"aa", "af", "agq", "ak", "am", "ar", "as", "asa", "az", "bas", "be",
"bem", "bez", "bg", "bm", "bn", "bo", "br", "brx", "bs", "byn", "ca",
"cch", "cgg", "chr", "cs", "cy", "da", "dav", "de", "dje", "dua", "dv",
"dyo", "dz", "ebu", "ee", "el", "en", "eo", "es", "et", "eu", "ewo",
"fa", "ff", "fi", "fil", "fo", "fr", "fur", "ga", "gaa", "gd", "gez",
"gl", "gsw", "gu", "guz", "gv", "ha", "haw", "he", "hi", "hr", "hu",
"hy", "ia", "id", "ig", "ii", "in", "is", "it", "iu", "iw", "ja", "jmc",
"ka", "kab", "kaj", "kam", "kcg", "kde", "kea", "kfo", "khq", "ki", "kk",
"kl", "kln", "km", "kn", "ko", "kok", "kpe", "ksb", "ksf", "ksh", "ku", "kw",
@mkj-is
mkj-is / unzip.php
Last active March 30, 2016 14:21
For extracting archives during transferring lots of small files over FTP.
<?php
$zip = new ZipArchive;
$res = $zip->open('Archive.zip');
if ($res === TRUE) {
$zip->extractTo('./');
$zip->close();
echo 'ok';
} else {
echo 'failed';
@mkj-is
mkj-is / ActivityIndicatorStyleKit.swift
Last active March 30, 2016 15:18
PaintCode experiments
//
// ActivityIndicatorStyleKit.swift
//
//
// Created by Matěj Kašpar Jirásek on 30/03/16.
// Copyright (c) 2016 Matěj Kašpar Jirásek. All rights reserved.
//
// Generated by PaintCode (www.paintcodeapp.com)
//
@mkj-is
mkj-is / BezierPathLinearAnimation.swift
Created January 15, 2017 13:56
Simple linear animations in Swift
// Create new playground in Xcode and see the result for yourself
// or see the final result here: https://twitter.com/StudioTvor/status/820629171613433856
import UIKit
import PlaygroundSupport
// This is the bezier path that will be animated, feel free to change it or add another one and scroll down for animation.
let logotypePath = UIBezierPath()
logotypePath.move(to: CGPoint(x: 36.28, y: 53.92))
logotypePath.addCurve(to: CGPoint(x: 21.03, y: 48.14), controlPoint1: CGPoint(x: 32.17, y: 50.07), controlPoint2: CGPoint(x: 26.89, y: 48.14))
@mkj-is
mkj-is / AddLinearAnimation.swift
Last active January 16, 2017 16:04
Adding linear animation to shape layer
// Create shape layer and add the path to it
let layer = CAShapeLayer()
layer.path = path.cgPath
// Set up the appearance of the shape layer
layer.strokeEnd = 0
layer.lineWidth = 1
layer.strokeColor = UIColor.black.cgColor
layer.fillColor = UIColor.clear.cgColor
@mkj-is
mkj-is / PathsToLayers.swift
Last active January 16, 2017 16:04
Bezier path to shape layers
let paths = [thPath, ePath, fuPath, nPath, tPath, aPath, sPath, t2Path, yPath]
let layers = paths.map { path -> CAShapeLayer in
let layer = CAShapeLayer()
layer.path = path.cgPath
layer.strokeEnd = 0
layer.strokeColor = UIColor.white.cgColor
layer.lineWidth = 1
layer.fillColor = UIColor.clear.cgColor
return layer
}
@mkj-is
mkj-is / HueColorAnimation.swift
Last active January 24, 2017 12:10
Hue color animation
// We will offset the starting hue of every letter a bit
let startHue = CGFloat(offset) / CGFloat(layers.count)
// And also we offset the end hue a bit
// (We need to check if the hue is not larger than 1, then we use the remainder after dividing by 1 as a correct hue value)
let endHue = (CGFloat(offset + 1) / CGFloat(layers.count + 1)).truncatingRemainder(dividingBy: 1)
// And we create the colors from the hue values
let startColor = UIColor(hue: startHue, saturation: 1, brightness: 1, alpha: 1)
let endColor = UIColor(hue: endHue, saturation: 1, brightness: 1, alpha: 1)
// Finally, we create the animation similarly to the stroke end animation
//
// Keyboardable.swift
//
// Created by Matěj Jirásek on 18/10/2016.
// Copyright © 2016 Matěj K. Jirásek. All rights reserved.
//
import Foundation
protocol Keyboardable {
@mkj-is
mkj-is / DefaultsStore.swift
Created November 15, 2017 15:35
Wrapper for UserDefaults with Codable in Swift 4
import Foundation
final class DefaultsStore<Value: Codable> {
private let defaults: UserDefaults
private let encoder: PropertyListEncoder
private let decoder: PropertyListDecoder