Skip to content

Instantly share code, notes, and snippets.

@yosshi4486
yosshi4486 / SynchronizingKeyValueStore.swift
Last active July 17, 2024 08:38
Example of syncing key value stores.
//
// SynchronizingKeyValueStore.swift
//
// Created by yosshi4486 on 2022/08/30.
//
import Foundation
/// A key value store that stores a key-value into both local and cloud. Subclass this class and override methods for your application.
///
@christianselig
christianselig / Locale+SFSymbol.swift
Created September 3, 2021 21:54
Returns an SF Symbol currency image that match's the device's current locale, for instance dollar in North America, Indian rupee in India, etc.
extension Locale {
/// Returns an SF Symbol currency image that match's the device's current locale, for instance dollar in North America, Indian rupee in India, etc.
func currencySFSymbol(filled: Bool, withConfiguration configuration: UIImage.Configuration? = nil) -> UIImage {
// Default currency symbol will be the Animal Crossing Leaf coin 􁂬 to remain impartial to any specific country
let defaultSymbol = UIImage(systemName: "leaf.circle\(filled ? ".fill" : "")")!
guard let currencySymbolName = currencySymbolNameForSFSymbols() else { return defaultSymbol }
let systemName = "\(currencySymbolName).circle\(filled ? ".fill" : "")"
return UIImage(systemName: systemName, withConfiguration: configuration) ?? defaultSymbol

iPhone

Model(s) Physical Size Points (Standard) Points (Zoomed) Scale Device Resolution Screen Resolution
iPhone 16 Pro Max 6.9" 440 x 956 375 x 812 @3x 1320 x 2868 1320 x 2868
iPhone 16 Pro 6.3" 402 x 874 320 x 693 @3x 1206 x 2622 1206 x 2622
iPhone 16 Plus 6.7" 430 x 932 375 x 812 @3x 1290 x 2796 1290 x 2796
iPhone 16 6.1" 393 x 852 320 x 693 @3x 1179 x 2556 1179 x 2556
iPhone 15 Pro Max 6.7" 430 x 932 375 x 812 @3x 1290 x 2796 1290 x 2796
@mattdesl
mattdesl / sketch.js
Last active April 29, 2022 07:10
h264-mp4-encoder + canvas-sketch = in-browser MP4 generation
// npm canvas-sketch-cli -g
// canvas-sketch sketch.js --open
const canvasSketch = require('canvas-sketch');
const H264 = require('h264-mp4-encoder');
const { lerp } = require("canvas-sketch-util/math");
const settings = {
duration: 4,
dimensions: [1024, 1024],
@botagar
botagar / blerp.js
Created May 5, 2020 23:15
Javascript implementation of Bilinear Interpolation
Math.blerp = function (values, x1, y1, x2, y2, x, y) {
let q11 = (((x2 - x) * (y2 - y)) / ((x2 - x1) * (y2 - y1))) * values[x1][y1]
let q21 = (((x - x1) * (y2 - y)) / ((x2 - x1) * (y2 - y1))) * values[x2][y1]
let q12 = (((x2 - x) * (y - y1)) / ((x2 - x1) * (y2 - y1))) * values[x1][y2]
let q22 = (((x - x1) * (y - y1)) / ((x2 - x1) * (y2 - y1))) * values[x2][y2]
return q11 + q21 + q12 + q22
}
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active March 17, 2025 06:52
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@kaneelyster
kaneelyster / Auto Backup ADB commands.md
Last active October 2, 2024 18:01
Auto Backup ADB commands

Good write-up here.

Enable ADB verbose logging for backups:
adb shell setprop log.tag.GmsBackupTransport VERBOSE
adb shell setprop log.tag.BackupXmlParserLogging VERBOSE

Force auto backup:
adb shell bmgr backupnow <PACKAGE>

Force full backup:

@allanweir
allanweir / SpriteKitTimingFunctions.swift
Last active February 12, 2022 09:15
Custom easing functions for use with SpriteKit / SKAction
//
// SKTimingFunction.swift
// Studious ToolKit
//
// Created by Allan Weir on 09/01/2017.
// Copyright © 2017 Allan Weir. All rights reserved.
// Adapted from a JavaScript version found at https://gist.github.com/gre/1650294
//
class SpriteKitTimingFunctions {
@tsauerwein
tsauerwein / index.html
Created April 19, 2016 20:21
OpenLayers 3 + windy.js
<!doctype html>
<html lang="en">
<head>
<title>windy.js integration example</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<link rel="stylesheet" href="http://openlayers.org/en/v3.15.0/css/ol.css" type="text/css">
<style type="text/css">
#map {
@rvl
rvl / git-pushing-multiple.rst
Created February 9, 2016 11:41
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just