Skip to content

Instantly share code, notes, and snippets.

View benschwarz's full-sized avatar
🏁
Making the web fast

Ben Schwarz benschwarz

🏁
Making the web fast
View GitHub Profile
@benschwarz
benschwarz / index.html
Last active November 6, 2023 21:10
Using ARIA roles with <header>, <footer> and <aside>
<!doctype html>
<html>
<body>
<header role="banner">
<a href="/" rel="home">My company</a>
<nav role="navigation">
<a href="/about">About</a>
<a href="/contact">Contact</a>
</nav>
</header>
@benschwarz
benschwarz / csrf-token.js
Created April 7, 2013 23:11
Set the CSRF token for Rails when doing Ajax requests
define( ['jquery'], function ( $ ) {
var token = $( 'meta[name="csrf-token"]' ).attr( 'content' );
$.ajaxSetup( {
beforeSend: function ( xhr ) {
xhr.setRequestHeader( 'X-CSRF-Token', token );
}
});
return token;
@benschwarz
benschwarz / pg.md
Last active December 15, 2020 04:20
Awesome postgres
@benschwarz
benschwarz / README.md
Created October 14, 2015 14:56
Intercom CSP (Content security policy)

You'll need to add a whole slew of hosts for intercom if you've got CSP in place (which you should).

Heres what you'll need to add:

connect-src: https://api-ping.intercom.io https://nexus-websocket-a.intercom.io https://nexus-websocket-b.intercom.io wss://nexus-websocket-a.intercom.io wss://nexus-websocket-b.intercom.io https://api-iam.intercom.io 
script-src: https://widget.intercom.io https://js.intercomcdn.com
image-src: https://js.intercomcdn.com
@benschwarz
benschwarz / .bowerrc
Last active April 3, 2019 07:55
Bower + Rails asset pipeline
{
"directory": "vendor/assets/components"
}
// Add Modernizr test for font-smoothing
// A designer may wish to darken the colour of a given font when antialiasing is applied
// Examples of font-smoothing in action: http://bit.ly/bLeUg1
/*
Usage:
Add to your page
Use html.fontsmoothing h1 { color: xxx; } to make your colours darker
*/
@benschwarz
benschwarz / vector-bg-with-fallback.scss
Last active May 19, 2017 01:30
SVG background image with PNG fallback (Sass mixin)
$public_path: "./";
@mixin vector-bg-with-fallback($name) {
background-image: url('#{$public_path}images/#{$name}.png');
background-image: none, url('#{$public_path}images/#{$name}.svg');
}

Keybase proof

I hereby claim:

  • I am benschwarz on github.
  • I am benschwarz (https://keybase.io/benschwarz) on keybase.
  • I have a public key whose fingerprint is E7EA A491 E183 AA96 7629 BD41 F719 7B3B 8B26 9972

To claim this, I am signing this object:

bonsai
rdiscount
<link rel="stylesheet" href="/stylesheets/screen.css">
<link rel="stylesheet" href="/stylesheets/narrow.css" media="screen and (max-width: 44em)">
<link rel="stylesheet" href="/stylesheets/medium.css" media="screen and (min-width: 44em) and (max-width: 65em)">
<link rel="stylesheet" href="/stylesheets/wide.css" media="screen and (min-width: 44em)">
<!--[if (gte IE 6)&(lte IE 8)]>
<link rel="stylesheet" href="/stylesheets/wide.css">
<script src="/javascripts/nwmatcher.min.js"></script>
<script src="/javascripts/selectivizr.min.js"></script>
<![endif]-->