Skip to content

Instantly share code, notes, and snippets.

@phunehehe
phunehehe / slack-timesheet-bookmarklet.md
Last active March 1, 2024 19:45
Slack Timesheet Bookmarlet

Create a browser bookmark with the following code as the URL, name it Slack Timesheet or something

javascript:(async function() {
  allMessages = [];
  while (true) {
    buttons = document.getElementsByClassName('c-search__expand');
    buttons = Array.from(buttons);
    for (b of buttons) { b.click(); }
@phunehehe
phunehehe / remove-gpg-user.sh
Last active March 31, 2022 09:02 — forked from glogiotatidis/remove-gpg-user.sh
Git-crypt remove user.
#!/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 / organize.sh
Created August 21, 2011 14:59
Organize files by file extension
#!/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 August 18, 2020 06:23
Philesight on Ubuntu

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 / 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
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 March 7, 2018 02:10
Settings for Mutt to test SES

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
[twistd]
user munin
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 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 {}