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 / 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 / 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";
}());
(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 / 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
@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 / 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 / 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 / scrollbarsize.js
Last active December 30, 2015 21:39
calculate the size of the scrollbar
var scrollbarSize = (function() {
var inner = document.createElement( "div" ),
outer = document.createElement( "div" );
inner.style.width = "100%";
inner.style.height = "60px";
outer.style.position = "absolute";
outer.style.top = "0";
outer.style.left = "0";
outer.style.visibility = "hidden";
outer.style.width = "50px";
@matijs
matijs / README.md
Last active June 13, 2019 09:03
Instructions and example configuration to install BitTorrent Sync on a Raspberry Pi running Arch Linux.

Installing BitTorrent Sync on a Raspberry Pi running Arch Linux

The commands below assume you're using a user that can use sudo, you're not logged in as root are you!?

First create a btsync user:

sudo useradd -M --shell /bin/false --home /var/lib/btsync
@matijs
matijs / postforms.js
Last active August 29, 2015 13:57 — forked from adactio/postforms.js
/*
Show a progress element for any form submission via POST.
Prevent the form element from being submitted twice.
*/
(function ( win, doc ) {
'use strict';
if ( !win.addEventListener ) {
// doesn't cut the mustard.
return;
}