Skip to content

Instantly share code, notes, and snippets.

@phunehehe
phunehehe / check_urls
Last active December 23, 2018 00:54
Script to check multiple URLs in Nagios, see http://phunehehe.net/check-multiple-urls-nagios/
#!/bin/bash
# Split URLs by comma
urls=${1//,/ }
for url in $urls
do
hostname="${url%%/*}"
if [[ "$url" = */* ]]
then
@phunehehe
phunehehe / logrotate.conf
Last active December 20, 2015 03:09
A nice starting point for a logrotate config file
/path/to/*.log {
size 10M
rotate 10
create
compress
delaycompress
dateext
dateformat -%Y%m%d-%s
}
#!/bin/bash
grep nrpe /var/log/audit/audit.log | audit2allow -M local
semodule -i local.pp
@phunehehe
phunehehe / modules
Created November 5, 2013 09:28
Manage Chef modules
name;/path/to/name
#!/bin/bash
set -e
monthday="$(date +%-d)"
weekday="$(date +%w)"
if [[ "$monthday" -eq 1 ]]
then
@phunehehe
phunehehe / MyFormModel.php
Last active December 30, 2015 05:59
Antispam for Yii form
<?php
/*
* Prevent automated POST (actually non-GET) requests by checking a form
* attribute set by JavaScript, in the hope that spammers will not execute
* JavaScript.
*
* Usage:
* 1. Extend MyFormModel instead of CFormModel
* class ContactForm extends MyFormModel {}
for i in $(virsh list | grep running | awk '{print $2}')
do
virsh autostart $i
done
for i in $(virsh list --all | grep 'shut off' | awk '{print $2}')
do
virsh autostart --disable $i
done
[twistd]
user munin
benchmarking repmat/useRepmat whnf
time 112.9 ms (111.7 ms .. 113.7 ms)
1.000 R² (1.000 R² .. 1.000 R²)
mean 113.3 ms (112.8 ms .. 113.9 ms)
std dev 724.5 μs (504.6 μs .. 955.7 μs)
variance introduced by outliers: 11% (moderately inflated)
benchmarking repmat/useReplicate whnf
time 101.6 ms (99.19 ms .. 104.0 ms)
0.999 R² (0.996 R² .. 1.000 R²)
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE TypeFamilies #-}
module Data.StrictList where
import qualified Control.Foldl as L
import qualified GHC.Exts
import Control.Foldl (Fold (Fold))