Skip to content

Instantly share code, notes, and snippets.

View Duder-onomy's full-sized avatar
💭
Shred till yer Dead

Greg Larrenaga Duder-onomy

💭
Shred till yer Dead
View GitHub Profile
@stevecastaneda
stevecastaneda / CSSTransition.tsx
Last active May 10, 2024 19:02
CSSTransition component (Typescript). This one allows you use TransitionGroup with Tailwind, animating in a list of items.
import React, { ReactNode } from "react";
import { CSSTransition as ReactTransition } from "react-transition-group";
interface TransitionProps {
in?: boolean;
timeout: number;
enter?: string;
enterFrom?: string;
enterTo?: string;
leave?: string;
@samselikoff
samselikoff / README.md
Last active June 24, 2020 19:56
How to use an `asyncThrows` custom helper.

This assert.asyncThrows custom assertion allows us to write tests against failing async code, usually as a result of a server error (4xx/5xx response).

test('If the index route errors, I see a message', async function(assert) {
  server.create('post');
  server.get('/posts/:id', { errors: ['The site is down'] }, 500); // force Mirage to error

  await assert.asyncThrows(() => {
    return visit('/posts/1');
 }, 'GET /posts/1 returned a 500');
@paulirish
paulirish / what-forces-layout.md
Last active May 8, 2025 05:49
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@pajtai
pajtai / open-and-keep-alive.sh
Last active August 29, 2015 14:25
Robust way of opening an closing ssh tunnels without having to depend on active connections
#!/usr/bin/env bash
#set -x # for debugging
SSH_HOST="[email protected]"
# using -f and -o exitOnForwardFailure is helpful, but if you are managing processes that restart and you want to keep
# the tunnel open even after a restart this can be difficult (e.g. nodemon with a remote mongo, mysql, elasticsearch, etc)
#
# instead you can open the tunnels and close them on script exit
@Duder-onomy
Duder-onomy / imageLoader.js
Last active August 29, 2015 14:20
Async Image Preloader Using Promises AMD
define(['jquery'], function($) {
'use strict';
return function(urlArray) {
return $.when.apply($, urlArray.map(function(url) {
if(url) {
var $imgDeferred = new $.Deferred();
setTimeout(function() {
var imageTag = new Image();
@thomasfr
thomasfr / Git push deployment in 7 easy steps.md
Last active May 6, 2025 10:00
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
@clayton
clayton / ffmpeg-install.sh
Created August 9, 2013 18:55
Install FFMPEG on OS X with HomeBrew to convert Mp4 to WebM
# Installation
brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvorbis --with-libvpx --with-libx264 --with-libxvid
# Easy Peasy
ffmpeg -i video.mp4 video.webm
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@remy
remy / trim-canvas.js
Last active March 20, 2025 00:44
Trims the surrounding transparent pixels from a canvas
// MIT http://rem.mit-license.org
function trim(c) {
var ctx = c.getContext('2d'),
copy = document.createElement('canvas').getContext('2d'),
pixels = ctx.getImageData(0, 0, c.width, c.height),
l = pixels.data.length,
i,
bound = {
top: null,