Skip to content

Instantly share code, notes, and snippets.

View cee-chen's full-sized avatar

Cee Chen cee-chen

View GitHub Profile
@cee-chen
cee-chen / keaTypes.ts
Created August 20, 2020 19:15
Kea helpers
/**
* Type helpers from before Kea came with type generation.
* My first foray into Typescript generics, so I'm keeping it around for funsies
*/
export interface IKeaLogic<IKeaValues, IKeaActions> {
mount(): Function;
values: IKeaValues;
actions: IKeaActions;
}
@cee-chen
cee-chen / .htaccess
Last active February 23, 2022 23:33
Apache .htaccess / https / barba.js / Jekyll workaround
# Apache servers throw content mismatch errors with XMLHttpRequests (used by barba.js)
# because links without a trailing slash didn't know to look for a subdir/index.html.
# See:
# https://discuss.emberjs.com/t/mixed-content-the-page-was-loaded-over-https-but-requested-an-insecure-xmlhttprequest-endpoint/13876/10
# https://stackoverflow.com/questions/43696438/strange-mixed-content-issue
# https://serverfault.com/a/817023
# https://webmasters.stackexchange.com/questions/105111
# Disable the default directory slash behavior and handle that ourselves below
@cee-chen
cee-chen / pullrequest-counter.gs
Last active February 20, 2017 20:31
Google Spreadsheets: Automatically fetch and populate a set of GitHub users and their total # of assigned PRs (across a set of specified repos).
var repos = [
"constancecchen/object-fit-polyfill",
"octocat/Hello-World",
];
var users = [
"constancecchen",
"octocat",
];
@cee-chen
cee-chen / wp-backup.sh
Last active February 20, 2017 20:30
WordPress backup script
#!/bin/sh
# Automatically create WordPress database backups every week
# Delete old backups
cd /home/protected
echo "Deleting backups older than 30 days..."
find ./ -mtime +30 -type f -name '*.sql.gz' -print -delete
# Create the backup
now=$(date +"%Y_%m_%d")
@cee-chen
cee-chen / img-cover.scss
Last active March 31, 2018 21:31
Attempt to recreate object-fit: cover with just CSS. Not entirely perfect, some dependency on the media element's aspect ratio
// Parent container
.container {
position: relative;
width: 100vh;
height: 100vh;
overflow: hidden;
}
// Can be an img, video, or picture element
.media {
@cee-chen
cee-chen / scrollmagic-reusable-pins.js
Created August 16, 2016 14:10
Reusable js-class-hook & data attributes for setting pins
/*----------------------------------------------
Generic & reusable logic for sticky/fixed pins
Requires scrollmagic.io
-----------------------------------------------*/
// Dependencies
if (ScrollMagic === undefined) { return; }
document.addEventListener("DOMContentLoaded", function() {
var controller = new ScrollMagic.Controller();