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(); }
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 / 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.
$ tree /nix/store/q56a5gs1iq3f9q0afrb2prn5wdxs5392-archiveopteryx-3.2.0
/nix/store/q56a5gs1iq3f9q0afrb2prn5wdxs5392-archiveopteryx-3.2.0
├── bin
│   ├── aox -> /nix/store/q56a5gs1iq3f9q0afrb2prn5wdxs5392-archiveopteryx-3.2.0/usr/local/archiveopteryx/bin/aox
│   ├── aoxdeliver -> /nix/store/q56a5gs1iq3f9q0afrb2prn5wdxs5392-archiveopteryx-3.2.0/usr/local/archiveopteryx/bin/aoxdeliver
│   ├── aoxexport -> /nix/store/q56a5gs1iq3f9q0afrb2prn5wdxs5392-archiveopteryx-3.2.0/usr/local/archiveopteryx/bin/aoxexport
│   ├── aoximport -> /nix/store/q56a5gs1iq3f9q0afrb2prn5wdxs5392-archiveopteryx-3.2.0/usr/local/archiveopteryx/bin/aoximport
│   ├── archiveopteryx -> /nix/store/q56a5gs1iq3f9q0afrb2prn5wdxs5392-archiveopteryx-3.2.0/usr/local/archiveopteryx/sbin/archiveopteryx
│   ├── logd -> /nix/store/q56a5gs1iq3f9q0afrb2prn5wdxs5392-archiveopteryx-3.2.0/usr/local/archiveopteryx/sbin/logd
│   └── recorder -> /nix/store/q56a5gs1iq3f9q0afrb2prn5wdxs5392-archiveopteryx-3.2.0/usr/local/archiveopteryx/sbin/recorder
bn.BUILD_KEY: Dropbox
bn.VERSION: 3.12.4
bn.DROPBOXEXT_VERSION: failed
bn.is_frozen: True
pid: 1414
ppid: 30834
ppid exe: '/nix/store/qgwrxh06c52aj17adg20wc75smg5qlay-zsh-5.0.8/bin/zsh'
uid: 1000
user_info: pwd.struct_passwd(pw_name='phunehehe', pw_passwd='x', pw_uid=1000, pw_gid=1000, pw_gecos='Hoang Xuan Phu,,,', pw_dir='/home/phunehehe', pw_shell='/bin/bash')
effective_user_info: pwd.struct_passwd(pw_name='phunehehe', pw_passwd='x', pw_uid=1000, pw_gid=1000, pw_gecos='Hoang Xuan Phu,,,', pw_dir='/home/phunehehe', pw_shell='/bin/bash')
{-# 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))
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²)
[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 {}