Skip to content

Instantly share code, notes, and snippets.

@jamessawyer
jamessawyer / Accordion.tsx
Created March 13, 2024 02:41
React Patterns
// Compound Components using Context
type AccordionContextProps = {
activeItemIndex: number
setActiveItemIndex: (index: number) => void
}
type AccordionItemProps = {
item: {
id: number
label: string
content: string
@jamessawyer
jamessawyer / CIFilter+Extension.swift
Created March 4, 2020 17:14 — forked from Umity/CIFilter+Extension.swift
CIFilter+Extension.swift
//
// Created by はるふ on 2017/12/11.
// Copyright © 2017年 ha1f. All rights reserved.
//
import Foundation
import CoreImage
import AVFoundation
extension CIFilter {

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).