Skip to content

Instantly share code, notes, and snippets.

View richy486's full-sized avatar
🐶
Experimenting

Richard Adem richy486

🐶
Experimenting
View GitHub Profile
@richy486
richy486 / NumberValidator.swift
Last active January 14, 2017 23:16
Swift number validator
let valid = ["3.14159265", "123.12", "2", "56754", "92929292929292.12", "0.21", "3.1","3","-3","0","0.0","1.0","0.1", ".12", "-12", "-34.6"]
let invalid = ["e666.76","a"," ","-"," -1","--1", "2..3", "2-", "2...3", "2.4.3", "5-6-7"]
func isValidNumber(numberString: String) -> Bool {
let numberFormatter = NumberFormatter()
// print(numberFormatter.decimalSeparator)
let decimalSeparator = numberFormatter.decimalSeparator ?? "."
let regularExpression = "[+-]?((\\d+(\\\(decimalSeparator)\\d*)?)|(\\\(decimalSeparator)\\d+))"
// print(regularExpression)
@richy486
richy486 / Unity_tools.py
Created January 10, 2017 18:03
Fix for Blender .blend files being loaded in Unity3D.
import bpy
bl_info = {
"name": "Unity Tools",
"author": "Karol \"Mirgar\" Głażewski",
"version": (1, 0, 2),
"blender": (2, 6, 5),
"location": "3D View > Tool Shelf > Unity Tools",
"description": "Tools to ease workflow with Unity Engine",
"warning": "",
@richy486
richy486 / youtube_m3u8.txt
Created January 6, 2017 21:16
get youtube streaming url
from: http://stackoverflow.com/a/35631022/667834
$ brew install youtube-dl
$ youtube-dl --list-formats https://www.youtube.com/watch\?v\=[YouTube video id]
shows something like:
....
91 mp4 144p HLS , h264, aac @ 48k
@richy486
richy486 / vaporStarted.txt
Last active January 6, 2017 18:20
How did i get Vapor running on Heroku
Vapor Example
https://github.com/vapor/example
Will vapor run on this swift version:
$ curl -sL check.qutheory.io | bash
Install vapor toolbox:
https://github.com/qutheory/vapor-toolbox
$ brew install vapor/tap/toolbox
@richy486
richy486 / new app stuff.txt
Last active October 18, 2019 17:38 — forked from anonymous/new app stuff.txt
Stuff to put in each new app project.
# Add a carthage Cartfile
github "username/Project" ~> 1.0
git "https://github.com/username/Project.git" "branch"
# Update carthage
carthage update --platform ios
# Run script
/usr/local/bin/carthage copy-frameworks
$(SRCROOT)/Carthage/Build/iOS/[framework]
@richy486
richy486 / archFrameworks.txt
Last active October 11, 2016 13:07
Architecture frameworks to try
Hub framework
https://spotify.github.io/HubFramework/
Reactive Swift
https://github.com/ReactiveX/RxSwift
Viper
https://www.objc.io/issues/13-architecture/viper/
http://mutualmobile.github.io/blog/2013/12/04/viper-introduction/
☑ https://developer.apple.com/swift/blog/?id=37
☐ https://oleb.net/blog/2016/09/swift-3-ranges/
☐ https://my.pcloud.com/publink/show?code=XZdKqsZBfty39EC0uFccqHQwv4FQLwlrNf7
☐ https://medium.com/airbnb-engineering/introducing-the-airbnb-imessage-app-806f48d303a8#.i3th9ccue
☐ https://www.raizlabs.com/dev/2016/09/preparing-ios-app-for-extensions/
☐ https://sandofsky.com/blog/singletons.html
☐ http://blog.benjamin-encz.de/post/declarative-api-design-in-swift/
☐ http://nsakaimbo.me/
☐ http://khanlou.com/2016/10/slicing/
@richy486
richy486 / Something+Properties.h
Last active September 1, 2016 22:02
Objective-c categories with properties.
// Objective-c categories with properties.
//
// Taken from:
// http://stackoverflow.com/a/22812632/667834
// http://stackoverflow.com/a/16020927/667834
// http://stackoverflow.com/a/11529511/667834
//
#define CATEGORY_PROPERTY_GET(type, property) \
- (type) property { return objc_getAssociatedObject(self, @selector(property)); }
// vector to radians
let radian = atan2(vector.y, vector.x)
// difference between two vectors
let difference = CGFloat.pi2 - abs(abs(radian1 - radian2) - CGFloat.pi2)
@richy486
richy486 / CGHelpers.swift
Last active September 18, 2018 15:10
Operator overloads for Core Graphics data structures
//
// CGHelpers.swift
//
// Created by Richard Adem on 6/21/16.
// Copyright © 2016 Richard Adem. All rights reserved.
//
// Lerp and Clamp from Daniel Clelland https://github.com/dclelland/Lerp
import CoreGraphics