Skip to content

Instantly share code, notes, and snippets.

View akihiro's full-sized avatar

Hiroaki Mizuguchi akihiro

View GitHub Profile
#-*- coding: utf-8
Plugin.create :gray_protected_users do
UserConfig[:protected_users_background_color] ||= [0xcccc,0xcccc,0xcccc]
filter_message_background_color do | mp, array |
if mp.to_message.user[:protected] == true
array = UserConfig[:protected_users_background_color]
end
[mp, array]
end
#include <iostream>
// implement
template<class T>
void implement(T t){
t++;
std::cout << t << std::endl;
}
//interface
@akihiro
akihiro / update-gummiboot-multiesp.diff
Last active August 29, 2015 14:14
Debian jessie gummiboot multi esp patch
--- update-gummiboot 2014-07-21 20:38:50.000000000 +0900
+++ update-gummiboot.new 2015-02-01 16:10:59.329668858 +0900
@@ -29,14 +30,16 @@
}
install_kernel() {
- install -D /boot/vmlinuz-$KERNEL $GUMMIBOOT_EFI/$MACHINE_ID/$KERNEL/linux
+ esp=$1
+ install -D /boot/vmlinuz-$KERNEL $esp/$MACHINE_ID/$KERNEL/linux
if [ -e /boot/initrd.img-$KERNEL ]; then
@akihiro
akihiro / lvmcache
Created February 7, 2015 04:49
initramfs-tools lvmcache hooks for / on dm-cache on lvm on dm-crypt on mdadm environment
#!/bin/sh
# original script from http://forums.debian.net/viewtopic.php?f=5&t=119644#p564446
PREREQ="mdadm cryptroot lvm2"
prereqs()
{
echo "$PREREQ"
}
@akihiro
akihiro / keyfile-md0
Created July 18, 2016 09:58
cryptsetup keyscript example
#!/bin/sh
target="${0##*/keyfile-}"
m=
cleanup() {
[ -n "$m" ] && umount "$m" 1>&2
}
init() {
@akihiro
akihiro / index.js
Created July 7, 2017 04:26
default value on javascirpt
function defvalue(fn, v) {
let ret;
try{
ret = fn();
}catch(e){
ret = v;
}
if(ret === undefine){
ret = v;
}
@akihiro
akihiro / Dockerfile
Created October 10, 2018 05:21
small nsd-4.1.25 Dockerfile
FROM buildpack-deps:stretch
ARG VERSION=4.1.25
WORKDIR /usr/src
RUN gpg --recv-keys 9F6F1C2D7E045F8D
RUN curl -sSLO https://www.nlnetlabs.nl/downloads/nsd/nsd-${VERSION}.tar.gz.asc
RUN curl -sSLO https://www.nlnetlabs.nl/downloads/nsd/nsd-${VERSION}.tar.gz
RUN gpg --verify nsd-${VERSION}.tar.gz.asc nsd-${VERSION}.tar.gz
RUN tar xzf nsd-${VERSION}.tar.gz
#!/bin/bash
[[ -z $STATE ]] && export STATE=init
case "$STATE" in
init)
export STATE=unshare
sudo -E unshare -mpf "$0"
# cleanup が不要ならexecでも良い
exit 0
;;
@akihiro
akihiro / gencrt.sh
Created April 20, 2022 15:17
Temporary CA and localhost certificate script
#!/bin/bash
san="DNS:localhost, DNS:localhost.localdomain, IP:127.0.0.1, DNS:app, DNS:app.localdomain"
date=$(date -uI)
openssl genpkey -out tempca.key -outform PEM -algorithm RSA
openssl req -out tempca.csr -key tempca.key -subj "/CN=TempCA$date" -new
openssl x509 -req -days 366 -signkey tempca.key -in tempca.csr -outform der -out tempca.crt
openssl genpkey -out localhost.key -algorithm EC -pkeyopt "ec_paramgen_curve:prime256v1"
openssl req -new -sha256 -key localhost.key -subj "/CN=localhost" -outform pem -out localhost.csr