Skip to content

Instantly share code, notes, and snippets.

@andyduke
andyduke / main.dart
Last active December 31, 2018 13:23
Flutter ORM prototype 2
class DB {
static DB _instance = null;
factory DB() {
if (_instance == null) _instance = DB._internal();
return _instance;
}
DB._internal();
@andyduke
andyduke / main.dart
Last active December 29, 2018 15:50
Dart i18n prototype
class i18nText {
final String text;
i18nText(this.text);
String toString() {
return text;
}
String format() {
@andyduke
andyduke / main.dart
Last active December 29, 2018 15:23
Dart ORM Prototype
class Article extends _Article<Article> {
int get id;
Article();
factory Article.fromMap(Map<String, dynamic> map) = _Article.fromMap;
//factory Article.fromMap(Map<String, dynamic> map) {
// return new Article().update(map);
@andyduke
andyduke / check_nfs_mount.sh
Created April 7, 2018 22:59
Check NFS mount
COUNT=`df -k | grep /mnt | wc -l`
#Change your mountpoint according to your requirement
#Mount -a read /etc/fstab so make sure you have proper entry for the same (linux)
if [ $COUNT = 0 ]; then
date >> /var/log/messages
echo NFS MOUNTS ARE dead
echo NFS is dead >> /var/log/messages
echo Remounting Mounts
sleep 2
/bin/mount -a
@andyduke
andyduke / mount-raspbian-image
Last active April 2, 2018 15:22
Locally mounting a Raspberry Pi Raspbian Linux image
#!/bin/bash
#
# Usage: sudo ./mount-raspbian-image <imagename> <mount_path>
#
if [ -z "$1" ] || [ -z "$2" ]
then
echo "Usage: sudo ./mount-raspbian-image <imagename> <mount_path>"
exit
fi
@andyduke
andyduke / simple-dlna-browser
Created June 26, 2017 14:28
cli browse upnp-av based media servers by javier-lopez
#!/bin/sh
#description: browse upnp-av based media servers by javier-lopez
#usage: simple-dlna-browser [options] [pattern]
#example:
#$ simple-dlna-browser "Video file"
#http://192.168.1.254:8200/MediaItems/22.mp4
_usage() {
printf "%s\\n" "Usage: ${progname} [options] [pattern]"
@andyduke
andyduke / Debian-OMV-read-only.md
Last active January 26, 2018 18:49
Debian OMV on Read-only root

Setting up a read-only root partition on Debian with OMV installed

To switch the root partition to read-only mode, and the system and OMV work correctly, you must use overlayfs, which is supported in the linux 3.18 kernel. I used a slightly modified script (root-ro) for Raspberry Pi by Pascal Rosin https://gist.github.com/niun/34c945d70753fc9e2cc7

To save the OMV changes, I created an omv-apply-config script that remount the lowerdir of overlayfs into read-write mode, synchronize the config.xml and exec omv-mkconf via chroot, then remount the lowerdir of overlayfs back to read-only mode.

To run omv-mkconf through omv-apply-config, I made a PHP wrapper class \ROPatch\Process (process.inc) and a script (start.inc) to use this class instead of \OMV\System\Process, this script is loaded via php conf.d, using the auto_prepend_file parameter, so this should not break when updating the OMV.

@andyduke
andyduke / root-ro
Last active June 21, 2017 14:07 — forked from niun/root-ro
Read-only Root-FS with overlayfs for Raspian
#!/bin/sh
#
# Read-only Root-FS for Raspian
#
# Modified 2015 by Pascal Rosin to work on raspian-ua-netinst with
# overlayfs integrated in Linux Kernel >= 3.18.
#
# Originally written by Axel Heider (Copyright 2012) for Ubuntu 11.10.
# This version can be found here:
# https://help.ubuntu.com/community/aufsRootFileSystemOnUsbFlash#Overlayfs
@andyduke
andyduke / tweak-omv-settings.sh
Created May 22, 2017 11:01
NanoPi NEO2 OMV Tweaks by tkaiser (May 22nd, 2017)
#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# cpufreq settings
echo -e "OMV_CPUFREQUTILS_GOVERNOR=ondemand" >>/etc/default/openmediavault
echo -e "OMV_CPUFREQUTILS_MINSPEED=240000" >>/etc/default/openmediavault
echo -e "OMV_CPUFREQUTILS_MAXSPEED=912000" >>/etc/default/openmediavault
apt install -y cpufrequtils
echo -e "ENABLE=true\nMIN_SPEED=240000\nMAX_SPEED=912000\nGOVERNOR=ondemand" >/etc/default/cpufrequtils
sed -i '/^exit\ 0/i \
@andyduke
andyduke / hdd-spindown.sh
Created May 17, 2017 11:51
Check for idle disks and spin them down, run this from cron every 30 mins
#!/bin/bash
# hdd-spindown.sh
#
# Automatic Disk Standby using Kernel diskstats and hdparm
# 2011-2015 by Alexander Koch <lynix47@gmail.com>
# configuration file, (ba)sh-style
CONFIG="/etc/hdd-spindown.rc"