Skip to content

Instantly share code, notes, and snippets.

View Josscii's full-sized avatar
💭
??

Josscii Josscii

💭
??
View GitHub Profile
@ypresto
ypresto / YPLayoutGuideHelper.m
Last active April 20, 2020 15:07
Apply automaticallyAdjustsScrollViewInsets in child view controller like Container View or UIPageViewController
//
// YPLayoutGuideHelper.m
//
// Created by Yuya Tanaka, 2015
//
// This is free and unencumbered software released into the public domain.
// Refer: http://unlicense.org/
//
// automaticallyAdjustsScrollViewInsets doesn't work for child view controllers
// hosted by something like Container View or UIPageViewController.
@paulirish
paulirish / what-forces-layout.md
Last active April 12, 2025 21:43
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@Kametrixom
Kametrixom / emoji.swift
Created August 3, 2015 20:46
Gets all Emoji Unicode code points from the latest Unicode source and prints them out (as Emoji). Also: Prints out all country flag emojis from "AA" to "ZZ"
import Foundation
import XCPlayground
XCPSetExecutionShouldContinueIndefinitely()
func getAllEmojis(completion: String? -> ()) {
let url = NSURL(string: "http://www.unicode.org/Public/UCD/latest/ucd/EmojiSources.txt")!
NSURLSession.sharedSession().dataTaskWithURL(url) { data, response, error in
guard let data = data where error == nil else {
completion(nil)
@stuartjmoore
stuartjmoore / FontMeasure.swift
Created June 21, 2015 21:54
Fix Clipping UITextView
//: Playground - noun: a place where people can play
import XCPlayground
import UIKit
// MARK: - Paragraph Styles
let headlineParagraphStyle = NSMutableParagraphStyle()
headlineParagraphStyle.lineHeightMultiple = 0.8
@algal
algal / FontUtils.swift
Last active January 12, 2018 18:43
Type-safe font initiazer
//
// MARK: Font utilities
//
enum FontFamily : String {
case HelveticaNeue = "Helvetica Neue"
case MontSerrat = "Montserrat"
}
enum FontWeight {
@josephg
josephg / 0dedict.py
Last active February 20, 2025 03:12
Apple dictionaries
# Thanks to commenters for providing the base of this much nicer implementation!
# Save and run with $ python 0dedict.py
# You may need to hunt down the dictionary files yourself and change the awful path string below.
# This works for me on MacOS 10.14 Mohave
from struct import unpack
from zlib import decompress
import re
filename = '/System/Library/Assets/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/9f5862030e8f00af171924ebbc23ebfd6e91af78.asset/AssetData/Oxford Dictionary of English.dictionary/Contents/Resources/Body.data'
f = open(filename, 'rb')

Git Cheat Sheet

Commands

Getting Started

git init

or

@JaviLorbada
JaviLorbada / FRP iOS Learning resources.md
Last active March 19, 2025 07:02
The best FRP iOS resources.

Videos

@kirsteins
kirsteins / Array -> UnsafeMutablePointer -> Array
Last active June 16, 2024 09:42
Array -> UnsafeMutablePointer -> Array
var initalArray = [1, 2, 3]
let pointer: UnsafeMutablePointer<Int> = UnsafeMutablePointer(initalArray)
let arrary = Array(UnsafeBufferPointer(start: pointer, count: initalArray.count))
@steipete
steipete / workaround.m
Created January 6, 2015 22:14
If you're implementing child view controllers and want automaticallyAdjustsScrollViewInsets to work...
// This ensures that the automaticallyAdjustsScrollViewInsets magic works
// On our newly added view controller as well.
// This triggers _layoutViewController which then triggers
// _computeAndApplyScrollContentInsetDeltaForViewController:
// which finally updates our content inset of the scroll view (if any)
// rdar://19053416
[self.navigationController.view setNeedsLayout];