Skip to content

Instantly share code, notes, and snippets.

View fdevibe's full-sized avatar

Fredrik de Vibe fdevibe

View GitHub Profile
@fdevibe
fdevibe / .bashrc
Created May 1, 2025 15:08
Add newline to bash prompt if the last output didn't end with one
# This won't work in PS1, as inside PS1, newlines
# in command substitutions are handled specially.
# Hence, using PROMPT_COMMAND instead.
__conditional_newline() {
IFS='[;' read -rsd R -p $'\e[6n' _ _ col
if [ -n "$col" ] && [ "$col" -gt 1 ]; then
echo -e "\033[01;31m\\missing newline\033[00m"
fi
}
@fdevibe
fdevibe / i3-urgent-notify.py
Created October 20, 2016 11:58
Send desktop notifications on window urgency hints on i3
#! /usr/bin/env python
import i3ipc
import pgi
pgi.require_version('Notify', '0.7')
from pgi.repository import Notify
i3conn = i3ipc.Connection()
Notify.init('Urgent!')
@fdevibe
fdevibe / Users-seed-example.js
Last active November 13, 2021 15:24
Dumb, straightforward seeding Sequelize data. Feel free to improve. :-)
var _ = require('lodash'),
fs = require('fs'),
path = require('path'),
csv = require('csv'),
Sequelize = require('sequelize');
function addUser(db, filename, rolesByName, addresses) {
var parser = csv.parse({}, function (err, data) {
db.models.User.bulkCreate(
_.map(data, function (record, index) {