Skip to content

Instantly share code, notes, and snippets.

View foxinni's full-sized avatar

Foxinni foxinni

View GitHub Profile
@KobbyMmo
KobbyMmo / Image.js
Last active April 14, 2023 12:58
Lazy Loading in React
import PropTypes from "prop-types";
import React from "react";
function Image({ src: ImageSrc, root, rootMargin, threshold, alt, ...props }) {
const [src, setSrc] = React.useState(false);
const imageRef = React.useRef(null);
const callback = React.useCallback((entries) => {
const [entry] = entries;
if (entry.isIntersecting) {
@olee
olee / WebGlVideoProcessor.ts
Created April 17, 2021 00:49
remotion advanced video renderer
import { continueRender, delayRender, RemotionVideoProps } from 'remotion';
import { GlslVarType, setUniform } from './glUtils';
export interface VideoShaderOptions {
variables?: {
type: GlslVarType;
name: string;
}[];
}
@SteveBarnett
SteveBarnett / notes.md
Last active April 14, 2016 07:00
Current preferred WebPageTest setup

Run using the excellent WebPageTest API wrapper for NodeJS by Marcel Duran, and $WPT_API_KEY as an environment variable.

Command

webpagetest test example.com -k $WPT_API_KEY -l "Dulles_MotoG" -y "custom" -D 100 -U 100 -Y 200 -r "5" -vpt

-k key -l location and device (Dulles being thinly place with a selection of mobile devices, at the time of writing)

@msurguy
msurguy / eloquent.md
Last active February 8, 2022 03:13
Laravel 4 Eloquent Cheat Sheet.

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

@simX
simX / hidpi.txt
Created July 28, 2012 04:58
Enable HiDPI mode in Mountain Lion w/o Quartz Debug
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool YES;
sudo defaults delete /Library/Preferences/com.apple.windowserver DisplayResolutionDisabled;
// by the way, you need to logout and log back in for this to take effect. Or at least that's what
// Quartz Debug says. Who knows, maybe it's lying?
// P.S. Go to [Apple menu --> System Preferences --> Displays --> Display --> Scaled] after logging
// back in, and you'll see a bunch of "HiDPI" resolutions in the list to choose from.
@krogsgard
krogsgard / woo-loop-image-wrap.php
Created June 29, 2012 03:51
WooCommerce insert wrapper around thumbnail images in loop
<?php
/* This snippet removes the action that inserts thumbnails to products in teh loop
* and re-adds the function customized with our wrapper in it.
* It applies to all archives with products.
*
* @original plugin: WooCommerce
* @author of snippet: Brian Krogsard
*/
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
@stephenh1988
stephenh1988 / sh-wp-dropdown-taxonomies.php
Created June 9, 2012 20:40
A walker class to use that extends wp_dropdown_categories and allows it to use the term's slug as a value rather than ID
<?php
/*
* A walker class to use that extends wp_dropdown_categories and allows it to use the term's slug as a value rather than ID.
*
* See http://core.trac.wordpress.org/ticket/13258
*
* Usage, as normal:
* wp_dropdown_categories($args);
*