Skip to content

Instantly share code, notes, and snippets.

Hoàng Xuân Phú phunehehe

View GitHub Profile
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 / 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.
View existing archiveopteryx tree
$ 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
View dropbox_error9KrtSh.txt
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')
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))
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 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.