Skip to content

Instantly share code, notes, and snippets.

@bivald
bivald / ie9-console-fix.js
Created August 22, 2013 19:24
Avoid `console` errors in browsers that lack a console.
// Source: https://github.com/h5bp/html5-boilerplate/blob/master/js/plugins.js
// Avoid `console` errors in browsers that lack a console.
(function() {
var method;
var noop = function () {};
var methods = [
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
@bivald
bivald / hide-fixed-on-zoom.html
Last active December 21, 2015 20:49
Hide a fixed element (navigation/menu) on zoom (so iOS doesn't distort or alter the menu). iOS could use gesture as well, but touch *should* work better for Android as well. UPDATE: Haven't tried Android, so added an if iOS check
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Never Denim</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
xen-create-image --hostname site.se --ip XX.XX.X.XXX --dist wheezy --dir /home/xen --memory 512Mb --size 15gb --swap 1024Mb --gateway XX.XX.XX.XX --netmask 255.255.255.0 --passwd --role=udev --accounts --vifname=yourdomain --vcpus=1
--- /home/niklas/xen/xen-unpatched/xen/tools/ioemu-remote/hw/xen_disk.c 2013-11-28 13:22:15.000000000 +0100
+++ /home/niklas/xen/xen/tools/ioemu-remote/hw/xen_disk.c 2013-11-27 11:59:23.000000000 +0100
@@ -116,6 +116,31 @@
/* ------------------------------------------------------------- */
+static void ioreq_reset(struct ioreq *ioreq)
+{
+ memset(&ioreq->req, 0, sizeof(ioreq->req));
+ ioreq->status = 0;
import flask
import jinja2
app = flask.Flask(__name__)
my_loader = jinja2.ChoiceLoader([
app.jinja_loader,
jinja2.FileSystemLoader('/path/to/extra/templates'),
])
app.jinja_loader = my_loader
@bivald
bivald / prioritize-ipv4.sh
Created January 27, 2014 13:58
Prioritize ipv4 over ipv6
echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf
@bivald
bivald / photoshop-to-css.sass
Created March 7, 2014 09:02
Sass mixin to convert photoshop line-height to CSS, photoshop letter-spacing to CSS
/* Reset rem to 10-based instead of default browser 16 */
html {
font-size: 62.5%;
}
/*
Photoshop does not apply line height to the first row, which CSS does. This creates all kinds of havock.
To calculate the correct offset for the first line we need the font-size and the lineheight, i.e:
@include line-height(22,30);
@bivald
bivald / ffmpeg.sh
Last active November 6, 2020 11:27
FFmpeg commands
# TO MP4 (with quicktime/windows media player support)
# Convert to 720 MP4 (roughly 7MB for 30 seconds)
ffmpeg -i input.mp4 -s hd720 -c:v libx264 -crf 23 -c:a aac -strict -2 -pix_fmt yuv420p output.mp4
# Convert to 1080 MP4 (roughtly 60MB for 30 seconds) - high resolution, but not RAW
ffmpeg -i input.mp4 -s hd1080 -c:v libx264 -crf 23 -c:a aac -strict -2 -pix_fmt yuv420p output.mp4
# Animated gif to mp4
ffmpeg -i input.gif -strict -2 -pix_fmt yuv420p output.mp4
@bivald
bivald / signal-strength.sh
Created April 11, 2014 10:05
Signal strength, mac
# Signal strength:
while x=1; do /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep agrCtlRSSI | awk '{print "Signal strength: "$2}' ; sleep 0.5; done
# BSSID
while x=1; do /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | grep BSSID; sleep 0.5; done
# Speed
ping www.google.se
@bivald
bivald / gist:86e0d119bce54d01fabe
Created September 26, 2014 12:54
Walker grey out folders
import os
from xattr import xattr
from sys import argv, stderr
directory = './walker'
child_was_empty = None
last_depth = None
#from https://github.com/danthedeckie/display_colors/blob/master/display_colors.py