Skip to content

Instantly share code, notes, and snippets.

Hoàng Xuân Phú phunehehe

Block or report user

Report or block phunehehe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@phunehehe
phunehehe / check_urls
Last active Dec 23, 2018
Script to check multiple URLs in Nagios, see http://phunehehe.net/check-multiple-urls-nagios/
View check_urls
#!/bin/bash
# Split URLs by comma
urls=${1//,/ }
for url in $urls
do
hostname="${url%%/*}"
if [[ "$url" = */* ]]
then
@phunehehe
phunehehe / logrotate.conf
Last active Dec 20, 2015
A nice starting point for a logrotate config file
View logrotate.conf
/path/to/*.log {
size 10M
rotate 10
create
compress
delaycompress
dateext
dateformat -%Y%m%d-%s
}
View nrpe-selinux.sh
#!/bin/bash
grep nrpe /var/log/audit/audit.log | audit2allow -M local
semodule -i local.pp
@phunehehe
phunehehe / modules
Created Nov 5, 2013
Manage Chef modules
View modules
name;/path/to/name
View amanda-retry.sh
#!/bin/bash
set -e
monthday="$(date +%-d)"
weekday="$(date +%w)"
if [[ "$monthday" -eq 1 ]]
then
@phunehehe
phunehehe / MyFormModel.php
Last active Dec 30, 2015
Antispam for Yii form
View MyFormModel.php
<?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 {}
View autostart-sync.sh
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
View 10000x10000.txt
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²)
View StrictList.hs
{-# 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))
You can’t perform that action at this time.