Skip to content

Instantly share code, notes, and snippets.

View davidsharp's full-sized avatar

David Sharp davidsharp

View GitHub Profile
@davidsharp
davidsharp / triangular-number.js
Created December 17, 2021 10:23
Finds triangular number (or x + x-1 + x-2, etc down to 0)
const fn = x => x + (x * ((x-1)/2))
@davidsharp
davidsharp / remark-star-wipe.css
Last active November 26, 2021 10:20
A neat little star wipe for Remark.js presentations
@-webkit-keyframes wipe {
0% {
-webkit-mask-size: 0% 0%;
}
100% {
-webkit-mask-size: 550% 550%;
}
}
.remark-visible .remark-slide-content {
@davidsharp
davidsharp / animated-sync-icon.jsx
Created October 28, 2021 09:31
An old animated sync icon, for an old version of React Native (0.40.0)
import React, {
PropTypes, Component
} from 'react';
import {
Animated, Easing
} from 'react-native';
// BYO sync icon
const SYNC = require('../images/sync.png')
@davidsharp
davidsharp / townscaper-overlook
Created October 27, 2021 13:29
Overlook, a Townscaper town with small quaint buildings and overbearing towers
HzRBnyQt1d2e-uD5L6T7PJdXrnt7_9Q_0_wNPSvW3Z797p9nAsLydSubwj0r1w273L6hdav9pk3mHpXrnt3v7iebbfm4J5uNPSvW3AAzZ7972F9NGAAAEE0yGAAE0nAuLytdSebCAkkkj0Bggctutw2LKApTLAobMAIJJJJpPBcXi7k82cbHpbL5a9QWSSXUAQ60CAS3YAQfC4l4J5t5RKAzhskk0FFA0pFA0nAidJujEAkDJA9JgbXib7kAAJ5IBA5sBAI5TAAQuEAQOJAQzRCAz1CASQ_UCAgckAgctAgc2Ag8pEAI52AA5IBA5aBA5TJAQSuNAQQOSAQQSO
@davidsharp
davidsharp / jump.css
Last active October 22, 2021 08:17
Lousy alternating jumping styles (good for jumping pumpkins 🎃)
.jump {
display: inline-block;
animation-duration: 1.5s;
animation-name: jump;
animation-iteration-count: infinite;
}
.jump.alt {
animation-delay: .75s;
}
@keyframes jump {
@davidsharp
davidsharp / sway.css
Last active October 21, 2021 23:37
A short and sweet CSS snippet for slightly spooky swaying text and more
.sway {
display: inline-block;
animation-duration: 2s;
animation-name: sway;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-timing-function: ease-in-out;
}
@keyframes sway {
from {
@davidsharp
davidsharp / local-storage-proxy.js
Created August 17, 2021 13:08
Example of using JS proxies as a wrapper for localStorage
// localStorageProxy.foo = 'bar'
// -> localStorage.getItem('foo') = 'bar'
localStorageProxy = new Proxy(localStorage, {
get: (r,n)=>r.getItem(n),
set: (r,n,v)=>r.setItem(n,v),
deleteProperty: (r,n)=>r.removeItem(name)
})
// reverses the vowels of a (lowercase) word
(
s=>(r=/[aeiou]/g,x=s.match(r),c=x.length,s.replace(r,_=>x[--c]))
)('geographically') // -> gaigraphocelly
// sorts the vowels in a (lowercase) word
(
s=>(r=/[aeiou]/g,x=s.match(r).sort(),c=0,s.replace(r,_=>x[c++]))
)('crocodile') // -> crecidolo
@davidsharp
davidsharp / autorun-retropie.js
Created May 1, 2021 19:30
(untested) interruptable node.js script for autorunning retropie on a raspberry pi
const child_process = require('child_process')
const readline = require('readline');
let bootRP = true;
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});