Skip to content

Instantly share code, notes, and snippets.

@coiby
coiby / generate_ima_cert.sh
Last active November 7, 2025 03:16
Generate a pair of IMA certs
#!/bin/bash
# Generate IMA keys. For details, please check,
# https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/managing_monitoring_and_updating_the_kernel/extending-customizing-and-troubleshooting-kernel-integrity-subsystem#creating-custom-ima-keys-using-openssl
cat <<END >> ima_ca.conf
[ req ]
default_bits = 2048
distinguished_name = req_distinguished_name
prompt = no
string_mask = utf8only
@coiby
coiby / Makefile
Created December 26, 2020 13:02
seq_file example
ifndef KDIR
KDIR = /lib/modules/`uname -r`/build
endif
obj-m := hello_world.o
kbuild:
make -C $(KDIR) M=`pwd`
load: kbuild
@coiby
coiby / make test_terminal
Last active June 13, 2020 04:44
vim test
1 FAILED:
Found errors in Test_terminal_syn_pwd():
Run 1:
Caught exception in Test_terminal_syn_pwd(): Vim(call):E121: Undefined variable: Xtopdir @ function RunTheTest[39]..Test_terminal_syn_pwd, line 13
Run 2:
Caught exception in Test_terminal_syn_pwd(): Vim(call):E121: Undefined variable: Xtopdir @ function RunTheTest[39]..Test_terminal_syn_pwd, line 13
Flaky test failed too often, giving up
rofi usage:
rofi [-options ...]
Command line only options:
-no-config Do not load configuration, use default values.
-v,-version Print the version number and exit.
-dmenu Start in dmenu mode.
-display [string] X server to contact.
${DISPLAY}
-h,-help This help message.
@coiby
coiby / dl.py
Created June 2, 2018 10:35
python3 dl.py - Download PPTs on https://sp18.datastructur.es/
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
#
import cgi
from urllib.request import urlopen
from urllib.parse import unquote
import re
def download(url, folder):
  1. use wget to mirror the whote site

     wget -c -r -p -np -nc -k https://sp18.datastructur.es/
  2. extract the links starting with "https://docs.google.com/present" from .html files

@coiby
coiby / Excel.php
Created August 14, 2012 14:24
processing data using PHPExcel
<?php
/**
* process Excel data from Chunpeng
*
* @author Coiby
* @date 2012.7.28
* @version V1
*/
error_reporting(E_ALL);
@coiby
coiby / site_service
Created March 12, 2012 16:54
many-to-many assocation2
I'm using ZF1.11+Doctrine2.
Assume that the user already logged in(using preDispatch method to check whether identity whether exists) and the User entity is stored in session. The user goes to his/her homepage and all the sites and tags(SiteController) belonging to him/her should be listed. The SiteController class has a member $service(Application_Service_Site) through which add site/tag will be done.
Application_Service_Site class has a member $user which is obtained from $session when the class is constructed. Application_Service_Site also has other members, i.e UserSiteTags, Sites, Tags all of which are type of object Collection. These members are provided by Entity Manager.
@coiby
coiby / initialUser.php
Created March 12, 2012 13:07
many-to-many assocation
$user = $session->user;; //get user from session
$site = new Site(); //Could be already given
$term = new Term(); //Could be already given
$UserSiteTerms = $this->em->getRepository('Entities\UserSiteTerm')->find($user->getUid());//find UserSiteTerm according to userId
//foreach $UserSiteTerms
$userSiteTerm[i]->setUser($user);
$user->addUserSiteTerm($userSiteTerm[i]);