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
@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 June 9, 2024 19:08
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 July 17, 2024 14:28
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 {
import SpriteKit
class GameScene: SKScene {
private var mainCircle: SKSpriteNode!
override func didMoveToView(view: SKView) {
physicsBody = SKPhysicsBody(edgeLoopFromRect: self.frame)
@jellybeansoup
jellybeansoup / update-version.sh
Last active June 23, 2021 08:44
Script for Incrementing Version Numbers
#!/bin/bash
# Link: <https://gist.github.com/jellybeansoup/db7b24fb4c7ed44030f4>
#
# A command-line script for incrementing build numbers for all known targets in an Xcode project.
#
# This script has two main goals: firstly, to ensure that all the targets in a project have the
# same CFBundleVersion and CFBundleShortVersionString values. This is because mismatched values
# can cause a warning when submitting to the App Store. Secondly, to ensure that the build number
# is incremented appropriately when git has changes.
#