Skip to content

Instantly share code, notes, and snippets.

Avatar

Hoàng Xuân Phú phunehehe

View GitHub Profile
@phunehehe
phunehehe / organize.sh
Created Aug 21, 2011
Organize files by file extension
View organize.sh
#!/bin/sh
# Organize files by file extension
# Written in answer to http://unix.stackexchange.com/q/19110/250
# Configuration (feel free to add your types and change the path)
DOCUMENTS='
pdf
doc
'
@phunehehe
phunehehe / philesight-ubuntu.md
Last active Aug 18, 2020
Philesight on Ubuntu
View philesight-ubuntu.md

Install dependencies

sudo apt-get install libdb4.2-ruby1.8 libcairo-ruby1.8

Install Philesight

git clone https://github.com/phunehehe/philesight.git
@phunehehe
phunehehe / remove-gpg-user.sh
Last active Sep 25, 2019 — forked from glogiotatidis/remove-gpg-user.sh
Git-crypt remove user.
View remove-gpg-user.sh
#!/usr/bin/env bash
#
# Script to remove GPG key from git-crypt
#
# It will re-initialize git-crypt for the repository and re-add all keys except
# the one requested for removal.
#
# Note: You still need to change all your secrets to fully protect yourself.
# Removing a user will prevent them from reading future changes but they will
# still have a copy of the data up to the point of their removal.
@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
View main.tf
resource aws_elasticache_replication_group single {
node_type = "cache.m3.medium"
number_cache_clusters = 1
port = 6379
replication_group_description = "single-test"
replication_group_id = "single-test"
subnet_group_name = "staging"
}
resource aws_elasticache_replication_group cluster {
@phunehehe
phunehehe / mutt-ses.md
Last active Mar 7, 2018
Settings for Mutt to test SES
View mutt-ses.md

Change the email address to the verified sender address. By default Mutt doesn't use the envelope address, resulting in the email getting rejected because of unverified address.

set from = 'Amazing Tester <tester@amazing.com>'
set smtp_pass = 'xxx'
set smtp_url = 'smtps://xxx@email-smtp.xxx.amazonaws.com'
set use_envelope_from = yes
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
@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 amanda-retry.sh
#!/bin/bash
set -e
monthday="$(date +%-d)"
weekday="$(date +%w)"
if [[ "$monthday" -eq 1 ]]
then
You can’t perform that action at this time.