Skip to content

Instantly share code, notes, and snippets.

@roelentless
roelentless / gist:5233676
Created March 24, 2013 21:44
A method to group time ranges into time-by-day percentages. Usefull for analysis of time ranges.
##
# Having two times, group the time by dates in percentages.
# Time and analysis will be done in the timezone the time is passed with.
# Result for time range D1-D5:
# D1 |-----D2------------D3------------D4------| D5
# 16.67% 32.34% 32.34% 16.67%
def date_range_group(start_time, end_time)
return nil unless start_time
return nil unless end_time > start_time
total = end_time - start_time
@roelentless
roelentless / README.md
Last active January 10, 2019 18:46
Countdown widget for Dashing

Description

Simple Dashing widget to countdown until a certain moment. Flashes the widget when finished.

##Usage

To use this widget, copy countdown.html, countdown.coffee, and countdown.scss into the /widgets/countdown directory.

To include the widget in a dashboard, add the following snippet to the dashboard layout file:

@roelentless
roelentless / code.md
Last active December 24, 2015 01:59
Interesting code snippets and useful links.
@roelentless
roelentless / tools.md
Last active December 24, 2015 06:09
Useful hammers for some jobs

Databases

  • Neo4j
  • Redis
  • Cassandra
  • MariaDB

Terminal

  • UXterm
@roelentless
roelentless / edu.md
Last active December 24, 2015 06:09
Useful study material

Servers

  • Configure NTP
  • Scheduled automatic diskspace alerts
@roelentless
roelentless / autoupdate
Last active August 29, 2015 14:07
Auto update ubuntu servers
#!/bin/bash
# Put this script in your /etc/cron.daily or schedule it through crontab. It should run as root and have x permissions.
# roelb unattended autoupdate
echo "" >> /var/log/autoupdate
echo "*****" >> /var/log/autoupdate
date >> /var/log/autoupdate
echo "Updating aptitude..." >> /var/log/autoupdate
aptitude update >> /var/log/autoupdate
@roelentless
roelentless / diskspace
Last active August 29, 2015 14:07
A script to warn when disks are getting full
#!/bin/bash
EMAIL="your_email@gmail.com"
WARNING_LEVEL=90
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge $WARNING_LEVEL ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" | mail -s "Alert: Almost out of disk space $usep%" $EMAIL
#!/bin/bash
# Weekly full + daily incrementals of full servers + dbs.
# Cron
# 0 4 * * 6 root bash /scripts/backup full >> /var/log/backup
# 0 4 * * 0,1,2,3,4,5 root bash /scripts/backup >> /var/log/backup
# Configure what folders to backup.
backup_files="/home /etc /root /boot /opt /scripts"