Skip to content

Instantly share code, notes, and snippets.

@SaveTheRbtz
SaveTheRbtz / README
Last active November 25, 2016 14:29
Locality-Based Least-Connection Scheduling module for nginx
Locality-based Least connection scheduling module for nginx.
Based on logic[1] from IPVS lblc module.
[1] http://kb.linuxvirtualserver.org/wiki/Locality-Based_Least-Connection_Scheduling
Configuration directives:
lblc
@cescoffier
cescoffier / my-vertx-application
Last active February 26, 2018 18:52
Vert.x init.d service script
#!/bin/bash
###
# chkconfig: 345 20 80
# description: Vert.x application service script
# processname: java
#
# Installation (CentOS):
# copy file to /etc/init.d
# chmod +x /etc/init.d/my-vertx-application
@jonathan-beebe
jonathan-beebe / ruby-rails-erb-comments.erb
Created February 20, 2014 19:06
Comment lines in ruby rails html.erb files, as answered on StackOverflow http://stackoverflow.com/a/3901665/123781
To comment a single line use
<%-# commented line -%>
This also works
<%# my comment %>
To comment a whole block use a if false to surrond your code like this
@fkleon
fkleon / temperature.sh
Created August 3, 2013 18:27
FreeBSD / FreeNAS script to send a status report containing CPU and HDD temps and status to a given email address. Tested on FreeNAS 9.1.0-RELEASE (based on FreeBSD 9-STABLE). Based on the script available at http://forums.freenas.org/threads/how-to-monitor-system-cpu-hdd-mobo-gpu-temperatures-on-freenas-8.2994/#post-38847.
#! /usr/local/bin/sh
# Write email header to temp file
(
echo "To: your@email"
echo "Subject: System Temperatures INFO"
echo " "
) > /var/cover
# Define adastat function, which writes drive activity to temp file
@sunjon
sunjon / deptree
Last active March 2, 2019 17:01
Chef Recipe include/dependency checker
#!/usr/bin/env bash
# Senghan Bright
# Delta Projects
REPO_ROOT=$HOME/repos/chef-repo
COOKBOOK_DIRECTORIES=(cookbooks community_cookbooks forked_cookbooks)
COLOR_COOKBOOK=(131 165 151)
COLOR_DELIMITER=(215 153 32)
@pudquick
pudquick / warranty_update.py
Last active March 10, 2019 11:49
Casper warranty estimation, stored locally at /Library/Preferences/com.apple.warranty - in python!
#!/usr/bin/python
import os.path, subprocess, datetime, dateutil.parser, time, sys
def apple_year_offset(dateobj, years=0):
# Convert to a maleable format
mod_time = dateobj.timetuple()
# Offset year by number of years
mod_time = time.struct_time(tuple([mod_time[0]+years]) + mod_time[1:])
# Convert back to a datetime obj
return datetime.datetime.fromtimestamp(int(time.mktime(mod_time)))
@pudquick
pudquick / warrantydate.py
Last active March 10, 2019 11:49
A simple estimated warranty date output script - calculates date as manufacture date of your Mac + 3 years
#!/usr/bin/python
import sys, datetime, time
def apple_year_offset(dateobj, years=0):
# Convert to a maleable format
mod_time = dateobj.timetuple()
# Offset year by number of years
mod_time = time.struct_time(tuple([mod_time[0]+years]) + mod_time[1:])
# Convert back to a datetime obj
return datetime.datetime.fromtimestamp(int(time.mktime(mod_time)))

Notifications from Resources "Bubble Up"

Release in Chef 12.9.41 via PR #4741 core chef now has a feature which has been available in Poise for awhile, which is that notifications from within resources will now notify resources in outer run contexts. This means you can write a recipe with a service resource and send a notification to it from a resource that you write.

Notifications will bubble up from arbitrarily nested resources, so users that write resources that wrap resources which wrap your resource will still find the service resource in your default recipe.

At the same time the resources collection #find() and #lookup methods and the more commonly-used DSL method resources("service[ntpd]") has been changed to also match

#!/usr/bin/env ruby
# <bitbar.title>GitHub Notifications</bitbar.title>
# <bitbar.version>v1.0.0</bitbar.version>
# <bitbar.author>mig</bitbar.author>
# <bitbar.author.github>migrs</bitbar.author.github>
# <bitbar.desc></bitbar.desc>
# <bitbar.image></bitbar.image>
# <bitbar.dependencies>ruby</bitbar.dependencies>
# <bitbar.abouturl>https://github.com/migrs</bitbar.abouturl>
@prebenlm
prebenlm / .A how to display Irssi-hilights in OS X Notification Center.md
Last active August 12, 2019 08:54
Guide: how to make irc messages in a screen on a remote server appear in your Mac OS X Lion Notification Center with the help of terminal-notifier

Irssi in Mac OS X Notification Center

Mou icon

Overview

This guide will explain how you can make irc messages in a screen on a remote server appear in your Mac OS X Lion Notification Center with the help of terminal-notifier.

We will also explain how the process can be automatically started each time you log in to your Mac and ensure the connection to the server is kept alive.