Skip to content

Instantly share code, notes, and snippets.

@ammgws
ammgws / htpc_setup_notes.md
Last active January 19, 2018 13:53
Notes on how I setup HTPC for future reference

1. Preparation / OS Install

  • Create liveusb using Ubuntu mini.iso dd bs=4M if=/home/user/Downloads/mini.iso of=/dev/sdf status=progress; and sync in fish shell

  • During install will be prompted for what to install: choose xubuntu minimal and openssh server

  • This time left just one disk (8TB) in the case, and used LVM when partitioning: root given 15gb, data partition given the rest (set recovery-blocks to 1% and inode to largest size since this is just a media partition)

2. Creating a user with limited privileges for Kodi

Setup PGP

~/.gnupg/gpg.conf use SHA512 over default SHA256

personal-digest-preferences SHA512
cert-digest-algo SHA512
default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
personal-cipher-preferences TWOFISH CAMELLIA256 AES 3DES
@ammgws
ammgws / unifi_ubuntu_lxc_install.md
Last active January 23, 2019 11:15
Steps to install Unifi 5.6.29 in a Ubuntu 16.04 unpriveleged LXC
@theskumar
theskumar / app.py
Created November 17, 2014 06:47
Database diagram using sqlalchemy
# -*- coding: utf-8 -*-
''' Generates database schema graph from a relational database.
Usages:
Add database configuation in this file and then
python app.py
Note: You must have your latest database schema in the database
engine you are running against.
'''
from __future__ import unicode_literals, absolute_import
@adymitruk
adymitruk / conways-game-of-life.fish
Last active April 28, 2020 07:48
Conway's game of life in fishshell
set DEAD " "; set LIVE "🌱"; set wid 21; set hei 21
for cell in b(seq 2)r(seq $hei)c(seq $wid); set -g $cell $DEAD; end
set -g flip 1; set -g flop 2
function show_board
for row in (seq $hei); for col in (seq $wid); set -l cell b{$flip}r{$row}c{$col}; echo -n $$cell
end; echo; end; end
set b1r10c10 $LIVE; set b1r10c11 $LIVE; set b1r10c12 $LIVE;
set b1r11c10 $LIVE; set b1r11c12 $LIVE;
set b1r12c10 $LIVE; set b1r12c11 $LIVE; set b1r12c12 $LIVE;
while true
@czardoz
czardoz / background_flask.py
Created April 21, 2015 10:45
Simple Flask app with a background task using gevent
import gevent
import gevent.monkey
gevent.monkey.patch_all()
from gevent.pywsgi import WSGIServer
from flask import Flask
app = Flask(__name__)
app.debug = True
@noborus
noborus / gist:7516369
Last active March 25, 2021 10:06
iBus(1.4)をD-Busで操作する方法

iBus(1.4)をD-Busで操作する方法

iBusはD-Busを通信プロトコルに使用しているため、外からもD-Busで制御することが出来る。 しかしながら、D-Busが一般に使用するSystem Bus と Session Busとは違うBusを使用するため、ちょっと注意が必要になる。

iBus1.5からはデスクトップ環境に統合されることを前提に変更されているため、ここではその変更前のバージョンを対象とする。

iBusのD-Busに接続するための接続情報

iBusのD-Busに接続するための接続するには IBUS_ADDRESSが必要になる。IBUS_ADDRESSは通常 iBusを起動しているユーザーの

@hmanicka
hmanicka / app.py
Last active April 30, 2021 15:22
Flask-Admin: To update timestamp with timezone field with UTC
import pytz
class MyView(MyModelView):
# Display the time in user's local timezone on the List View
column_formatters =
dict(scheduledtime=lambda v,c,m,p: m.scheduledtime.replace(tzinfo=pytz.utc).astimezone(tz=pytz.timezone(config.LOCAL_TIMEZONE)))
# Display the time in user's timezone on the Edit View
def edit_form(self, obj):
form = self._edit_form_class(get_form_data(), obj=obj)
@vodik
vodik / rez-x
Last active November 23, 2021 20:54
startx alternative
#!/bin/bash
# startx
# Alternative, simpler startx which makes use of the XDG specification
# - assumes dbus is already running
[[ -n "$DISPLAY" ]] && exit 0
[[ -z "$XDG_VTNR" ]] && exit 1
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
@gak
gak / fish-prompt.sh
Last active February 4, 2022 18:34
My custom fish prompt code explained at http://geraldkaszuba.com/tweaking-fish-shell/
function _common_section
printf $c1
printf $argv[1]
printf $c0
printf ":"
printf $c2
printf $argv[2]
printf $argv[3]
printf $c0
printf ", "