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 / 00-create_local_dns_conf.sh
Created December 29, 2023 02:34
UDM-SE: Boot script to add custom DNS records in dnsmasq
#!/bin/sh
# We'll plug the overriding configurations into /run/dnsmasq.conf.d/
cat > /run/dnsmasq.conf.d/local_custom_dns.conf <<- 'EOF'
# Add an A record to a specific server (i.e. override)
address=/double-click.net/127.0.0.1
# Or a SRV record, if needed
srv-host=_ldap._tcp.example.com,ldapserver.example.com,389
# You can even add MX records as you wish
mx-host=maildomain.com,servermachine.com,50
@x-magic
x-magic / mariadb_tzdata.md
Last active October 8, 2023 12:54 — forked from brianburridge/gist:11298396
How to load MySQL/MariaDB time zone tables from macOS tzdata files

The easiest way to load the MySQL Time Zone tables from your macOS tzdata is via this command:

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

Once the file is imported, you'll need to restart MySQL or MariaDB:

# Determine if you have MySQL or MariaDB
brew list
@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 <haofei.gong@monash.edu>
// @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/;
/ {