Skip to content

Instantly share code, notes, and snippets.

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

@jamesramsay
jamesramsay / README.md
Last active April 26, 2024 13:15
Gmail: delete old emails automatically

Gmail: delete old emails automatically

Automatically deletes old emails that match the specified label.

Get started

  • Create a new Google Apps Script at https://script.google.com
  • Overwrite the placeholder with the javascript below
  • Update the following constants:
  • LABEL_TO_DELETE: the label that should be have old messages deleted
@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)))
@magnetikonline
magnetikonline / README.md
Last active March 16, 2024 02:00
Bash string manipulation cheatsheet.

Bash string manipulation cheatsheet

Assignment
Assign value to variable if variable is not already set, value is returned.

Combine with a : no-op to discard/ignore return value.
${variable="value"}
: ${variable="value"}
@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
@d10v
d10v / tsdb_delete_old.sh
Last active September 13, 2023 05:10
opentsdb delete old data
#!/bin/bash
set -o nounset
set -o errexit
set -o pipefail
EXTRA_TAGS=${1}
TSDB_CMD=$( /usr/bin/which tsdb )
START_TIME="1y-ago"
END_TIME="45d-ago"
@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
@csirac2
csirac2 / disable-partman-hack_preseed.cfg
Last active September 7, 2022 06:34
disable partman from debian preseed
# Thanks to http://ubuntuforums.org/showthread.php?t=1411273 for inspiration..
# But what a disgusting nasty hack! This prevents partman from running (and
# mounts /target, creates /target/etc/fstab). d-i just can't cope with
# installation to partitionless block device... which is disappointing,
# because partitions are pointless for pvlinux guests.
#
# The hack works by ... wait for it... spawning a little while/sleep 1 script,
# waits for the partman-base.postinst file to appear (the preseed/earl_command
# hook is too early, and the partman/early_command is too late). Once it
# appears we replace this with a bit more script which does what we wanted
@randerzander
randerzander / control.sh
Last active November 22, 2022 11:54
Ambari Service Start/Stop script
USER='admin'
PASS='admin'
CLUSTER='dev'
HOST=$(hostname -f):8080
function start(){
curl -u $USER:$PASS -i -H 'X-Requested-By: ambari' -X PUT -d \
'{"RequestInfo": {"context" :"Start '"$1"' via REST"}, "Body": {"ServiceInfo": {"state": "STARTED"}}}' \
http://$HOST/api/v1/clusters/$CLUSTER/services/$1
}