Skip to content

Instantly share code, notes, and snippets.

@skyfe79
skyfe79 / Gif-CALayer.swift
Created January 24, 2024 02:44 — forked from magicmikek/Gif-CALayer.swift
Add Gif to CALayer for Video Overlay
func startGifAnimation(with url: URL?, in layer: CALayer?) {
let animation: CAKeyframeAnimation? = animationForGif(with: url)
if let animation = animation {
layer?.add(animation, forKey: "contents")
}
}
func animationForGif(with url: URL?) -> CAKeyframeAnimation? {
let animation = CAKeyframeAnimation(keyPath: "contents")
@skyfe79
skyfe79 / NSImageExtensions.swift
Created January 23, 2024 12:01 — forked from Farini/NSImageExtensions.swift
NSImage extensions for easy resizing, cropping and saving png images. Version updated for Swift 3. Originally by Raphael Hanneken https://gist.github.com/raphaelhanneken/cb924aa280f4b9dbb480
extension NSImage {
/// Returns the height of the current image.
var height: CGFloat {
return self.size.height
}
/// Returns the width of the current image.
var width: CGFloat {
return self.size.width
@skyfe79
skyfe79 / Makefile
Created July 4, 2023 12:00 — forked from scastiel/Makefile
Resources for eBook creating using Pandoc
all: pdf epub kindle html examples
BOOK_TITLE = A\ React\ Developer’s\ Guide\ to\ Hooks\ -\ Sebastien\ Castiel
dist:
@mkdir -p dist
pdf: dist/${BOOK_TITLE}.pdf
@echo '✅ PDF'
@skyfe79
skyfe79 / strong-password-regex.md
Created April 10, 2020 05:30 — forked from arielweinberger/strong-password-regex.md
Strong password Regular Expression - NestJS Course
  • Passwords will contain at least 1 upper case letter
  • Passwords will contain at least 1 lower case letter
  • Passwords will contain at least 1 number or special character
  • There is no length validation (min, max) in this regex!

Regular expression for JavaScript:

/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/
@skyfe79
skyfe79 / diff.mdown
Created March 1, 2019 13:41 — forked from ndarville/diff.mdown
Paul Heckel's Diff Algorithm

[Isolating Differences Between Files][paper]

Advantage over Other Algorithms

The diff output is more specific:

[I]f a whole block of text is moved, then all of it, rather than just the beginning and end, is detected as changed.

>The algorithm described here avoids these difficulties. It detects differences that correspond very closely to our intuitive notion of difference.

@skyfe79
skyfe79 / StringExtensionHTML.swift
Created November 20, 2018 14:00
Decoding HTML Entities in Swift
import Foundation
// Very slightly adapted from http://stackoverflow.com/a/30141700/106244
// 99.99% Credit to Martin R!
// Mapping from XML/HTML character entity reference to character
// From http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
private let characterEntities : [String: Character] = [
@skyfe79
skyfe79 / makeAnimatedGif.m
Created November 2, 2017 18:08 — forked from mayoff/makeAnimatedGif.m
Example of creating an animated GIF on iOS, with no 3rd-party code required. This should also be easy to port to OS X.
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
static UIImage *frameImage(CGSize size, CGFloat radians) {
UIGraphicsBeginImageContextWithOptions(size, YES, 1); {
[[UIColor whiteColor] setFill];
UIRectFill(CGRectInfinite);
CGContextRef gc = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(gc, size.width / 2, size.height / 2);
@skyfe79
skyfe79 / build.gradle
Created June 8, 2016 03:48 — forked from Takhion/build.gradle
Automatic Java home (7/8) for Retrolambda with Gradle
String getJavaHome(String version)
{
def stdout = new ByteArrayOutputStream()
exec {
commandLine "/usr/libexec/java_home", "-v", version
standardOutput = stdout;
}
return stdout.toString().trim()
}
@skyfe79
skyfe79 / GameViewController.swift
Created February 27, 2016 16:04 — forked from kconner/GameViewController.swift
Xcode 6.3 OpenGL Game template ported to Swift. (Add "-D DEBUG" to Other Swift Flags setting)
import GLKit
// Uniform index.
private enum Uniform {
case ModelViewProjectionMatrix, NormalMatrix
}
private var gUniforms: [Uniform: GLint] = [:]
extension GLKMatrix3 {
var array: [Float] {

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.