Skip to content

Instantly share code, notes, and snippets.

@OrionReed
OrionReed / dom3d.js
Last active June 6, 2024 12:04
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
//
// PagingView.swift
// Wallaroo - https://wallaroo.app
//
// Created by Sean Heber (@BigZaphod) on 8/9/22.
//
import SwiftUI
// This exists because SwiftUI's paging setup is kind of broken and/or wrong out of the box right now.
@prachigauriar
prachigauriar / Slider+LogarithmicScale.swift
Last active April 11, 2024 16:26
SwiftUI Slider with Logarithmic Scale
extension Binding where Value == Double {
/// Returns a new version of the binding that scales the value logarithmically using the specified base. That is,
/// when getting the value, `log_b(value)` is returned; when setting it, the new value is `pow(base, newValue)`.
///
/// - Parameter base: The base to use.
func logarithmic(base: Double = 10) -> Binding<Double> {
Binding(
get: {
log10(self.wrappedValue) / log10(base)
},
@nsfyn55
nsfyn55 / media-bias-scrubbed-results.csv
Last active May 22, 2024 06:24
A fully scrubbed CSV of all of media bias fact check's primary categories(note on bias negative(-) connotes liberal bias, positive(+) connotes conservative bias)
site_name url bias_rating factual_reporting_rating
(The) Interpreter Magazine http://www.interpretermag.com/ -8 HIGH
1600 Daily https://www.whitehouse.gov/1600daily 26 MIXED
2ndVote https://2ndvote.com/ 29 MIXED
680 News http://www.680news.com/ -3 HIGH
71 Republic https://71republic.com/ 15 HIGH
9 News (Australia) http://www.9news.com.au/ 6 HIGH
ABC News Australia http://www.abc.net.au/news/ -4 HIGH
ABC News http://abcnews.go.com/ -13 HIGH
ABC11 Eyewitness News http://abc11.com/ -11 HIGH
@cellularmitosis
cellularmitosis / EmojiPointersDemo.swift
Created August 15, 2018 18:11
Representing pointer values as emoji can be useful for "visually" debugging certain issues, like cell reuse, etc.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let window = UIWindow(frame: UIScreen.main.bounds)
@benasher44
benasher44 / Swift42Compatibility.swift
Last active March 3, 2019 23:03
Swift 4.2 Compatibility Shims
//
// Created by Ben Asher on 6/13/18.
// Copyright © 2018-present PlanGrid. All rights reserved.
//
import Foundation
import MapKit
import UserNotifications
#if swift(>=4.2)
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active June 11, 2024 09:14
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

As of iOS 11/macOS High Sierra, and only including ones in Foundation and CoreFoundation
Strings:
_NSCFString - a CFStringRef or CFMutableStringRef. This is the most common type of string object currently.
- May have 8 bit (ASCII) or 16 bit (UTF-16) backing store
_NSCFConstantString - a compile time constant CFStringRef, like you'd get with @"foo"
- May also be generated by dynamic string creation if matches a string in a pre-baked table of common strings called the StringROM
NSBigMutableString - an NSString backed by a CFStorage (https://github.com/opensource-apple/CF/blob/master/CFStorage.h) for faster handling of very large strings
NSCheapMutableString - a very limited NSMutableString that allows for zero-copy initialization. Used in NSFileManager for temporarily wrapping stack buffers.
@mackuba
mackuba / wwdc16.md
Last active March 5, 2023 21:28
New stuff from WWDC 2016

Following the tradition from last year, here's my complete list of all interesting features and updates I could find in Apple's OSes, SDKs and developer tools that were announced at this year's WWDC. This is based on the keynotes, the "What's New In ..." presentations and some others, Apple's release notes, and blog posts and tweets that I came across in the last few weeks.

If for some reason you haven't watched the talks yet, I really recommend watching at least the "State of the Union" and the "What's New In" intros for the platforms you're interested in. The unofficial WWDC Mac app is great way to download the videos and keep track of what you've already watched.

If you're interested, here are my WWDC 2015 notes (might be useful if you're planning to drop support for iOS 8 now and start using some iOS 9 APIs).


OSX → macOS 10.12 Sierra