Skip to content

Instantly share code, notes, and snippets.

View x-magic's full-sized avatar
😀
Happy

Bill Haofei Gong x-magic

😀
Happy
View GitHub Profile
@x-magic
x-magic / UptownFunk.sh
Created February 1, 2016 06:51
Use Raspbian, youtube-dl and omxplayer to stream YouTube videos
#!/bin/bash
VARHL='\033[1;33m'
ECHOHL='\033[1;36m'
NC='\033[0m'
URL="https://www.youtube.com/watch?v=OPf0YbXqDm0"
echo -e "${ECHOHL}===== The YouTube URL about to play is: ${VARHL}$URL${NC}"
echo -e "${ECHOHL}===== youtube-dl will now list all possible format for you to choose...${NC}"
#!/bin/sh
DROPBOX_USERS="[put your username here]"
DAEMON=.dropbox-dist/dropboxd
DAEMON_ACTUAL=.dropbox-dist/*/dropbox
start() {
echo "Starting dropbox..."
for dbuser in $DROPBOX_USERS; do
HOMEDIR=`getent passwd $dbuser | cut -d: -f6`
if [ -x $HOMEDIR/$DAEMON ]; then

Boot UEFI CloudReady on ASUS X43U

If BIOS failed to add EFI boot entry to CloudReady automatically after standalone installation, in this case on an ASUS X43U old laptop, do following:

  • Enter BIOS, Boot and select "Add New Boot Option"
  • Enter "Add boot option" and give it a name (like "CloudReady")
  • When you install CloudReady in standalone mode, "Select Filesystem" should have only one option available. Leave it alone
  • In "Path for boot option" type in \efi\boot\bootx64.efi as value
  • Finally select "Create" and then press ESC key back to previous menu
  • Now set "Boot Option #1" to newly created "CloudReady" entry
@x-magic
x-magic / lyrics.php
Last active February 20, 2016 13:41
Download lyrics using geci.me's API @ https://github.com/solos/geci.me-api
<?php
error_reporting(0);
ini_set('display_errors', 0);
/* SQL for `lyrics` table
CREATE TABLE `lyrics` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`title` varchar(256) NOT NULL,
`artist` varchar(256) NOT NULL,
`lrc` varchar(256),
@x-magic
x-magic / Shadowsocks4Debian.sh
Created July 6, 2016 11:25
Automated installation script to install Shadowsocks on Debian Jessie server (perfect for DigitalOcean droplet)
#!/bin/bash
# A script that automates Shadowsocks on a Debian Jessie server
# Perfect for and tested on DigitalOcean 512MB ($5/month) Debian Jessie x64 droplet, as of July 2016
# Since this is modifying systemd servie script so it won't work on Debian Wheezy
# Disable nfs and rpcbind service (this is just for DigitalOcean Debian distros since these services are useless!)
systemctl stop nfs-common > /dev/null 2>&1
systemctl disable nfs-common > /dev/null 2>&1
systemctl stop nfs-common > /dev/null 2>&1
@x-magic
x-magic / mmvmysql.sh
Created August 7, 2016 06:27
Install MySQL in OSX, originally from http://git.io/eUx7rg, fixed the link used in the script (since it point to wrong file and leads the script to fail)
#!/bin/bash
#############################################
# AUTHOR: JONATHAN SCHWENN @JONSCHWENN #
# MAC MINI VAULT - MAC MINI COLOCATION #
# MACMINIVAULT.COM - @MACMINIVAULT #
# VERSION 2.2 RELEASE DATE SEPT 28 2015 #
# DESC: THIS SCRIPT INSTALLS MySQL on OSX #
#############################################
#REQUIREMENTS:
# OS X 10.7 or newer
@x-magic
x-magic / smstools-eventhandler.sh
Created November 19, 2016 06:33
SMS Server Tools 3 event handler script (mainly used for converting messages to UTF-8 encoding, for example, those messages with CJK characters included)
#!/bin/bash
#
# This script processes events from smsd.
# It mainly will converts SMS encoded with UCS2 encoding to UTF-8 format expected by many other applications.
# To use it, edit your /etc/smsd.conf and add the following line:
#
# eventhandler = /path/to/smstools-eventhandler.sh
#
# When a new message is received in /var/spool/incoming/, message files with following header line will be converted:
#
@x-magic
x-magic / ZhihuIgnoreAllInvitation.user.js
Last active February 17, 2018 00:24
一个忽略知乎邀请页单页所有邀请的脚本(怎么读起来这么别扭……)
// ==UserScript==
// @name Zhihu Ignore All Invitation
// @namespace http://www.zhihu.com/
// @version 0.2.1
// @description Add a button to ignore all invitation
// @include http*://www.zhihu.com/question/invited*
// @run-at document-end
// @copyright 2016, x-magic <xmagic5589@gmail.com>
// @updateURL https://gist.githubusercontent.com/x-magic/04c6d7d87f7c934cd1c3fc102d6d8d63/raw/ZhihuIgnoreAllInvitation.user.js
// @downloadURL https://gist.githubusercontent.com/x-magic/04c6d7d87f7c934cd1c3fc102d6d8d63/raw/ZhihuIgnoreAllInvitation.user.js
@x-magic
x-magic / TTGAddPersonalisedCategories.user.js
Last active April 1, 2024 00:25
Add direct link to specific category filter on navbar
// ==UserScript==
// @name TTG Add Personalised Categories
// @namespace https://totheglory.im/
// @version 0.8
// @description Add direct link to specific category filter on navbar
// @include https://totheglory.im/*
// @run-at document-end
// @copyright 2017-2023, x-magic <xmagic5589@gmail.com>
// @updateURL https://gist.githubusercontent.com/x-magic/a9c35a0b29b66c4e645b64a3caad6a2b/raw/TTGAddPersonalisedCategories.user.js
// @downloadURL https://gist.githubusercontent.com/x-magic/a9c35a0b29b66c4e645b64a3caad6a2b/raw/TTGAddPersonalisedCategories.user.js
@x-magic
x-magic / TTGPointsCalculator.user.js
Last active March 16, 2024 05:30
Let me know how long does it takes to get 36,000 points on TTG
// ==UserScript==
// @name TTG Points Calculator
// @namespace https://totheglory.im/
// @version 0.2
// @description Let me know how long does it takes to get 36,000 points on TTG
// @match https://totheglory.im/mybonus.php
// @run-at document-end
// @copyright 2016, x-magic <xmagic5589@gmail.com>
// @updateURL https://gist.githubusercontent.com/x-magic/99035b660bbf180a26ac05c24aa4e861/raw/TTGPointsCalculator.user.js
// @downloadURL https://gist.githubusercontent.com/x-magic/99035b660bbf180a26ac05c24aa4e861/raw/TTGPointsCalculator.user.js