Skip to content

Instantly share code, notes, and snippets.

View x-magic's full-sized avatar
🙂
Smiling

Bill Haofei Gong x-magic

🙂
Smiling
View GitHub Profile
@x-magic
x-magic / mailtodisk.php
Last active September 16, 2023 23:09
A script to imitate sendmail (to capture mails to be saved locally) for PHP using PHP
<?php
// To use this script, set
// sendmail_path = "/path/to/php /path/to/mailtodisk.php"
// in php.ini
// Set the mail redirect folder path
const MAILTODISK_ROOT = "/opt/mailtodisk/";
// Generate a date/time-based random file name
do {
@x-magic
x-magic / ikea_open_close_remote.yaml
Last active February 15, 2024 18:20 — forked from r3mcos3/ikea_open_close_remote.yaml
Home Assistant Blueprint For ZHA IKEA Open/Close Remote
blueprint:
name: IKEA Open/Close Remote
description: 'Control your roller blind with an IKEA 2 button square remote which comes with "Fytur" or " Kadrilj" roller blinds.'
domain: automation
input:
remote:
name: Remote
description: IKEA remote to use
selector:
device:
@x-magic
x-magic / vlmcsd-deb-build.md
Last active July 10, 2022 04:16
Build Debian package for vlmcsd

Build Debian package for vlmcsd

It turns out vlmcsd already has a Debian buildpackage scripts as a git submodule.

To build the package and install

  1. Clone the vlmcsd git repository with submodules
foo@bar:~$ git clone --recurse-submodules -j8 https://github.com/Wind4/vlmcsd.git vlmcsd/vlmcsd
@x-magic
x-magic / 知乎 - 强行设为暗色主题.user.js
Last active November 14, 2021 03:38
根据网页源代码,很久以前,知乎网页版就已经有了暗色主题。设置项都有了。但官方迟迟不开放使用。等不下去了,先这样了。现已支持切换主题。使用按钮切换主题后,如果页面显示有错误,刷新即可。
// ==UserScript==
// @name 知乎 - 强行设为暗色主题
// @description 根据网页源代码,很久以前,知乎网页版就已经有了暗色主题。设置项都有了。但官方迟迟不开放使用。等不下去了,先这样了。现已支持切换主题。使用按钮切换主题后,如果页面显示有错误,刷新即可。
// @namespace RainSlide
// @author RainSlide
// @icon https://static.zhihu.com/static/favicon.ico
// @version 1.1.1
// @match https://*.zhihu.com/*
// @updateURL https://gist.githubusercontent.com/x-magic/8d3898e5ed51d64814393ab42dbe0673/raw/知乎 - 强行设为暗色主题.user.js
// @downloadURL https://gist.githubusercontent.com/x-magic/8d3898e5ed51d64814393ab42dbe0673/raw/知乎 - 强行设为暗色主题.user.js
@x-magic
x-magic / lms-dashboard.block.html
Created February 16, 2021 05:01
User info finder block code by reusing Moodle Enrolment API
<div>
<input type="text" id="fndr_student_finder_field" class="form-control" placeholder="Type User ID/Email/..." role="textbox" style="max-width: 15em; float: left; margin-right: 1em;" />
<button id="fndr_student_finder_search" type="button" class="btn btn-primary" style="margin-right: 1em;">Search</button>
<div id="fndr_student_finder_results" style="font-family: monospace; float: right;">Click Search button to display results</div>
</div>
<script type="text/javascript">
// <![CDATA[
var fndr_sesskey = document.querySelector('#page-header input[name=sesskey]').value;
var fndr_endpoint = "/lib/ajax/service.php?sesskey=" + fndr_sesskey + "&info=core_enrol_get_potential_users";
var fndr_search_template = '[{"index":0,"methodname":"core_enrol_get_potential_users","args":{"courseid":"___PROVIDE_YOUR_COURSEID___","enrolid":"___PROVIDE_YOUR_ENROLID___","search":"___SEARCHME___","searchanywhere":true,"page":0,"perpage":10}}]';
@x-magic
x-magic / sources.list
Created December 20, 2019 10:05
Simply the sources.list for Debian Buster
deb http://deb.debian.org/debian buster main contrib non-free
deb-src http://deb.debian.org/debian buster main contrib non-free
deb http://deb.debian.org/debian-security/ buster/updates main contrib non-free
deb-src http://deb.debian.org/debian-security/ buster/updates main contrib non-free
deb http://deb.debian.org/debian buster-updates main contrib non-free
deb-src http://deb.debian.org/debian buster-updates main contrib non-free
deb http://deb.debian.org/debian buster-backports main contrib non-free
@x-magic
x-magic / mahara-diary-assistant.user.js
Last active July 28, 2020 04:33
Make Mahara diary marking easier. You will need Greasemonkey/Tampermonkey to make this work. Click "Raw" button on the top-right corner should prompt you to install this script.
// ==UserScript==
// @name Mahara Diary Assistant
// @namespace https://mahara.infotech.monash.edu.au/mahara/
// @version 0.5.2
// @description Make diary marking easier
// @author Bill Gong <[email protected]>
// @match https://mahara.infotech.monash.edu.au/mahara/*
// @require https://cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js
// @updateURL https://gist.githubusercontent.com/x-magic/70f26bdc5217e77fa42ffab010ebba05/raw/mahara-diary-assistant.user.js
// @downloadURL https://gist.githubusercontent.com/x-magic/70f26bdc5217e77fa42ffab010ebba05/raw/mahara-diary-assistant.user.js
@x-magic
x-magic / usbotg2host.dts
Created August 10, 2019 11:36
Device Tree overlay to enable OTG host on Orange Pi Zero
/*
* Device Tree overlay to enable OTG host on Orange Pi Zero
* Tested on Armbian Buster latest
* Run 'armbian-add-overley usbotg2host.dts' in root to use
*/
/dts-v1/;
/plugin/;
/ {
@x-magic
x-magic / darkgmailsidebarinvert.user.css
Created May 31, 2019 08:07
Google Gmail sidebar invert color Dark Night Mode Theme
/* ==UserStyle==
@name Google Gmail sidebar invert color Dark Night Mode Theme
@namespace https://mail.google.com/mail
@version 1.1.5
@description Google Gmail sidebar invert color Dark Night Mode Theme - currently undergoing build
@author Someone
@updateURL https://gist.githubusercontent.com/x-magic/78af8328f233bd1d05b622693637bbe8/raw/darkgmailsidebarinvert.user.css
==/UserStyle== */
/* Originally from https://greasyfork.org/en/scripts/371510-google-gmail-sidebar-invert-color-dark-night-mode-theme */
@x-magic
x-magic / PoGDesignTVCalendarFooterMarginRemover.user.css
Created May 31, 2019 08:05
PoGDesign TV Calendar footer margin remover
/* ==UserStyle==
@name PoGDesign TV Calendar footer margin remover
@namespace https://www.pogdesign.co.uk/cat/
@version 0.1.1
@description The title is load and clear!
@author Some random guy
@updateURL https://gist.githubusercontent.com/x-magic/c229752bb8d8dc9b82208dd2250573ce/raw/PoGDesignTVCalendarFooterMarginRemover.user.css
==/UserStyle== */
/*