Skip to content

Instantly share code, notes, and snippets.

View bofrede's full-sized avatar

Bo Frederiksen bofrede

View GitHub Profile
@bofrede
bofrede / disable_support.js
Last active May 3, 2018 11:40
Disable all styles in a @supports rule.
function disable_support(supports_condition) {
for (var si = 0; si < document.styleSheets.length; si++) {
window.console.log("Looking in " + document.styleSheets[si].href);
var rules = document.styleSheets[si].cssRules;
for(var i = 0; i < rules.length; i++) {
if (rules[i].type === 12 && rules[i].conditionText.match(supports_condition)) {
window.console.log("Removing style index " + i);
document.styleSheets[0].deleteRule(i);
}
}
@bofrede
bofrede / disable_keys.sh
Last active January 19, 2018 12:30
Disable keyboard keys on Linux.
# Back
xmodmap -e 'keycode 166='
# Forward
xmodmap -e 'keycode 167='
# Caps-lock
xmodmap -e 'keycode 66='
@bofrede
bofrede / postman-upgrade.sh
Last active January 4, 2018 10:56
Script to upgrade Postman on Linux
#!/usr/bin/env bash
# Derived from: https://blog.bluematador.com/posts/postman-how-to-install-on-ubuntu-1604/
wget https://dl.pstmn.io/download/latest/linux64 -O ~/Downloads/postman.tar.gz
sudo rm -rf /opt/Postman
sudo tar -xzf ~/Downloads/postman.tar.gz -C /opt
rm ~/Downloads/postman.tar.gz
# sudo ln -s /opt/Postman/Postman /usr/bin/postman
@bofrede
bofrede / config-initializers-solidus_fixes.rb
Created March 23, 2017 13:34
Fixes for Solidus with Solidus Globalize
require 'spree/product'
require 'solidus_globalize/fallbacks'
module Spree
Product.class_eval do
# Fix for method not found find_by_slug
def self.find_by_slug(slug)
translation = Product::Translation.find_by_slug(slug)
find(translation.spree_product_id)
end
@bofrede
bofrede / gist:9846e0c1d063bdf9b44e
Created May 17, 2014 11:40
disable_java_sponsors.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft]
"SPONSORS"="DISABLE"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft]
"SPONSORS"="DISABLE"
@bofrede
bofrede / chef_solo_bootstrap.sh
Last active December 17, 2015 12:08 — forked from ryanb/chef_solo_bootstrap.sh
Script to run on a new Linux server, to prepare for Chef.
#!/usr/bin/env bash
# Run this script, as root, on a prestine server, with:
# sudo su
# curl -L https://gist.githubusercontent.com/bofrede/5607048/raw/chef_solo_bootstrap.sh | bash
apt-get -y update
apt-get -y install software-properties-common lib64readline-gplv2-dev
apt-get -y install build-essential zlib1g-dev lib64z1-dev libssl-dev libyaml-dev libxml2-dev libxslt1-dev libffi-dev
echo 'gem: --no-rdoc --no-ri' > /etc/gemrc
ln -s /etc/gemrc ~/.gemrc
add-apt-repository ppa:brightbox/ruby-ng
@bofrede
bofrede / html_export.rb
Last active February 8, 2017 16:22
Export Word documents as HTML
=begin
This script requires a Ruby intepeter to run:
http://rubyinstaller.org/
This script also requires Microsoft Windows and Microsoft Word to be installed.
A few libraries, used by this script:
HTML Sanitizer:
https://github.com/rgrove/sanitize/
@bofrede
bofrede / hack.sh
Created April 10, 2012 20:33 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env bash
##
# This is a script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# Download and auto-run with:
# $ curl -sL https://raw.github.com/gist/2108403/hack.sh | bash
#
# or download and prompt before change defaults:
@bofrede
bofrede / sl_gems_update.rb
Created December 28, 2009 16:24 — forked from mattetti/sl_gems_update.rb
List gems using C extensions
#!/usr/bin/env ruby
puts "looking for the gems to upgrade..."
gem_info = Struct.new(:name, :version)
to_reinstall = []
Dir.glob('/Library/Ruby/Gems/**/*.bundle').map do |path|
path =~ /.*1.8\/gems\/(.*)-(.*?)\/.*/
name, version = $1, $2
bundle_info = `file path`
to_reinstall << gem_info.new(name, version) unless bundle_info =~ /bundle x86_64/
end
@bofrede
bofrede / debug.js
Last active September 4, 2015 00:55
Debug function that works on all browsers.
function debug(aMsg) {
if (window.console) {
window.console.log(aMsg);
} else if (window.dump) {
window.dump(aMsg + '\n');
} else {
setTimeout(function () {
throw new Error('[debug] ' + aMsg);
}, 0);
}