Skip to content

Instantly share code, notes, and snippets.

@derekstavis
derekstavis / FastList.tsx
Last active February 22, 2024 10:33 — forked from vishnevskiy/FastList.js
Discord's FastList, but in TypeScript
import { forEachObjIndexed } from "ramda";
import * as React from "react";
import {
Animated,
ScrollView,
View,
ViewStyle,
LayoutChangeEvent,
NativeScrollEvent,
} from "react-native";
@julien
julien / metaballs.glsl
Created October 29, 2016 12:24
simple metaball shader
precision highp float;
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
float ball(vec2 p, float fx, float fy, float ax, float ay) {
vec2 r = vec2(p.x + sin(time * fx) * ax, p.y + cos(time * fy) * ay);
return 0.09 / length(r);
}
@nuragic
nuragic / es6-array-flatten.js
Last active December 15, 2016 15:42
ES6 Array Flatten
const flatten = (arr) => arr.reduce((prev, current) => prev.concat(Array.isArray(current) ? flatten(current) : current), []);
@paulirish
paulirish / gist:43b68a2b6a38ceaaf345
Last active August 4, 2016 11:29
jQuery 3.0 Ideas

Just some early draft thoughts

Increased modularity is a long-standing request of jQuery. 3.0 should deliver on that. Many authors will use jQuery 3.0 in ES6 codebases, and often alongside frameworks that have overlap in functionality.

That said, a majority of developers will use a monolithic build. jQuery 3.0 must aggressively remove API surface area and functionality from this core build to protect developers from performance footguns. The jQuery team has reasonably voiced concern that removing modules means it's less likely for people to upgrade. While some users do attempt jQuery version upgrades, many freeze their version and never revisit it. I'd like to get more data on this phenomenon as I think we're optimizing API deprecation policy for a small audience.

Lastly, it's 2015 and the gap between JavaScript developers and jQuery developers has never been bigger. Let's bridge that gap. We should encourage the developer to use modern DOM APIs (that don't suck) and polyfill as neccessary.

Rem

@addyosmani
addyosmani / README.md
Last active April 2, 2024 20:18 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@mlynch
mlynch / autofocus.js
Last active August 24, 2022 15:03
AngularJS Autofocus directive
/**
* the HTML5 autofocus property can be finicky when it comes to dynamically loaded
* templates and such with AngularJS. Use this simple directive to
* tame this beast once and for all.
*
* Usage:
* <input type="text" autofocus>
*
* License: MIT
*/
@katychuang
katychuang / remove_brew-mongo_osx.sh
Last active January 30, 2024 12:20
remove mongodb that was installed via brew
#!/usr/bin/env sh
# first check to see if mongo service is running. you can't delete any files until the service stops so perform a quick check.
launchctl list | grep mongo
# NOTE: the pipe | symbol means the commands on the right performs on the output from the left
# grep is a string search utility. `grep mongo` means search for the substring mongo
# use the unload command to end the mongo service. this is required to 'unlock' before removing the service.
# first look for the file to delete
MONGO_SERVICE_FILE=$(ls ~/Library/LaunchAgents/*mongodb*)
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@juandopazo
juandopazo / gist:1182244
Created August 30, 2011 22:14
JavaScript without logical operators or loops
function _if(truthy, then) {
[then, function () {}][+!truthy]();
}
function ifElse(truthy, then, _else) {
[then, _else][+!truthy]();
}
function and(a, b) {
return !!((!!a + !!b) >> 1);
@tony-landis
tony-landis / array-to-texttable.php
Created December 3, 2008 08:00
PHP: Array to Text Table Generation Class
<?php
/**
* Array to Text Table Generation Class
*
* @author Tony Landis <tony@tonylandis.com>
* @link http://www.tonylandis.com/
* @copyright Copyright (C) 2006-2009 Tony Landis
* @license http://www.opensource.org/licenses/bsd-license.php
*/
class ArrayToTextTable