Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Second Page</title>
</head>
<body>
<h1>This is the second page</h1>
<script>
@iamjason
iamjason / simulator_fullscreen.sh
Created October 26, 2018 19:18
Allow XCode + Simulator to share a split screen
defaults write com.apple.iphonesimulator AllowFullscreenMode -bool YES
@iamjason
iamjason / Date+FindPrevNextWeekday.swift
Created February 2, 2018 03:51
Extension that helps to find the week's previous/next weekday. e.g. if it's sunday, what was last monday's date?
/**
Extension that helps to find the week's previous/next weekday.
e.g. if it's sunday, what was last monday's date?
usage: Date().get(direction: .previous, dayName: .monday, considerToday: true)
*/
extension Date {
// weekday is in form 1...7
enum WeekDay: Int {
case sunday = 1, monday, tuesday, wednesday, thursday, friday, saturday
import UIKit
import RxCocoa
import RxSwift
// KEYBOARD STUFF
extension UIViewController {
func setupViewResizerOnKeyboardShown(bag:DisposeBag) {
NotificationCenter.default.rx
@iamjason
iamjason / String+HTMLToNSAttributedString.swift
Last active March 9, 2017 21:10
HTML to NSAttributedString
import UIKit
public extension String {
static let htmlBase = "<html><head><style type='text/css'> body { color: %COLOR%; } %STYLE% </style></head><body>%BODY%</body></html>"
static let cssBase = " h1 { font-family: 'GTWalsheimLight'; font-size: 34px; } h2 { font-family: 'GTWalsheimBold'; font-size: 24px; } h3 { font-family:'GTWalsheimLight'; font-size: 18px; } h4 { font-family:'GTWalsheimBold'; font-size: 14px; } h5 { font-family:'GTWalsheimBold'; font-size: 12px; } p { font-family: 'SourceSansPro-Regular'; font-size: 16px; } p.strong { font-family: 'SourceSansPro-Semibold'; font-size: 16px; }"
public func HTMLtoAttributedText(_ color:UIColor = UIColor.black, css:String = String.cssBase) -> NSAttributedString? {
@iamjason
iamjason / Fonts+Helper.swift
Last active May 24, 2017 05:29
Loading Custom Fonts - Swift 3
import UIKit
/// Load Fonts
///
/// Example Usage:
///
/// let fonts = ["SourceSansPro-Regular.otf", "GT-Walsheim-Regular.ttf"]
///
/// let loadedSuccessfuly = loadFonts(fonts)
///
@iamjason
iamjason / noah's ark.swift
Last active April 18, 2016 15:37
Noah's Ark w/ Swift 2 using immutable values
// Inspired by: https://gist.github.com/futurepaul/8b99d502006cf8a67a93
import UIKit
typealias ๐Ÿพ = String
let ๐ŸŒ = "๐Ÿฆƒ๐Ÿ•Š๐Ÿถ๐Ÿบ๐Ÿฑ๐Ÿญ๐Ÿน๐Ÿฐ๐Ÿธ๐Ÿฏ๐Ÿจ๐Ÿป๐Ÿท๐Ÿฝ๐Ÿฎ๐Ÿ—๐Ÿต๐Ÿ’๐Ÿด๐Ÿ‘๐Ÿ˜๐Ÿผ๐Ÿง๐Ÿฆ๐Ÿค๐Ÿฅ๐Ÿฃ๐Ÿ”๐Ÿ๐Ÿข๐Ÿ›๐Ÿ๐Ÿœ๐Ÿž๐ŸŒ๐Ÿ™๐Ÿš๐Ÿ ๐ŸŸ๐Ÿฌ๐Ÿณ๐Ÿ‹๐Ÿ„๐Ÿ๐Ÿ€๐Ÿƒ๐Ÿ…๐Ÿ‡๐Ÿ‰๐ŸŽ๐Ÿ๐Ÿ“๐Ÿ•๐Ÿ–๐Ÿ๐Ÿ‚๐Ÿฒ๐Ÿก๐ŸŠ๐Ÿซ๐Ÿช๐Ÿ†๐Ÿˆ๐Ÿฉ"
let ๐Ÿšข = ๐ŸŒ.characters
.map { (๐Ÿšœ) -> ๐Ÿพ in
return ๐Ÿพ(๐Ÿšœ)
}
@iamjason
iamjason / ping-google
Created April 16, 2015 23:51
testing time warner's new router
โžœ Maven git:(master) โœ— ping -c google.com
ping: invalid count of packets to transmit: `google.com'
โžœ Maven git:(master) โœ— ping -c 10 google.com
PING google.com (74.125.226.9): 56 data bytes
64 bytes from 74.125.226.9: icmp_seq=0 ttl=52 time=13.532 ms
64 bytes from 74.125.226.9: icmp_seq=1 ttl=52 time=562.196 ms
64 bytes from 74.125.226.9: icmp_seq=2 ttl=52 time=11.785 ms
64 bytes from 74.125.226.9: icmp_seq=3 ttl=52 time=18.157 ms
64 bytes from 74.125.226.9: icmp_seq=4 ttl=52 time=12.873 ms
64 bytes from 74.125.226.9: icmp_seq=5 ttl=52 time=10.785 ms
@iamjason
iamjason / us-states-array
Created December 29, 2014 01:31
Swift US States Array
let state = [ "AK - Alaska",
"AL - Alabama",
"AR - Arkansas",
"AS - American Samoa",
"AZ - Arizona",
"CA - California",
"CO - Colorado",
"CT - Connecticut",
"DC - District of Columbia",
"DE - Delaware",
@iamjason
iamjason / JGCell.swift
Created December 16, 2014 20:39
Generic UITableViewCell Implementation (swift)
class JGCell : UITableViewCell {
override init(style: UITableViewCellStyle, reuseIdentifier: String!) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupViews()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)