Skip to content

Instantly share code, notes, and snippets.

export let action: ActionFunction = async ({ request, params }) => {
let session = await requireAuthSession(request);
await ensureUserAccount(session.get("auth"));
let data = Object.fromEntries(await request.formData());
invariant(typeof data._action === "string", "_action should be string");
switch (data._action) {
case Actions.CREATE_TASK:
case Actions.UPDATE_TASK_NAME: {
@drewdaemon
drewdaemon / ThumbnailGenerator.js
Last active May 13, 2022 12:58
Front end JS for generating image thumbnails from base64-encoded images.
function ThumbnailGenerator() {
this.resizeCanvas = document.createElement('canvas');
this.generate = function (imgSrc, thumbDims, compression) {
[this.resizeCanvas.width, this.resizeCanvas.height] = [thumbDims.x, thumbDims.y];
const ctx = this.resizeCanvas.getContext("2d");
const tmp = new Image();
const ret = new Promise(resolve => {
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active May 3, 2024 13:01
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
$space-inset-default = 16px 16px 16px 16px;
$space-inset-xs = 4px 4px 4px 4px;
$space-inset-s = 8px 8px 8px 8px;
$space-inset-m = 16px 16px 16px 16px;
$space-inset-l = 32px 32px 32px 32px;
$space-inset-xl = 64px 64px 64px 64px;
$space-stack-default = 0 0 16px 0;
$space-stack-xs = 0 0 4px 0;
$space-stack-s = 0 0 8px 0;
$space-stack-m = 0 0 16px 0;
@ayamflow
ayamflow / gist:b602ab436ac9f05660d9c15190f4fd7b
Created May 9, 2016 19:10
Safari border-radius + overflow: hidden + CSS transform fix
// Add on element with overflow
-webkit-mask-image: -webkit-radial-gradient(white, black);
@kaleksandrov
kaleksandrov / global-protect.sh
Last active April 19, 2024 03:46
Simple script that starts and stops GlobalProtect.app on Mac OSX.
#!/bin/bash
case $# in
0)
echo "Usage: $0 {start|stop}"
exit 1
;;
1)
case $1 in
start)
/**
* A redux middleware for processing Meteor methods
* When an action is dispatched, it will pass through our middleware.
* if denoted a method, we will dispatch the action with readyState of loading
* The method passed in is then called, and dispatches further ready states for success/error
* The reducer shape should include { data, readyState } for use in the UI
* @returns {Function}
*/
export default function methodMiddleware() {
return (next) => {
@sapegin
sapegin / preload.js
Created February 21, 2016 07:42
Tamia image preload es6
// Image preload
import { ensureArray } from './util';
export default function preload(images, callback) {
let done = () => {
counter--;
if (counter === 0) {
callback(errors.length ? errors : null);
}
@optilude
optilude / client:entry.js
Created October 26, 2015 11:00
Webpack vs. React
// Polyfill ES6 for older browsers
import 'babel/polyfill';
// Trigger globals / methods
import 'simon/client/startup';
import './routes';
@Yimiprod
Yimiprod / difference.js
Last active April 5, 2024 13:17
Deep diff between two object, using lodash
/**
* This code is licensed under the terms of the MIT license
*
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*/
function difference(object, base) {
function changes(object, base) {