Skip to content

Instantly share code, notes, and snippets.

@pelsedyr
pelsedyr / commit-msg.py
Last active June 5, 2024 18:40
Prepend formatted branch name to commit messages
#!/usr/bin/env python
import sys, os, re
from subprocess import check_output
file_path = sys.argv[1]
# Get branch name
branch_name = check_output([
'git',
'symbolic-ref',
'--short',
'-q',
@pelsedyr
pelsedyr / dnf.conf
Last active August 18, 2021 20:17
/etc/dnf/dnf.conf
fastestmirror=True
max_parallel_downloads=10
defaultyes=True
@pelsedyr
pelsedyr / regex.txt
Last active October 17, 2015 10:02
Some regex to remember
([a-zøæåA-ZØÆÅ0-9]+) //Letters and digits no spaces
([a-zøæåA-ZØÆÅ0-9 ]+) //Same as above but with spaces
([a-zøæåA-ZØÆÅ0-9 ]+) //Same as above but with spaces
@pelsedyr
pelsedyr / qimg_image_conv.cpp
Created April 25, 2015 09:16
Conversion between QImage and Magick::Image. Tested and reliable.
Image* MainWindow::toImage(QImage* qimage)
{
qDebug() << "toImage:" << qimage->width() << qimage->height();
Image *newImage = new Image(Magick::Geometry(qimage->width(), qimage->height()), Magick::ColorRGB(0.5, 0.2, 0.3));
double scale = 1 / 256.0;
newImage->modifyImage();
Magick::PixelPacket *pixels;
Magick::ColorRGB mgc;
@pelsedyr
pelsedyr / qmake_image_magic_ex.pro
Last active August 29, 2015 14:19
Eksempel over en pro fil for qt creator som fungerer.
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET =
TEMPLATE = app
SOURCES +=
HEADERS +=
@pelsedyr
pelsedyr / ssd_trim.sh
Last active August 29, 2015 14:17
Cron trim file for ssd with log output. Tested on Fedora 21.
# !/bin/bash
LOG=/var/log/trim.log
echo "***$(date -R)***" >> $LOG
{
fstrim -v /
fstrim -v /home
fstrim -v /boot
} >> $LOG
@pelsedyr
pelsedyr / .vimrc
Last active August 29, 2015 14:14
My .vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
@pelsedyr
pelsedyr / fstrim cron.daily
Last active August 29, 2015 14:13
A Cron script that invokes daily run of fstrim and writes out results to a log.
#!/bin/sh
#Egen script for å kjøre fstrim og skrive ut resultatet til en log
LOG=/var/log/trim.log
echo "Starting trim $(date -R) " >> $LOG
fstrim -v / >> $LOG
fstrim -v /home >> $LOG
fstrim -v /boot >> $LOG