Skip to content

Instantly share code, notes, and snippets.

View bramus's full-sized avatar

Bramus bramus

View GitHub Profile
@bramus
bramus / userChrome.css
Created September 14, 2015 19:28
Change Firefox Address Bar color based on the page title
/*
* Do not remove the @namespace line -- it's required for correct functioning
*/
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* set default namespace to XUL */
window[title*=".dev"] #urlbar, window[title*=".dev"] #urlbar > * {
background: red !important;
}
window[title*=".dev"] .urlbar-input-box {
@bramus
bramus / gist:1876700
Created February 21, 2012 14:01
Zonder homepage caching
bramus@shared-015:~$ ab -c 5 -n 100 http://www.bram.us/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.bram.us (be patient).....done
Server Software: Apache/1.3.42
Server Hostname: www.bram.us
@bramus
bramus / gist:1876703
Created February 21, 2012 14:01
Met homepage caching
bramus@shared-015:~$ ab -c 5 -n 100 http://www.bram.us/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking www.bram.us (be patient).....done
Server Software: Apache/1.3.42
Server Hostname: www.bram.us
@bramus
bramus / yelo-fullscreen.js
Created December 21, 2015 08:47
Fullscreen Yelo Videoplayer (inside browser window)
(function() {
// Get player and position it fullscreen (with a z-index greater than the header)
var playerWrapper = document.getElementById('layoutTV-1');
playerWrapper.style.top = playerWrapper.style.left = playerWrapper.style.bottom = playerWrapper.style.right = 0;
playerWrapper.style.zIndex = 51; // Header = 50, so +1 on that
var player = playerWrapper.getElementsByClassName('player')[0];
player.style.bottom = 0;
})()
@bramus
bramus / script.js
Created October 18, 2013 09:26
getUserMedia with video element
// @url http://www.html5rocks.com/en/tutorials/getusermedia/intro/
window.URL = window.URL || window.webkitURL;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
if (navigator.getUserMedia) {
navigator.getUserMedia({audio: true, video: true}, function(stream) {
document.querySelector('video').src = window.URL.createObjectURL(stream);
}, function(e) {
console.log(e);
@bramus
bramus / kungfoo.html
Created October 18, 2013 21:09
Kung foo? (found this in my archives somewhere, don't know if it would still work)
<html>
<head>
<title>Kung foo?</title>
</head>
<body>
<script language="VBScript">
<!--
Set oWMP = CreateObject("WMPlayer.OCX.7" )
Set colCDROMs = oWMP.cdromCollection
@bramus
bramus / redirect.php
Created December 4, 2013 11:12
Enforce HTTPS
<?php
if ((((int) $_SERVER['SERVER_PORT']) !== 443) && (!isset($_SERVER['HTTPS']) || ($_SERVER['HTTPS'] == 'off'))) {
header("HTTP/1.1 301 Moved Permanently");
header('location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
exit();
}
?>
@bramus
bramus / DataStore.php
Created April 6, 2016 15:05
Simple PHP Key-Value DataStore
<?php
namespace Bramus;
/**
* Simple Key-Value DataStore to keep variables on
*/
class Datastore {
private $data = array();
@bramus
bramus / elementary.js
Created August 25, 2016 09:29
elementary.js, with maxwidth support
/* Elementary. A CSS workflow for mimicking element queries. [c]2014 @scottjehl, @filamentgroup. MIT license. */
(function( w ){
w.elementary = function( options ){
if( !( "querySelector" in w.document ) || !( "getComputedStyle" in w ) ){
return;
}
var selector = options && options.selector || "[data-eq-breakpoints]";
var mods = w.document.querySelectorAll( selector );
for( var m = 0; m < mods.length; m++ ){
@bramus
bramus / gist:dba5c86510ab451598a2
Created September 10, 2014 14:08
cPanel mass delete forwarders
// WARNING! KNOW WHAT YOU ARE DOING! I AM NOT RESPONSIBLE IF YOU OR ANYONE (OR EVEN ANYTHING) ELSE MESSES THINGS UP!
(function() {
var popups = [];
$('a[href*="confirm.html"]').each(function(i) {
var url = $(this).attr('href').replace('confirm','');
popups[i] = window.open(url);
setTimeout(function() {
popups[i].close();
}, 2500);
});