Skip to content

Instantly share code, notes, and snippets.

View ahgood's full-sized avatar

Guojun ahgood

  • Fullstack Developer
  • Halifax
View GitHub Profile
@ahgood
ahgood / tsconfig.json
Created January 20, 2023 17:34 — forked from thatisuday/tsconfig.json
A simple TypeScript configuration file to be used with Webpack.
{
"compilerOptions": {
"noImplicitAny": true,
"target": "ES5",
"module": "ES2015"
}
}
@ahgood
ahgood / bing-daily-wallpaper.sh
Last active July 14, 2022 18:45 — forked from SamanSh999/changebg.sh
A shell script to set Bing Background as wallpaper automatically on macOS(2022) (requires wget & jq)
#!/usr/bin/env bash
#
# Credit: https://gist.github.com/SamanSh999/3ee8cad2859a900b7e36e1cff4204005
#
# Instruction(macOS only):
#
# 1. Save this script to your home folder
# 2. Grant permission to script: chmod +x ~/bing-daily-wallpaper.sh
# 3. Install homebrew if you don't have it: https://brew.sh/
# 4. Install jq: brew install jq
@ahgood
ahgood / detect-available-fonts.js
Created August 17, 2021 13:37 — forked from fijiwebdesign/detect-available-fonts.js
Detect available fonts with JS
/**
* JavaScript code to detect available availability of a
* particular font in a browser using JavaScript and CSS.
*
* Author : Lalit Patel
* Website: http://www.lalit.org/lab/javascript-css-font-detect/
* License: Apache Software License 2.0
* http://www.apache.org/licenses/LICENSE-2.0
* Version: 0.15 (21 Sep 2009)
* Changed comparision font to default from sans-default-default,
@ahgood
ahgood / index.js
Created January 13, 2020 15:34
Goolge Actions Simulator Helper
// step 1, edit the code:
document.querySelector('.f8r-title').append('🎩');
setInterval(() => {
const cards = document.querySelectorAll("MD-CARD-CONTENT");
cards.forEach((card) => {
if (card.querySelector("img") === null && card.querySelector("a.say") === null) {
const sayTag = document.createElement("a");
sayTag.className = "say";
@ahgood
ahgood / getVideos.js
Created November 13, 2019 01:54
Get all youtube videos ids for specified username
const request = require("request");
const apiKey = "...";
const youtubeUserName = "...";
let videos = [];
let playlistId;
console.log("Getting videos...");
// Get playlist ID
@ahgood
ahgood / extractURLs.js
Created October 29, 2019 19:25
Extract URLs from content
const regxURL = new RegExp(`(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])`, 'igm');
const content = 'Hello www.google.com World http://yahoo.com';
const urls = content.match(regxURL); // ["www.google.com", "http://yahoo.com"]
1. Run from Ubuntu(one time)
sudo apt install virtualbox-guest-x11
2.
sudo mount -t vboxsf Share /var/www/html
OR add to startup:
$ umask # Get umask
0022
$ id # Get uid & gid
@ahgood
ahgood / msmtp.sh
Created March 11, 2019 21:15 — forked from mikesmullin/msmtp.sh
install msmtp gmail, a localhost sendmail alternative
# setup msmtp for sending out email
# as an alternative to sendmail
# i prefer this because it is easier to install and configure than sendmail
# especially when using Gmail smtp servers
sudo -i
apt-get install msmtp
ln -s /usr/bin/msmtp /usr/sbin/sendmail
touch /var/log/msmtprc && chmod 666 /var/log/msmtprc
vim /etc/msmtprc
# config options: http://msmtp.sourceforge.net/doc/msmtp.html#A-user-configuration-file
@ahgood
ahgood / encrypt-decrypt.php
Created December 10, 2018 21:25
Common PHP encrypt decrypt
// encrypt
function encrypt(string $data, string $key, string $method) {
$encrypted = openssl_encrypt($data, $method, $key, OPENSSL_RAW_DATA);
$encrypted = base64_encode($encrypted);
return $encrypted;
}
// decrypt
function decrypt(string $data, string $key, string $method) {
$data = base64_decode($data);
import React, { Suspense, useState } from "react";
import { unstable_createResource as createResource } from "react-cache";
import {
Autocomplete as Combobox,
Input as ComboboxInput,
List as ComboboxList,
Option as ComboboxOption
} from "./Combobox";
function App({ tabIndex, navigate }) {