Skip to content

Instantly share code, notes, and snippets.

View dizys's full-sized avatar
🎯
Focusing

Ziyang dizys

🎯
Focusing
View GitHub Profile
@dizys
dizys / iyf_ads_blocker.js
Last active July 17, 2023 13:39
Browser user script for blocking ads on IYF.tv
// ==UserScript==
// @name IYF Ads Blocker
// @namespace https://dizy.cc
// @version 0.2
// @description Ads blocker for iyf.tv
// @author Dizy
// @include /^https:\/\/(.*?)\.iyf\.tv\//
// @icon https://www.google.com/s2/favicons?sz=64&domain=iyf.tv
// @grant GM_log
// @grant unsafeWindow
@dizys
dizys / confusion-matrix.ipynb
Last active December 14, 2022 18:20
Plot a confusion matrix in Jupyter Notebook. A piece of utility code snippet from fastai library.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import re
file1=open("all-OANC.txt",'r')
pattern1=r'(\$[0-9]+(\.[0-9]+)?)'
digit_in_english = f'(?:one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fifteen)'
teens_in_english = f'(?:(?:{digit_in_english}(?:y|ty|teen))|forty|fifty|half +a|a)'
number1_in_english = f'(?:(?:(?:{teens_in_english} +)?{digit_in_english})|{teens_in_english})'
big_numbers = f'(?:million|billion|trillion|hundred|thousand)'
number_in_english = f'(?:(?:{number1_in_english} +{big_numbers} +(?:and +)?)+{number1_in_english}?|{number1_in_english})'
@dizys
dizys / build_gcc_with_offload.sh
Last active November 25, 2022 05:38
Build GCC 11 from source with offloading support.
#!/bin/sh
#
# Build GCC with support for offloading to NVIDIA GPUs.
#
netid=$(whoami)
work_dir=/tmp/$netid/gcc-build
install_dir=/tmp/$netid/gcc
@dizys
dizys / nvidia-blog-printing-mode.js
Created October 20, 2022 02:09
Toggle printing mode for NVIDIA blog website.
function togglePrintMode() {
let inPrintMode = document.querySelector("header").hidden === true;
document.querySelector("header").hidden = !inPrintMode;
document.querySelector(".subscribe-link-wrapper").hidden = !inPrintMode;
document.querySelector(".card--post-attributes").hidden = !inPrintMode;
document.querySelector(".card--post-attributes-secondary").hidden = !inPrintMode;
// document.querySelector(".card--post-attributes-secondary > .post-tags--list").hidden = !inPrintMode;
document.querySelector("#sidebar").hidden = !inPrintMode;
document.querySelector(".entry-content-author").hidden = !inPrintMode;
document.querySelector(".entry-content-comments").hidden = !inPrintMode;
@dizys
dizys / HOWTODMG.md
Created June 2, 2022 18:03 — forked from jadeatucker/HOWTODMG.md
How to create a "DMG Installer" for Mac OS X

Creating a "DMG installer" for OS X

A DMG Installer is convenient way to provide end-users a simple way to install an application bundle. They are basically a folder with a shortcut to the Applications directory but they can be customized with icons, backgrounds, and layout properties. A DMG file (.dmg) is a Mac OS X Disk Image file and it is used to package files or folders providing compression, encryption, and read-only to the package.

##Creating the DMG file #Disk Utility

{
"$id": "http://example.com/example.json",
"$schema": "http://json-schema.org/draft-07/schema",
"default": {},
"description": "JSON schema for cheatsheet note info",
"examples": [
{
"name": "Big-Oh Order",
"description": "Big-Oh Order of expressions",
"icon": "/images/big-oh-order.png"
@dizys
dizys / get-time-difference.js
Created February 12, 2022 23:34
Describe the time difference between a timestamp and now
function getTimeDifference(timestamp) {
let now = new Date();
let difference = now.getTime() - timestamp;
let seconds = Math.floor(difference / 1000);
let minutes = Math.floor(seconds / 60);
let hours = Math.floor(minutes / 60);
let days = Math.floor(hours / 24);
let time = "";
if (days > 0) {
@dizys
dizys / brightspace-assignment-print-mode.js
Last active February 14, 2022 23:35
Print mode for Brightspace Contents and Assignments
function setPrintMode(on) {
let hidden = on;
document
.querySelector(
"#d2l_body > header > nav > d2l-navigation > d2l-navigation-main-header"
)
.shadowRoot.querySelector("div").hidden = hidden;
document
.querySelector(