Skip to content

Instantly share code, notes, and snippets.

class AccessibleComponent extends Component {
render() {
return (
<div>
<div aria-label={this.props.label}>foo</div>
</div>
)
}
}
@fdecampredon
fdecampredon / gist:86ccbba3863bccaec7dd
Last active November 25, 2015 21:58
Obtaining client window size on server
/*jshint node:true*/
var http = require('http');
var fs = require('fs');
var url = require('url');
var querystring = require('querystring');
var head = fs.readFileSync('head.html','UTF-8');
//<head>
// <meta charset="utf-8">
@crmne
crmne / Convert Currency.scpt
Last active April 13, 2018 10:47
Converts currencies using Google Finance. Created specifically for LaunchBar, just put it in `~/Library/Application Support/LaunchBar/Actions`. It accepts input in this form: `<amount> <from currency> […] <to currency>`. So for example all of those strings will result in the same conversion: "60 gbp to eur" "60 gbp in eur" "60 gbp eur". It will …
on parse_input_string(theString)
set AppleScript's text item delimiters to " "
set theFromAmount to text item 1 of theString as text
if length of text items of theString is greater than 1 then
set theFromCurrency to text item 2 of theString as text
set theToCurrency to text item -1 of theString as text
set currenciesGiven to true
else
set theFromCurrency to "USD"
set theToCurrency to "EUR"
@brianloveswords
brianloveswords / git-obliterate
Last active January 24, 2024 12:28
git-obliterate: for removing sensitive files you may have committed from the entire history of the project.
#!/bin/bash
file=$1
test -z $file && echo "file required." 1>&2 && exit 1
git filter-branch -f --index-filter "git rm -r --cached $file --ignore-unmatch" --prune-empty --tag-name-filter cat -- --all
git ignore $file
git add .gitignore
git commit -m "Add $file to .gitignore"
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active April 2, 2024 02:45
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@PaulKinlan
PaulKinlan / criticalcss.html
Last active March 15, 2023 02:13
Detect Critical CSS
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<h2>Original CSS</h2>
<style style="display: block; white-space: pre; font-family: monospace">
h2 { margin:0; }
@bloodyowl
bloodyowl / gist:5823506
Created June 20, 2013 15:02
get all the additions to the global object
/*
get all the additions to the global object
*/
;(function(w,h,o,s,m,a,d){h=w.document,o=h.createElement("iframe"),s=h.body,s.appendChild(o),m=o.contentWindow,a=[];for(d in w)d in m||a.push(d);return a})(this.window || this.global)
@marcedwards
marcedwards / high-dpi-media.css
Last active November 19, 2023 12:56
A CSS media query that captures almost all high DPI aware devices.
/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */