Skip to content

Instantly share code, notes, and snippets.

@lrtfm
lrtfm / globalprotect-connect.scpt
Last active August 16, 2024 19:53
Auto Connect to GlobalProtect VPN (PolyU)
(*
Auto Connect to GlobalProtect VPN of PolyU
GlobalProtect version: 5.2.10-6
*)
set appName to "GlobalProtect"
set appLanguage to getAppLanguage(appName)
if appLanguage starts with "zh-Hans" then
set disconnectLabel to "中断连接"
@lrtfm
lrtfm / beamer-notes-patch.tex
Last active May 22, 2024 14:03
A patch file for beamer with notes options [show notes] and [show notes on second screen] (for XeLaTeX and LuaLaTeX)
% This is a patch for beamer with notes
% Usage:
% Input this file before set the option for notes, e.g.,
%
% \documentclass{beamer}
% \input{beamer-notes-patch}
% \setbeameroption{show notes on second screen=top}
%
% NOTE: This may still have warnings, e.g.,
% xdvipdfmx:warning: Object @linkA already defined.
@lrtfm
lrtfm / firedrake-run
Last active October 4, 2024 09:56
Run command in container of firedrake or firedrake-complex
#!/bin/bash
set -e
TOOL=${TOOL:-docker} # Set TOOL to 'docker' by default. Change it to 'podman' if needed.
BASE_IMAGE=${BASE_IMAGE:-firedrakeproject/firedrake}
RUN_ARGS=${RUN_ARGS:---rm}
if [[ "$TOOL" == "docker" ]]; then
#!/bin/env python3
import os
import sys
if len(sys.argv) < 2:
print('Usage: sys.argv[0] <script>')
exit(0)
scripts = sys.argv[1]
@lrtfm
lrtfm / check-rsh-login.sh
Created March 3, 2018 12:50
检测哪些节点可以正常 rsh 登陆
bhosts | grep ok | cut -d" " -f1 | while read a; do if rsh $a test >/dev/null 2>&1; then echo $a; fi done
@lrtfm
lrtfm / .tmux.conf
Created October 10, 2014 18:38
tmux like vim
unbind C-b
set -g prefix C-a
setw -g mode-keys vi
# split window like vim
# vim's defination of a horizontal/vertical split is revised from tumx's
bind s split-window -h
bind v split-window -v
# move arount panes wiht hjkl, as one would in vim after C-w
bind h select-pane -L
@lrtfm
lrtfm / lisp
Last active August 29, 2015 14:07
tmux + vim + guile for lisp
alias cdnote='cd ~/repo/note-code/note'
alias lisp='if tmux ls 2>/dev/null | grep lisp >/dev/null 2>&1; then tmux a -t lisp ; else tmux new -s lisp \; splitw -l6 guile \; selectp -t 0; fi'
alias note='if tmux ls 2>/dev/null | grep note >/dev/null 2>&1; then tmux a -t note ; else tmux new -s note\; splitw -v -l6 \; selectp -t 0; fi'
<p id="chiristmas" style="font-size: xx-large;">&nbsp;</p>
<script type="text/javascript">// <![CDATA[
var now =new Date();
var new_year = new Date("Dec 25, 2012 0:0:0");
var num_of_yoi = 1+( new_year.getTime() - now.getTime())/ 86400000;
field= document.getElementById('chiristmas');
var yois = "";
@lrtfm
lrtfm / tags.html
Created May 15, 2012 16:36
jekyll tag index
---
layout: def
title: TAGS
---
<div id="tagindex">
{% capture array %}{% for tag in site.tags %}{{ tag | first }}
{% endfor %}{% endcapture %}
{% for tag in array %}
<div id={{tag}} >
@lrtfm
lrtfm / linenumber.js
Created May 11, 2012 16:22
Add line number for text in element "<pre><code>".
//add line num for the code in Elenment "<pre><code>"
function addLineNum()
{
try {
var mycode = document.getElementsByTagName("code");
var space = /^[ \t\b]*$/;
//var times = mycode.length;
for (var loop = 0; loop < mycode.length; ) {
var s = mycode[loop];
var p = s.parentNode;