Skip to content

Instantly share code, notes, and snippets.

View joar's full-sized avatar
:bowtie:
Not wearing a bowtie

Joar Wandborg joar

:bowtie:
Not wearing a bowtie
View GitHub Profile

How I accidentally my Ubuntu installation

I was running a vanilla Ubuntu 13.10 installation improved with GNOME Shell and gdm.

Up popped a small window on my screen telling me about Trusty Tahr, I clicked OK. The Trusty Tahr window disabled some PPAs and started downloading the fresh trusty packages, then setting them up. Somewhere in the middle of the setting up Tahr spoke to me that an error had occured and that the system migth well be unusable. Behind the words i could see that dpkg was wailing over a read-only filesystem.

The Trusty Tahr was right. As I rebooted my laptop cryptsetup told me there was an error with the disk. After some digging and fscking I went and bought a new disk.

Using a Fedora Live CD I set up the new disk with two partitions, one 243MB ext2 for boot and one btrfs for root and ran cp -av /media/old/* /media/new.

@joar
joar / gunicorn+werkzeug-behind-nginx.nginxconf
Last active August 29, 2015 14:00
How to get rid of 127.0.0.1 in your generated links
server {
# [...]
location / {
set $backend_url 'http://127.0.0.1:8000';
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass $backend_url;
@joar
joar / better-underlines.less
Created December 3, 2014 15:15
LESSCSS: Better underlines
/* Adapted to LESS from https://github.com/at-import/toolkit/blob/2.x.x/stylesheets/toolkit/_underline.scss */
.better-underline(@background; @color; @underline-width: 3; @underline-distance: 2) {
@px: .0625em;
text-decoration: none;
background-image: linear-gradient(to top, @background 75%, @color 75%);
background-size: (2 * @px) ((1 + @underline-width) * @px);
background-position: 0 ((@underline-width) * @px) + @underline-distance;
background-repeat: repeat-x;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
set -o verbose
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl -L https://www.npmjs.org/install.sh | sh
@joar
joar / base_conversion.py
Last active August 29, 2015 14:14
Convert an integer to an arbitrary base, with examples
def to_base(integer, base_list=None):
"""
Convert an integer to an arbitrarily-represented arbitrary-base number
system.
The base representation must be defined in the `base list` parameter.
The base is taken from the length of the list.
:param integer: Base 10 int()
:type integer: int()
@joar
joar / award-notes.md
Last active August 29, 2015 14:16
The Crew - Notes

Ownership / Body / Good on the Inside

Drive 8.05 km in all cars using bumper view

Notes

  • Inside cam doesn't count.
  • Test drive at a car dealership works, might need two rounds (i.e 4 to 6 laps).
@joar
joar / fizzbuzz.py
Last active August 29, 2015 14:19
Simple FizzBuzz in Python. Just kidding.
import os; exec('def count_to_a_hundred():\n\tcursor = 1; max_ = 100;\n\twhile True:\n\t\tif not cursor <= max_:\n\t\t\traise StopIteration\n\t\tyield cursor; cursor += 1', globals(), locals()); open(os.path.join(os.path.dirname('__file__'), 'out.txt'), 'w').write('\n'.join([str('FizzBuzz' if (i % 5 == 0 and i % 3 == 0) else 'Buzz' if i % 5 == 0 else 'Fizz' if i % 3 == 0 else i) for i in count_to_a_hundred()]));
@joar
joar / transcode-avi.sh
Last active August 29, 2015 14:21
GStreamer multiple output transcoding with deduplication of media streams.
#!/bin/bash
# Note: use x264enc tune=zerolatency or bigger queues
# NOT WORKING! stalled at prerolling
gst-launch-1.0 filesrc location=VfE.webm ! decodebin name=dmux \
dmux. ! videoconvert ! tee name=vo \
dmux. ! audioconvert ! tee name=au \
webmmux name=webm ! progressreport name=webmprogress ! filesink location=out.webm \
avimux name=avi ! progressreport name=aviprogress ! filesink location=out.avi \
vo. ! queue ! vp8enc ! webm. \
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.