Skip to content

Instantly share code, notes, and snippets.

Jeremie Miserez jmiserez

Block or report user

Report or block jmiserez

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jmiserez / rightclick-element-ios-safari-bookmarklet.js
Last active Oct 22, 2018 — forked from foobear/copy-element-text-bookmarklet.js
JavaScript bookmarklet to right click an element in Safari Mobile. Only works when "Request Desktop Site" is used, tested on 12.0.1. Adapted from (license: MIT).
View rightclick-element-ios-safari-bookmarklet.js
# Bookmarklet on one line:
javascript:(function(){var x=0;var y=0;var overlay=document.createElement('div');Object.assign(,{position:'fixed',top:0,left:0,width:'100vw',height:'100vh',zIndex:99999999,background:'transparent',cursor:'crosshair'});document.body.append(overlay);overlay.addEventListener('click',function(event){Object.assign(,{width:0,height:0});x= event.clientX;y=event.clientY; var element=document.elementFromPoint(x,y);var position=element.getBoundingClientRect();Object.assign(,{background:'rgba(0,128,255,0.25)',outline:'1px solid rgba(0,128,255,0.5)',top:'''px',left:''+position.left+'px',width:''+position.width+'px',height:''+position.height+'px'});setTimeout(function(){var ev1=new MouseEvent("mousedown",{bubbles:true,cancelable:false,view:window,button:2,buttons:2,clientX:x,clientY:y});element.dispatchEvent(ev1);var ev2=new MouseEvent("mouseup",{bubbles:true,cancelable:false,view:window,button:2,buttons:0,clientX:x,clientY:y});element.dispatc
jmiserez /
Last active Jun 12, 2019
Bash on WSL or Cygwin: suspend and resume Windows processes by name and optionally command line part
# Add this to your Cygwin or WSL Ubuntu .bashrc
# Args:
# - process name
# - optional: commandline (use '%' as wildcards)
# Example: suspendps name commandline
# - suspendps notepad.exe %mytextfile.txt%
# - resumeps notepad.exe
# Note: pssuspend64.exe must be installed and available (
getwin32processid() {
# WSL / Windows 10 suitable version without spawning a shell
jmiserez /
Last active Jun 12, 2019
Bash: "Execute for all subdirectories", execute commands in all subdirectorys, cache output and print sequentially with locking
# Add this to your .bashrc and source it (source ~/.bashrc)
# Example: forallsubdirs basedir commands
# - forallsubdirs . "ls | wc -l; git status"
# - forallsubdirs . "git fetch --all; git merge --ff-only"
# Note:
# - To include hidden directories (starting with a "."), set the dotglob option in Bash: shopt -s dotglob
# - Silencing job control (see comments) is only partially possible, in certain cases job control output will still be printed (see
forallsubdirs() {
if [ -d "$1" ]; then
jmiserez / extensions.zotfile.wildcards.user
Created May 27, 2016
Zotero ZotFile Renaming user json for setting: zotfile.wildcards.user. Simplifies series field (remove all non-words, e.g. "PLDI '14" -> "PLDI14") for journal articles and conference papers. Use like this: "{%a_}{%y_}{%1|%w_}{%t}" in ZotFile settings. Also see this bug report:
View extensions.zotfile.wildcards.user
View gist:65450a29fecf9d1e48eba100feaef889
# Make default camera /dev/video0 point to the "best" camera present.
# Source: Jason Eisner
# on question
setdefaultwebcam() {
if [ -h /dev/video0 ]; then
sudo rm /dev/video0 # not first run: remove our old symlink
elif [ -e /dev/video0 ]; then
sudo mv /dev/video0 /dev/video0.original # first run: rename original video0

Keybase proof

I hereby claim:

  • I am jmiserez on github.
  • I am jmiserez ( on keybase.
  • I have a public key ASB1Z3r-6WbG1JJ12os9xUuXhFMe5QElabQLKWD_M29nPQo

To claim this, I am signing this object:

jmiserez / vm.c
Created Jan 6, 2016
X86 (subset) interpreter, prototype. Reads instructions from plaintext file, instructions separated by spaces.
View vm.c
* vm.c - Simple X86 interpreter
* Copyright (c) 2013, Jeremie Miserez <>
* Highlights/Features not specified in assignment
* ===============================================
* - Memory simulation of all 4GB with paging
# Author: Jeremie Miserez <>
# Latest version:
# This script will decrypt encrypted images generated by,
# (, when given a .key.enc file
# and if all related files are in the same directory as the .key.enc file.
jmiserez /
Last active Jan 6, 2016
Offline backup (cold, with shutdown/startup) of a XenServer VM with gzip, rate-limiting (pv), and public key + AES256 encryption (openssl). See ( for decryption. Note: You *must* trust both the remote and local server, as well as the SSH connection.
# Author: Jeremie Miserez <>
# Latest version:
# This script will:
# 1. Connect to a remote XenServer server over SSH
# 2. Shutdown the specified VM
jmiserez /
Last active Oct 6, 2015
Find child processes (and their children, etc.) with one ps call (no race conditions)
# Original idea:
while read pid ppid; do
pids_for_ppid[$ppid]+=" $pid"
done < <(ps -e -o pid,ppid --no-headers)
You can’t perform that action at this time.