Skip to content

Instantly share code, notes, and snippets.

@philfreo
philfreo / localstorage_safari_private_shim.js
Last active November 20, 2019 22:49
Don't let localStorage/sessionStorage setItem throw errors in Safari Private Browsing Mode
// Safari, in Private Browsing Mode, looks like it supports localStorage but all calls to setItem
// throw QuotaExceededError. We're going to detect this and just silently drop any calls to setItem
// to avoid the entire page breaking, without having to do a check at each usage of Storage.
if (typeof localStorage === 'object') {
try {
localStorage.setItem('localStorage', 1);
localStorage.removeItem('localStorage');
} catch (e) {
Storage.prototype._setItem = Storage.prototype.setItem;
Storage.prototype.setItem = function() {};
anonymous
anonymous / Spectrum Analyzer
Created April 22, 2014 10:15
Code for Arduino Spectrrum Analyzer
//#define LOG_OUT 1 // use the log output function
#define OCTAVE 1 // use the octave function
#define FFT_N 256 // set to 256 point fft
#define NBR_MTX 2 //Matrix
#include <FFT.h> // include the library
#include "LedControlMS.h"
int val[8];
LedControl lc=LedControl(7,6,5, NBR_MTX);//Configure pins for matrix // 12,11,10,NBR_MTX
void setup() {
@marcedwards
marcedwards / high-dpi-media.css
Last active March 2, 2025 20:24
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 */

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables