Skip to content

Instantly share code, notes, and snippets.

@manmal
manmal / SharedState.swift
Last active April 25, 2021 08:18
Shared State for The Composable Architecture - Make state accessible to sub components
// Copyright (c) 2021 Manuel Maly
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
@Clarko
Clarko / Frost.swift
Last active December 9, 2021 22:20
SwiftUI live-blur materials
// ⚠️ As of WWDC21 you can just use a SwiftUI Material
// https://developer.apple.com/documentation/swiftui/material
//
// Frost.swift
//
// Created by Clarko on 7/19/20.
//
// A SwiftUI representation of UIVisualEffectView
// and UIBlurEffect, that handles mostly like a
// SwiftUI Color view. Use it as a .background()
@chriseidhof
chriseidhof / goroutines.swift
Created February 16, 2018 12:36
goroutines.swift
import Foundation
protocol Channel: IteratorProtocol {
func send(_ value: Element?)
}
/// A blocking channel for sending values.
///
/// `send` and `receive` must run in separate separate execution contexts, otherwise you get a deadlock.
final class BlockingChannel<A>: Channel {
@smileyborg
smileyborg / InteractiveTransitionCollectionViewDeselection.m
Last active January 15, 2023 13:03
Animate table & collection view deselection alongside interactive transition (for iOS 11 and later)
// UICollectionView Objective-C example
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSIndexPath *selectedIndexPath = [[self.collectionView indexPathsForSelectedItems] firstObject];
if (selectedIndexPath != nil) {
id<UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
if (coordinator != nil) {
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
@westerlund
westerlund / RubberBand.md
Created May 25, 2017 14:25 — forked from originell/RubberBand.md
This is a straight copy of – to avoid this ever going dark http://squareb.wordpress.com/2013/01/06/31/

Analysis of Apple’s rubber band scrolling

January 6, 2013

I recently saw a post on Twitter from @chpwn that described the alogorithm that Apple uses for its “rubber band” or “bungee” scrolling.

b = (1.0 – (1.0 / ((x * c / d) + 1.0))) * d
@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@cybear
cybear / error-messages.md
Created March 10, 2015 09:04
Writing tips for error messages

Writing tips for error messages

  • Describe the cause of the error, if possible.
  • Avoid blaming the user. "You typed a URL that doesn't exist" => "We can't find any page at this URL"
  • Avoid impersonal writing. "Could not upload selected files" => "We could not upload the files that you selected"
  • Suggest a next action for the user if it is plausible.
@bobbygrace
bobbygrace / trello-css-guide.md
Last active April 22, 2024 10:15
Trello CSS Guide

Hello, visitors! If you want an updated version of this styleguide in repo form with tons of real-life examples… check out Trellisheets! https://github.com/trello/trellisheets


Trello CSS Guide

“I perfectly understand our CSS. I never have any issues with cascading rules. I never have to use !important or inline styles. Even though somebody else wrote this bit of CSS, I know exactly how it works and how to extend it. Fixes are easy! I have a hard time breaking our CSS. I know exactly where to put new CSS. We use all of our CSS and it’s pretty small overall. When I delete a template, I know the exact corresponding CSS file and I can delete it all at once. Nothing gets left behind.”

You often hear updog saying stuff like this. Who’s updog? Not much, who is up with you?

var red = '#c00'
var white = '#fff'
console.log('<table border=0 cellspacing=0 cellpadding=0 style="line-height:10px">\n' + ([
'111111111111111111',
'1 1 1 1',
'1 1 1 1 1 1 1 1',
'1 1 1 1 1 1 1 1',
'1 1 1 1 1 1 1',
'111111 1111111111',
@simme
simme / app.js
Last active May 16, 2019 05:59
Gulp file for an Ember project using bower and browserify.
// Load Ember into the global scope by requiring it
require('ember');
// Go have fun
var app = Ember.Application.create();