Skip to content

Instantly share code, notes, and snippets.

View ZCG-coder's full-sized avatar

Andy Zhang ZCG-coder

View GitHub Profile
@ZCG-coder
ZCG-coder / CL.md
Created June 22, 2024 13:43
Computer Literacy study notes (F2 Final Exam)

                            COMPUTER LITERACY
                           ===================

                              Revision Notes
                            Final Examination


@ZCG-coder
ZCG-coder / log.py
Last active May 9, 2024 12:42
A Pythonic way to take a n-th root without using math
#####################################################################################################
# Copyright (c) 2023-2024 NWSOFT #
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy #
# of this software and associated documentation files (the "Software"), to deal #
# in the Software without restriction, including without limitation the rights #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #
# copies of the Software, and to permit persons to whom the Software is #
# furnished to do so, subject to the following conditions: #
# #
@ZCG-coder
ZCG-coder / LICENSE
Last active April 29, 2024 04:38
AST way to evaluate an expression Step-by-step
MIT License
Copyright (c) 2024 Andy Zhang
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@ZCG-coder
ZCG-coder / decimal_conversion.py
Last active April 12, 2024 13:13
Python script to convert decimals to any bases and back
NAMES = {
2: "binary",
3: "trinary",
4: "quaternary",
8: "octadecimal",
10: "decimal",
16: "hexadecimal"
}
@ZCG-coder
ZCG-coder / A%20File%20Icon.sublime-settings
Last active July 22, 2024 13:24
My Sublime Configuration
// A File Icon Preferences – User
// ================================================================
{
"color": "hsl(219, 28%, 88%)",
"color_on_hover": "hsl(0, 0%, 97%)",
"color_on_select": "hsl(0, 0%, 100%)"
}
@ZCG-coder
ZCG-coder / main.py
Created February 5, 2022 11:12
Fisher-Yates Shuffle
import random
def shuffle(ary):
old_ary = ary[:]
a = len(ary)
b = a - 1
for d in range(b, 0, -1):
e = random.randint(0, d - 1)
ary[d], ary[e] = ary[e], ary[d]
@fnky
fnky / ANSI.md
Last active July 22, 2024 12:03
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@Firsh
Firsh / lwp-cloudflare-dyndns.sh
Last active July 2, 2024 02:55
Cloudflare as Dynamic DNS
#!/bin/bash
# Cloudflare as Dynamic DNS
# From: https://letswp.io/cloudflare-as-dynamic-dns-raspberry-pi/
# Based on: https://gist.github.com/benkulbertis/fff10759c2391b6618dd/
# Original non-RPi article: https://phillymesh.net/2016/02/23/setting-up-dynamic-dns-for-your-registered-domain-through-cloudflare/
# Update these with real values
auth_email="email@example.com"
auth_key="global_api_key_goes_here"
zone_name="example.com"
@osa1
osa1 / demo.c
Last active February 4, 2024 06:27
ncurses alt, ctrl etc. key events
// It turns out people don't really know how to handle Alt+ch, or F[1, 12] keys
// etc. in ncurses apps. Even StackOverflow is full of wrong answers and ideas.
// The key idea is to skip ncurses' key handling and read stuff from the stdin
// buffer manually. Here's a demo. Run this and start typing. ESC to exit.
//
// To compile:
//
// $ gcc demo.c -o demo -lncurses -std=gnu11
#include <ncurses.h>
@vmrob
vmrob / nonblocking.cpp
Created February 14, 2016 07:56
simple nonblocking read from std::cin
#include <iostream>
#include <chrono>
#include <future>
#include <string>
std::string GetLineFromCin() {
std::string line;
std::getline(std::cin, line);
return line;
}