Skip to content

Instantly share code, notes, and snippets.

@bivald
bivald / safe_format_and_mount.sh
Created September 30, 2016 10:23
safe_format_and_mount
#! /bin/bash
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@bivald
bivald / htpasswd.py
Created April 25, 2016 08:04 — forked from eculver/htpasswd.py
htpasswd script in python (no need to install apache utils)
#!/usr/bin/env python
"""Replacement for htpasswd"""
# Original author: Eli Carter
import os
import sys
import random
from optparse import OptionParser
# We need a crypt module, but Windows doesn't have one by default. Try to find
@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
@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 / 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 / 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 / prioritize-ipv4.sh
Created January 27, 2014 13:58
Prioritize ipv4 over ipv6
echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf
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
--- /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;
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