Skip to content

Instantly share code, notes, and snippets.

View ChinYikMing's full-sized avatar
😄

ChinYikMing

😄
View GitHub Profile
@ChinYikMing
ChinYikMing / gist:d804dcc94a890ba561e045ac9695b743
Created May 14, 2024 11:33
Prebuild 64-bit RISC-V toolchain and QEMU environment for xv6
FROM ubuntu:22.04
RUN apt-get update
RUN apt-get install git vim zip wget -y
RUN apt-get install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev -y
RUN wget https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2024.04.12/riscv64-elf-ubuntu-20.04-gcc-nightly-2024.04.12-nightly.tar.gz && tar -xvf riscv64-elf-ubuntu-20.04-gcc-nightly-2024.04.12-nightly.tar.gz && cp riscv/bin/* /usr/bin
RUN apt-get install git build-essential gdb-multiarch qemu-system-misc gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu -y
import RPi.GPIO as GPIO
import time
st = 1 # sleep time
def preamable(pin):
for _ in range(0,8):
blink(pin) # blink 0.5s
time.sleep(st) #dim 0.5s
return
@ChinYikMing
ChinYikMing / gist:0f4060ee74a13c5566b99c3f1f0baf51
Last active November 15, 2023 10:17
python_light_sensor.py
import time, sys, math
from grove.adc import ADC
__all__ = ["GroveLightSensor"]
st = 1#sleep time
class GroveLightSensor(object):
'''
@ChinYikMing
ChinYikMing / Delegation.sol
Created October 29, 2023 06:59
HW3 Delegation
contract DelegationAttack {
function callFallback(bytes32 secret, address studentWallet, address delegationAddress) external {
// trigger fallback of Delegation contract since no changeOwner function is defined
(bool success,) = delegationAddress.call(
abi.encodeWithSignature(
"changeOwner(bytes32,address)",
secret,
studentWallet
)
);
#!/usr/bin/env python
# coding: utf-8
import requests
import json
import time
from time import sleep
import pandas as pd
import openpyxl
from openpyxl.styles import Font
@ChinYikMing
ChinYikMing / rm_comments.c
Last active June 20, 2022 09:14
remove /* */ and // comments in C programming language
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
/*