Skip to content

Instantly share code, notes, and snippets.

View gdlmx's full-sized avatar

Mingxuan Lin gdlmx

View GitHub Profile
@gdlmx
gdlmx / pyproject.toml
Last active June 24, 2024 06:10
Split pdf file into chunks of pages
[build-system]
requires = ["hatchling>=1.24.2", "hatch-vcs>=0.3.0"]
build-backend = "hatchling.build"
[project]
name = "pdfsplit"
description = ""
readme = "README.md"
license = "MIT"
requires-python = ">=3.11"
@gdlmx
gdlmx / GoogleDocAutoplay.js
Last active October 6, 2023 02:07
Google Doc autoplay
var jumpto = (i , n)=>{
var evt = new Event("blur", {"bubbles":true, "cancelable":false});
var sldnr = document.querySelector('input.a-b-La-su-vb') ;
sldnr.value = `${i}`;
console.log(`jumping to ${i}, ${n} , ${sldnr.getAttribute('aria-label')}`);
sldnr.dispatchEvent(evt);
if(i<n){
setTimeout(() => {
jumpto(i+1, n);
}, 1500);
@gdlmx
gdlmx / calc_crc32.py
Created March 20, 2023 16:36
Create memory view of file larger than RAM
import mmap
import zlib
import sys
from contextlib import contextmanager
@contextmanager
def f2bytes(fname):
with open(fname, 'rb') as f :
with mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as m:
mmview = memoryview(m)
@gdlmx
gdlmx / Check_spark_env.py
Last active February 12, 2023 13:54
Scripts for spark on Windows
" check env variables "
# pylint: disable=invalid-name,line-too-long
import os
import pathlib
import subprocess
import logging
logging.basicConfig(level=logging.INFO, format='%(message)s' )
paths_should_exist: list[str]=[
'{DOTNET_ROOT}/dotnet.exe',
@gdlmx
gdlmx / CentOS9-gnome-patch.cil
Last active September 14, 2022 13:17
SELinux debug log in CentOS9
(allow staff_t lib_t (file (watch)))
(allow staff_t non_security_file_type (dir (watch)))
(allow staff_gkeyringd_t pidfile (file (getattr open read)))
@gdlmx
gdlmx / Qlik JS API.md
Last active August 23, 2022 17:58
Qlik SaaS Web Integration Notes

Summary of Qlik API

Capability API

Reference

Nebula.js

    import { embed } from '@nebula.js/stardust';
@gdlmx
gdlmx / save_bookmarks.py
Created July 18, 2020 02:44
Export Firefox bookmarks
import sqlite3, pandas as pd
conn = sqlite3.connect('places.sqlite')
tinfo= pd.read_sql_query("SELECT * FROM pragma_table_info('moz_places')", conn)
cols = [ 'p.'+c for c in tinfo.name if 'id' not in c ]
tinfo = pd.read_sql_query("SELECT * FROM pragma_table_info('moz_bookmarks')", conn)
cols += [ 'b.'+c for c in tinfo.name if 'id' not in c and 'title' not in c ]
tbmk = pd.read_sql_query("SELECT {0} FROM moz_bookmarks b INNER JOIN moz_places p ON b.fk = p.id".format( ', '.join(cols) ),
conn);
for c in tbmk:
@gdlmx
gdlmx / CompileMTEX.sh
Last active March 9, 2020 13:50
Compile MTEX with NFFT
#!/usr/bin/bash
# https://github.com/mtex-toolbox/mtex/blob/develop/extern/nfft/readme.md
# https://github.com/mtex-toolbox/mtex/tree/develop/extern/nfft_openMP
# https://www-user.tu-chemnitz.de/~potts/nfft/download.php
set -e
MTEX_HOME=$(echo "$PWD"/mtex-*.*.*/)
MATLAB_HOME=$(dirname $(dirname $(which matlab)))
@gdlmx
gdlmx / reindex_micress_vtk.py
Created June 13, 2019 13:05
Preprocessing scripts for MICRESS
import numpy as np
import re, sys
def reindex_micress_vtk(vtkfilename):
pLUT = re.compile('\s*LOOKUP_TABLE\s+', flags=re.I)
headers=[]
with open(vtkfilename) as f:
for l in f:
headers.append(l.strip())
if pLUT.match(l):
break
@gdlmx
gdlmx / Jupyterlab_build.sh
Last active May 15, 2019 11:13
Jupyterlab admin scripts
# Build JS files for production
export NODE_OPTIONS="--max-old-space-size=4096"
jupyter-lab build --LabBuildApp.dev_build=False