Skip to content

Instantly share code, notes, and snippets.

View aeharding's full-sized avatar
🪂
Flying

Alexander Harding aeharding

🪂
Flying
View GitHub Profile
@aeharding
aeharding / run_mods.sh
Created February 15, 2024 03:10
Run ionic mods for voyager-ionic-core
#!/bin/bash
# Navigate to the core directory
cd core || exit
# Fetch upstream changes and checkout the latest release
git fetch upstream
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
# Delete the existing "tweak" branch if it exists
@aeharding
aeharding / useOptimizedIonRouter.tsx
Created November 27, 2023 21:56
useIonRouter() has routeInfo attached. This causes a rerender of all components that contain useIonRouter, slowing down swipes. Since 99% of components don't use routeInfo and just need to push, we can optimize by using refs so rerender isn't triggered.
import { UseIonRouterResult, useIonRouter } from "@ionic/react";
import {
MutableRefObject,
ReactNode,
createContext,
useContext,
useEffect,
useMemo,
useRef,
} from "react";
@aeharding
aeharding / isInsideSFSafariViewController.ts
Last active August 15, 2022 00:39
Check if page is running in SFSafariViewController vs the Safari app
// IF YOU ARE AN APPLE ENGINEER READING THIS:
//
// PLEASE put the "Add to Home Screen" option inside the share menu of
// SFSafariViewController like it is in the Safari app!
//
// The code below is needed in order to differentiate to
// provide user messaging because of this difference.
//
// If the "Add to Home Screen" button was available in both
// SFSafariViewController + Safari, I wouldn't need this hack.
@aeharding
aeharding / index.html
Created November 26, 2016 01:45
Trying to replicate pouchdb/pouchdb#5943
<!DOCTYPE html>
<html>
<head>
<script src="//cdn.jsdelivr.net/pouchdb/6.0.7/pouchdb.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js"></script>
</head>
<body>
<button onclick="seed()">Seed the database with 10000 docs</button><br>
<button onclick="recreate()">Destroy and recreate database</button><br>
<button onclick="verifyDocs()">Verify 10000 docs exist</button><br>
@aeharding
aeharding / secureRandom.js
Created September 29, 2016 15:23
Generates a cryptographically secure number [0-1) as an alternative to Math.random()
// Generates a cryptographically secure number [0-1)
// as an alternative to Math.random()
//
// source: http://stackoverflow.com/a/13694869/1319878
function secureRandom() {
var arr = new Uint32Array(2);
crypto.getRandomValues(arr);
// keep all 32 bits of the the first, top 20 of the second for 52 random bits
var mantissa = (arr[0] * Math.pow(2,20)) + (arr[1] >>> 12)
@aeharding
aeharding / timeoutSort.coffee
Last active August 29, 2015 14:05
Sort an array of positive integers using timeouts. *genius*
# Only works with positive numbers #dealwithit
timeoutSort = (arr, cb) ->
ret = []
longest = 0
for t in arr then do ->
longest = t if t > longest
tmp = t
setTimeout ->
ret.push tmp
, t
@aeharding
aeharding / LinkedList.coffee
Last active August 29, 2015 13:57
A LinkedList (with Node and Iterator) written in Coffeescript to exercise my mind!
class LinkedList
isEmpty: ->
not @head?
prepend: (item) ->
node = new Node item, @head
@tail = node if @isEmpty()
@head = node
append: (item) ->
@aeharding
aeharding / index.coffee
Last active August 29, 2015 13:57
Diagonal star on dinamic grid thingy
diagDir = false
x = 5
y = 9
console.clear()
# Initialize that shizzle
grid = []
for i in [0...10]
grid.push []