Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/ruby
#
# This script fixes /usr/local only.
#
# 6th January 2010:
# Modified the script to just fix, rather than install. - rpavlik
#
# 30th March 2010:
# Added a check to make sure user is in the staff group. This was a problem
# for me, and I think it was due to me migrating my account over several
@ip2k
ip2k / python_time
Last active August 29, 2015 14:04
#pythonTime
import time, datetime
length=5 # 5 minutes from now
start_time = datetime.datetime.strftime(datetime.datetime.now(), "%Y-%m-%d %H:%M:%S")
stop_time = datetime.datetime.strftime(datetime.datetime.now() + datetime.timedelta(minutes=int(length)), "%Y-%m-%d %H:%M:%S")
epoch_start_local = int(time.mktime(datetime.datetime.now().timetuple()))
epoch_start_utc = int(time.mktime(datetime.datetime.utcnow().timetuple()))
epoch_stop_local = int(time.mktime(datetime.datetime.timetuple(datetime.datetime.now() + datetime.timedelta(minutes=length))))
epoch_stop_utc = int(time.mktime(datetime.datetime.timetuple(datetime.datetime.utcnow() + datetime.timedelta(minutes=5))))
@ip2k
ip2k / index.js
Last active August 29, 2015 14:14
Hipchat plugin for the uptime project - https://github.com/fzaninotto/uptime
/**
* HipChat plugin for the uptime project - https://github.com/fzaninotto/uptime
*
* This index.js files goes to a directory `plugins/hipchat` in your installation of uptime.
*
* Notifies all events (up, down, paused, restarted) to HipChat
*
* This plugin has a dependency on `hipchatter`.
* Add this to the "dependencies" object in your `package.json` file :
*
Usage:
jira (-a|--action) <action> [(-f|--file) <file>] [--encoding <encoding>] [--debug] [-v|--verbose] [--quiet] [--outputFormat
<outputFormat>] [--connectionTimeout <connectionTimeout>] [--sql <sql>] [--driver <driver>] [--url <url>] [--host <host>] [--port
<port>] [--database <database>] [--dbUser <dbUser>] [--dbPassword <dbPassword>] [--propertyFile <propertyFile>] [--common <common>]
[--findReplace <findReplace>] [--findReplaceRegex <findReplaceRegex>] [--list <list>] [--continue] [--simulate] (-s|--server)
<server> (-u|--user) <user> (-p|--password) <password> [--login <login>] [--service <service>] [-l|--loginFromStandardInput]
[--project <project>] [--toProject <toProject>] [--name <name>] [--description <description>] [--lead <lead>] [--defaultAssignee
<defaultAssignee>] [--after <after>] [--issue <issue>] [--toIssue <toIssue>] [--parent <parent>] [--summary <summary>] [--priority
@xphyr
xphyr / index.js
Created July 14, 2013 13:49
Simple Plugin for "Uptime" that send alerts via Pushover. I am not a Node hacker ... I barely understand why this code works .... but it does. I have not tried it with multiple users yet, so dont know if it will work to do multiple notifications. Let me know if you try it.
/**
* Pushover plugin for the uptime project - https://github.com/fzaninotto/uptime
* Thanks to DMathieu for the Campfire plugin which I basically hacked up to make this
* work: https://gist.github.com/dmathieu/5592418
*
* This index.js files goes to a directory `plugins/pushover` in your installation of uptime.
*
* Notifies all events (up, down, paused, restarted) to pushover
*
* This plugin has a dependency on `pushover-notifications`.
@jswank
jswank / queue_checks.json
Created January 8, 2014 17:19
Example Sensu check, which only alerts after 10 failures on a 60 second interval, and won't alert on nights or weekends.
{
"checks": {
"noisy_queue_check": {
"handler": "default",
"command": "/etc/sensu/plugins/check-queue-length.rb",
"interval": 60,
"refresh": 60,
"occurrences": 10,
"subscribers": [
"workers"
@mauvm
mauvm / gist:5de07085f3b51e117378
Created July 26, 2015 11:57
An "envsubst" alternative for replacing env variables in NGinX site configurations (for using it with Docker)
#!/bin/bash
# NOTE: Brackets are not supported and '$' in values will break the script.
mkdir /etc/nginx/sites-enabled 2> /dev/null
for file in /etc/nginx/sites-available/*.conf
do
TPL=$(cat $file)
for row in $(env)
do
@vdcrim
vdcrim / ddc-ci.py
Created February 11, 2015 00:35
Python script for adjusting the settings of my monitor, by using DDC/CI
#!/usr/bin/env python3
"""
Show and adjust display parameters on an Iiyama ProLite XB2483HSU-B1 monitor
Requirements:
- mentioned monitor (27' should also work) with DDC/CI setting on
- Windows Vista+
- Python 3
@simonw
simonw / varnish-jsonp.vcl
Last active May 13, 2021 18:13
Get Varnish to handle JSON-P requests for you
backend default {
.host = "127.0.0.1";
.port = "8000";
}
# We go BACK to varnish to get it to generate an ESI template that
# generates a JSON-P response.
backend jsonp_template_backend {
.host = "127.0.0.1";
.port = "8070";
@daliborgogic
daliborgogic / delay.js
Created December 16, 2016 15:26
Node.js Async/Await delay
'use strict'
const timeout = ms => new Promise(res => setTimeout(res, ms))
function convinceMe (convince) {
let unixTime = Math.round(+new Date() / 1000)
console.log(`Delay ${convince} at ${unixTime}`)
}
async function delay () {