Skip to content

Instantly share code, notes, and snippets.

View elliotlings's full-sized avatar

Elliot Lings elliotlings

View GitHub Profile
@paulirish
paulirish / bling.js
Last active February 18, 2025 14:08
bling dot js
/* bling.js */
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); };
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); };
@djanix
djanix / responsive svg polygon
Created December 8, 2014 22:49
html - responsive svg polygon
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 1000 20" preserveAspectRatio="none" width="100%" height="20">
<polygon points="0,0 1000,0 500,20" style="fill:#cc3333; stroke: lightgrey; stroke-width: 6;"/>
</svg>
@yjkogan
yjkogan / content_editable.js
Created August 12, 2014 23:15
Vue.js "EditableText" directive.
/**
* In order to get the cursor position / selection for a contenteditable HTML element, we need to do some
* fancy stuff. This is necessary for the editable-text directive (and possibly others in the future). This code comes
* from the following stack overflow post:
*
* http://stackoverflow.com/questions/13949059/persisting-the-changes-of-range-objects-after-selection-in-html/13950376#13950376
* Example here:
* http://jsfiddle.net/WeWy7/3/
*
*/
#!/bin/sh
remove_dangling() {
echo "Removing dangling images ..."
docker rmi $(docker images -f dangling=true -q)
}
remove_stopped_containers() {
echo "Removing stopped containers ..."
docker rm $(docker ps -qa)
@jamesmills
jamesmills / .zsh_alias
Last active August 29, 2015 14:04
Alias
# Add 'source ~/.zsh_alias' to the bottom of ~/.zshrc to use
# Can also add to these to /Homestead/aliases for us with your Homestead VM
# Composer
alias csu="composer self-update"
alias cu="composer update"
alias ci="composer install"
alias cda="composer dump-autoload -o"
# Laravel / Artisan
@staltz
staltz / introrx.md
Last active April 19, 2025 05:15
The introduction to Reactive Programming you've been missing
@scottjehl
scottjehl / noncritcss.md
Last active August 12, 2023 16:57
Comparing two ways to load non-critical CSS

I wanted to figure out the fastest way to load non-critical CSS so that the impact on initial page drawing is minimal.

TL;DR: Here's the solution I ended up with: https://github.com/filamentgroup/loadCSS/


For async JavaScript file requests, we have the async attribute to make this easy, but CSS file requests have no similar standard mechanism (at least, none that will still apply the CSS after loading - here are some async CSS loading conditions that do apply when CSS is inapplicable to media: https://gist.github.com/igrigorik/2935269#file-notes-md ).

Seems there are a couple ways to load and apply a CSS file in a non-blocking manner:

@kyledrake
kyledrake / ferengi-plan.txt
Last active January 10, 2025 14:02
How to throttle the FCC to dial up modem speeds on your website using Nginx
# The blog post that started it all: https://neocities.org/blog/the-fcc-is-now-rate-limited
#
# Current known FCC address ranges:
# https://news.ycombinator.com/item?id=7716915
#
# Confirm/locate FCC IP ranges with this: http://whois.arin.net/rest/net/NET-165-135-0-0-1/pft
#
# In your nginx.conf:
location / {
@jonbretman
jonbretman / type.js
Last active January 16, 2024 01:16
Simple type checking in JavaScript.
(function (root) {
var type = function (o) {
// handle null in old IE
if (o === null) {
return 'null';
}
// handle DOM elements