Skip to content

Instantly share code, notes, and snippets.

View block-flash-writes.txt
Adobe Flash LSO (Local Shared Objects) are like super-cookies that never expire and cannot be removed by browsers.
The Flash plugin installed in your system allows sites to write/share sensitive informations on your hard disk.
These are the simple info I currently have on how to make folders immutable on *NIX OS (Mac and Linux).
I have not been able to make immutable folders on my Windows XP VM maybe because I only use FAT32.
It seems that Windows allows you to lock files and folders on NTFS volumes only (I miss the info).
The following are the location of the folder that should be made immutable on each OS,
View ie-inject-style-rules.js
// this is how I fixed IE6-8 crashing on
// dynamic insertion of at-rules inside
// stylesheets (for example @font-face)
// Fix by MS, move up the style insertion
// before the stylesheet rule manipulation
function setStyle(rules) {
var d = document,
View gist:489591
// TODO: should probably convert result to plain array (since different engines return different things -- arrays, nodelists, objects, etc.)
var query = (function() {
var engine, engines = ',base2.dom.querySelectorAll,Sizzle,$$,$,YAHOO.util.Selector.query,dojo.query,'.split(',');
while ((engine = engines.shift())) {
if (Function('try{return ' + engine + '}catch(e){}')()) {
return Function('cssExpr, ctx', 'ctx || (ctx = document);return ' + engine + '(' +
(engine.indexOf('base2') > -1 ? 'ctx, cssExpr' : 'cssExpr, ctx') + ')');
return 'querySelectorAll' in document ?
View ie-early-clientCaps.js
<title>IE capabilities detection (clientCaps)</title>
<script type="text/javascript">
var r = document.documentElement, capabilities;
capabilities =
View js2png.php
* Author: Diego Perini <>
* this is what I have in my build system to embed
* the packed version of NWMatcher in a PNG file;
* actually any data like JSON or XML can be
* transported in compressed PNG files and
* avoids HTTP compression requirements.
View regex-weburl.js
// Regular Expression for URL validation
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
// Copyright (c) 2010-2018 Diego Perini (
View readfile.js
* readfile.js - Spidermonkey/V8 readfile wrapper
* Author: Diego Perini <>
* Released under the Creative Commons license:
dperini / snippets-compression
Created May 25, 2011
Comparison between manual and automated minification/compression
View snippets-compression
Testing on code snippet at:
Note: used "gzip -n9 file" on Mac to do this comparison.
Not very readable, minifier obsoleted & gzip makes size grow
dperini / loadFT.js
Created Aug 23, 2011
Feature testing browser support for 'load' events
View loadFT.js
<script type="text/javascript">
// 'load' events should be supported by every browser
// this was just an exercise to find a way to test it
var isLoadSupported = 'onload' in window, loadHandler = window.onload;
document.createElement('body').setAttribute('onload', 'return');
isLoadSupported = isLoadSupported || typeof window.onload == 'function';
window.onload = loadHandler;
dperini / has_load_capture_support.js
Created Jun 25, 2013
Here is an example on how to feature detect an Asynchronous event using a Synchronous event. Being able to capture 'load' events of each resource in a web page is a very interesting feature. All resources could be logged, or modified with just one 'load'' capturing event handler. This works for external link elements (CSS), for iframes, images, …
View has_load_capture_support.js
* Feature detect support for capturing load events
* Author: Diego Perini
* Updated: 2013/06/25
* the feature test can be performed before
* both 'load' and 'DOMContentLoaded' events