Skip to content

Instantly share code, notes, and snippets.

View matijs's full-sized avatar
:dependabot:
Scouting turtles

matijs matijs

:dependabot:
Scouting turtles
View GitHub Profile
@matijs
matijs / genpassword.js
Last active December 28, 2015 16:08
Random password generator bookmarklet
javascript:void(function() {
var chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var password = "";
for (var i = 0, length = 64; i < length; ++i) {
password += chars[~~(Math.random() * chars.length)];
}
var input = document.getElementById("f773da90-5044-11e3-8f96-0800200c9a66") || document.createElement("input");
if (!input.id) {
input.id = "f773da90-5044-11e3-8f96-0800200c9a66";
input.setAttribute("style", "background:deeppink;border:2px solid #000;border-radius:.25em;box-shadow:0 0 1em .25em rgba(0,0,0,.5);color:#fff;position:fixed;top:1em;left:1em;font:16px/1 Helvetica,sans-serif;padding:.5em;z-index:9999;opacity:1;transition:opacity .5s;");
@matijs
matijs / changeViewport.js
Created November 16, 2013 12:24
set the viewPort to 1024 if it was
javascript:void(function() {
var metaViewport = document.querySelector("meta[name=viewport]");
if (metaViewport) {
var content = metaViewport.getAttribute("content").replace("device-width","1024");
metaViewport.setAttribute("content", content);
}
})();
@matijs
matijs / create-mavericks-usb.sh
Created October 23, 2013 06:54
Create a OS X Mavericks bootable USB drive
sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointeraction
@matijs
matijs / snippets.sh
Created September 4, 2013 04:43
git snippets
# list deleted files
git log --diff-filter=D --summary
# find last commit that affected a file
git rev-list -n 1 HEAD -- path/to/filename
# restore one specific deleted file
(function() {
var timeouts = [];
var messageName = "zero-timeout-message";
function handleMessage(event) {
if (event.source === window && event.data === messageName) {
event.stopPropagation();
if (timeouts.length > 0) {
var fn = timeouts.shift();
fn();
@matijs
matijs / inlineSVGDetection.js
Created June 4, 2013 22:17
Detect support for inline SVG
(function() {
var div = document.createElement("div");
div.innerHTML = "<svg/>";
return !!div.firstChild && div.firstChild.namespaceURI === "http://www.w3.org/2000/svg";
}());
@matijs
matijs / svgDetection.js
Last active December 18, 2015 02:18
Detect support for SVG
(function() {
return !!document.createElementNS && !!document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect;
}());
@matijs
matijs / animationDetection.js
Last active December 18, 2015 02:18
Detect support for css animations
var hasAnimations = (function() {
var propNames = ["animationName", "MozAnimationName", "webkitAnimationName", "msAnimationName"];
var i = 0;
var length = propNames.length;
for (; i < length; i++) {
if (typeof document.documentElement.style[propNames[i]] === "string") return true;
}
return false;
}());
@matijs
matijs / transistionDetection.js
Last active December 18, 2015 02:18
Detect support for css transitions
var hasTransitions = (function() {
var propNames = ["transition", "MozTransition", "webkitTransition", "OTransition", "msTransition"];
var i = 0;
var length = propNames.length;
for (; i < length; i++) {
if (typeof document.documentElement.style[propNames[i]] === "string") return true;
}
return false;
}());
@matijs
matijs / generatedcontent.js
Last active December 17, 2015 14:19
Generated content feature detection
(function() {
var div = document.createElement("div");
var style = document.createElement("style");
div.id = "d";
style.innerHTML = "#d{position:absolute;left:-999px}#d:before{content:'x';}";
document.documentElement.appendChild(div);
document.documentElement.appendChild(style);
if (div.clientWidth > 0)
document.documentElement.className += " generated-content";
document.documentElement.removeChild(div);