Skip to content

Instantly share code, notes, and snippets.

@johnmave126
johnmave126 / whole_foods_link_share.user.js
Created January 25, 2023 23:40
Add a Button To Share Whole Foods Item Link
@johnmave126
johnmave126 / run.sh
Created October 5, 2020 01:29
Convert cue encodings
#!/bin/bash
set -e
# keep track of the last executed command
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap 'echo "\"${last_command}\" command filed with exit code $?."' EXIT
find . -name '*.cue' -print0 |
while IFS= read -r -d '' line; do
type=$(file "$line")
if ! echo $type | grep "with BOM" > /dev/null; then
@johnmave126
johnmave126 / Dockerfile
Created September 30, 2020 19:29
docker-baiduyun
FROM ubuntu:18.04
RUN apt-get update -y && apt-get upgrade -y
RUN apt-get install -y wget locales fontconfig apt-transport-https software-properties-common \
language-pack-zh-hans language-pack-zh-hant language-pack-ja language-pack-en language-pack-ko \
ttf-wqy-microhei fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-mincho fonts-ipafont-gothic fonts-unfonts-core \
xvfb python-numpy \
x264 libx264-dev libvpx5 \
libgtk-3-0 libnotify4 libnss3 libxss1 libxtst6 xdg-utils libatspi2.0-0 \
libappindicator3-1 libsecret-1-0 libasound2
@johnmave126
johnmave126 / .vimrc
Created June 8, 2020 01:37
Yank from vim to clipboard in remote session
# assume yank.sh is located at ~/yank.sh
map <leader>yy :<C-U>silent '<,'>:w !~/yank.sh<CR>:redraw<CR>
@johnmave126
johnmave126 / slider.frag
Created December 24, 2018 19:39
Slider GLSL
#version 120
in float flifespan;
void main() {
gl_FragColor = vec4(1.0f / lifespan, 0, 0, 0);
}
@johnmave126
johnmave126 / better_msssug.meta.js
Last active June 12, 2016 04:46
Add floor and quote to MSSSUG comment system. To install this script, install Tampermonkey first and goto https://gist.github.com/raw/3287b8d85a071b672344614432f97464/better_msssug.user.js
// ==UserScript==
// @name MSSSUG better comments
// @namespace http://youmu.moe/
// @version 0.7
// @description Add floor and quote to MSSSUG comment system
// @author John Tan (johnmave126@gmail.com)
// @match *://ihome.ust.hk/~msssug/*
// @updateURL https://gist.github.com/raw/3287b8d85a071b672344614432f97464/better_msssug.meta.js
// @downloadURL https://gist.github.com/raw/3287b8d85a071b672344614432f97464/better_msssug.user.js
// @grant none
@johnmave126
johnmave126 / floor.user.js
Last active November 18, 2015 08:09
Floor Number
// ==UserScript==
// @name Display Floor Number
// @namespace http://youmu.moe/
// @version 0.1
// @description Display Floor Number in MSSSUG election page
// @author John Tan
// @match http://ihome.ust.hk/~msssug/election_single/*
// @grant none
// ==/UserScript==
/* jshint -W097 */
var restify = require('restify');
// Authentication
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var sessions = require("client-sessions");
var server = restify.createServer();
server.use(restify.queryParser());
server.use(restify.bodyParser({mapParams: false}));
@johnmave126
johnmave126 / file_mapper
Last active December 23, 2015 07:59
Rename file recovered as CHK according to mime-type
application/vnd.lotus-1-2-3 .123
text/vnd.in3d.3dml .3dml
video/3gpp2 .3g2
video/3gpp .3gp
application/octet-stream .a
application/x-authorware-bin .aab
audio/x-aac .aac
application/x-authorware-map .aam
application/x-authorware-seg .aas
application/x-abiword .abw
@johnmave126
johnmave126 / convert.cpp
Created July 5, 2013 09:57
Modify file time on windows
#include <windows.h>
#include <stdio.h>
#include <string.h>
int main(void) {
FILE *fp;
char name[1024];
SYSTEMTIME base_time;
FILETIME base_time_f;
HANDLE fd;