Skip to content

Instantly share code, notes, and snippets.

Avatar

Rémi Gérard-Marchant remitbri

View GitHub Profile
View best-way.js
class AccessibleComponent extends Component {
render() {
return (
<div>
<div aria-label={this.props.label}>foo</div>
</div>
)
}
}
@fdecampredon
fdecampredon / gist:86ccbba3863bccaec7dd
Last active Nov 25, 2015
Obtaining client window size on server
View gist:86ccbba3863bccaec7dd
/*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 Apr 13, 2018
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 …
View Convert Currency.scpt
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 Dec 10, 2021
git-obliterate: for removing sensitive files you may have committed from the entire history of the project.
View git-obliterate
#!/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 Jan 4, 2022
CriticalCSS Bookmarklet and Devtool Snippet.js
View criticalcss-bookmarklet-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 May 6, 2021
Detect Critical CSS
View criticalcss.html
<!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 Jun 20, 2013
get all the additions to the global object
View gist:5823506
/*
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 Jun 28, 2021
A CSS media query that captures almost all high DPI aware devices.
View high-dpi-media.css
/* ---------------------------------------------------------- */
/* */
/* 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 */