Skip to content

Instantly share code, notes, and snippets.

View chris-marsh's full-sized avatar

Chris Marsh chris-marsh

View GitHub Profile
@chris-marsh
chris-marsh / .bashrc
Created January 30, 2018 10:31
Xubuntu default .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@chris-marsh
chris-marsh / twoline_prompt.sh
Created November 2, 2017 17:00 — forked from mkottman/twoline_prompt.sh
A two-line colored Bash prompt (PS1) with Git branch and a line decoration which adjusts automatically to the width of the terminal. Recognizes SVN, Git and Fossil version control systems and shows the current branch/revision.
# A two-line colored Bash prompt (PS1) with Git branch and a line decoration
# which adjusts automatically to the width of the terminal.
# Recognizes and shows Git, SVN and Fossil branch/revision.
# Screenshot: http://img194.imageshack.us/img194/2154/twolineprompt.png
# Michal Kottman, 2012
RESET="\[\033[0m\]"
RED="\[\033[0;31m\]"
GREEN="\[\033[01;32m\]"
BLUE="\[\033[01;34m\]"
@chris-marsh
chris-marsh / qtextdocument_printing.cpp
Created October 15, 2017 09:59
Qt Paginated Printing
// QTextDocument printing example written by David Faure for EADS
// Compared to QTextDocument::print, it allows to add a page header and footer.
#include <QPrinter>
#include <QPainter>
#include <QProgressDialog>
#include <QApplication>
#include <QTextDocument>
#include <QTextTableCell>
#include <QTextCursor>
@chris-marsh
chris-marsh / print_table.py
Created October 13, 2017 14:55
PyQt5 - Print paginated QTableWidget
from PyQt5 import QtWidgets, QtCore, QtPrintSupport, QtGui
class Window(QtWidgets.QWidget):
def __init__(self):
QtWidgets.QWidget.__init__(self)
self.setWindowTitle(self.tr('Document Printer'))
self.table = QtWidgets.QTableWidget(200, 5, self)
for row in range(self.table.rowCount()):
for col in range(self.table.columnCount()):
@chris-marsh
chris-marsh / colors.sh
Created March 15, 2017 16:47
Shell color script taken from Manjaro's .bashrc
colors() {
local fgc bgc vals seq0
printf "Color escapes are %s\n" '\e[${value};...;${value}m'
printf "Values 30..37 are \e[33mforeground colors\e[m\n"
printf "Values 40..47 are \e[43mbackground colors\e[m\n"
printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n"
# foreground colors
for fgc in {30..37}; do
@chris-marsh
chris-marsh / obsidian.vim
Last active February 16, 2017 15:51
Obsidian color scheme for vim
" Obsidian Maintainer: Trevor John <trevorrjohn@gmail.com>
" Source: http://github.com/tjohn/vim-obsidian
if has("gui_running")
set background=dark
endif
hi clear
if version > 580
if exists("syntax_on")
syntax reset
@chris-marsh
chris-marsh / instance.c
Created January 26, 2017 22:55
Only open a unique instance of an application.
include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/file.h>
#include <sys/wait.h>
#define TRUE 1
#define FALSE 0
@chris-marsh
chris-marsh / send_sig.c
Last active January 25, 2017 16:43
ANSI std C89/99 to send kill signals using system
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
void send_sig(int pid, int sig)
{
char exec_str[128];
@chris-marsh
chris-marsh / singleton.c
Created January 23, 2017 22:46
POSIX solution of a dual-role daemon, i.e. a single application that can act as daemon and as a client communicating with that daemon.
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <sys/socket.h>
#include <sys/un.h>
@chris-marsh
chris-marsh / .vimrc
Last active December 18, 2023 19:37
My vimrc Without plugins
set nocompatible
filetype off
set shell=/bin/bash
set hidden " opening new file hides current instead of closing
set nowrap " switch off line wrapping
set tabstop=4 " Set tabs to 4 characaters wide
set shiftwidth=4 " Set indentation width to match tab
set expandtab " Use spaces instead of actual hard tabs
set softtabstop=4 " Set the soft tab to match the hard tab width