Skip to content

Instantly share code, notes, and snippets.

Avatar

Yangyu Chen cyyself

View GitHub Profile
View cache-alias-test.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
int main() {
int fd = shm_open("test-shm", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (fd == -1) {
printf("Unable to open shm\n");
View axi_pref.v
module axi_perf(
input clock,
input reset,
input mem_axi4_0_awready,
output mem_axi4_0_awvalid,
output [3:0] mem_axi4_0_awid,
output [30:0] mem_axi4_0_awaddr,
output [7:0] mem_axi4_0_awlen,
output [2:0] mem_axi4_0_awsize,
output [1:0] mem_axi4_0_awburst,
View d1-wip-kernel-issue.c
/*
Hello, I'm using d1-wip kernel from https://github.com/smaeul/linux/commits/riscv/d1-wip.
My rootfs is archriscv from https://mirrors.wsyu.edu.cn/archriscv/images/archriscv-20210601.tar.zst.
I found some programs running on this kernel will get SEGV, such as curl.
I delve into this problem and found the root cause is about pthread. It just trap at "amoswap.w.aq a5,a5,(s1)". And the value of register s1 is an address on the stack.
Here is a simple program with pthread. using gcc -lpthread to compile and run on D1-board with work in progress kernel is fine.
@cyyself
cyyself / 2021-red-envelope.v
Last active Feb 11, 2021
我的2021年新年红包的支付宝口令就藏在这个.v文件中,你能找到吗?
View 2021-red-envelope.v
module some_server(
input clk,
input rst,
input ethernet_frame_bit_in,//high bit first
output correct
);
reg [9:0] current_stat;
assign correct = (current_stat == 10'd896);
View windows_utc_time.reg
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001
View ppt2pptx.py
import os
import os.path
import win32com
import win32com.client
import time
def ppt2pptx(file):
powerpoint = win32com.client.Dispatch('PowerPoint.Application')
win32com.client.gencache.EnsureDispatch('PowerPoint.Application')
powerpoint.Visible = 1
ppt = powerpoint.Presentations.Open(file)
@cyyself
cyyself / 合式判断.cpp
Created Feb 27, 2019
离散数学老师的作业,欢迎Hack
View 合式判断.cpp
/*
'A'-'Z'表示命题
!表示非
&表示合取
|表示析取
A@B表示如果A,那么B
A#B表示双条件
()表示优先级
*/
#include <bits/stdc++.h>
View curl.php
<?php
$curl_cmd = trim(fgets(STDIN));
$filename = md5($curl_cmd) . '.html';
while (1) {
$ret = shell_exec($curl_cmd.' -w %{http_code} -o '. $filename .' -i');
if ($ret != '503') break;
}
echo 'Saved to ' . $filename . "\n";
?>
@cyyself
cyyself / hostapd(rpi 3b+).conf
Last active Sep 3, 2018
Raspberry Pi 3B+ 11ac Hotspot
View hostapd(rpi 3b+).conf
interface=wlan0
driver=nl80211
hw_mode=a
ieee80211n=1
ieee80211ac=1
ieee80211d=1
ieee80211h=1
require_ht=1
require_vht=1
@cyyself
cyyself / ipv6passthrough.sh
Last active Sep 3, 2018
IPv6 Pass Through
View ipv6passthrough.sh
#!/bin/sh
ebtables -t broute -A BROUTING -p ! ipv6 -j DROP
brctl addbr ipv6br
ifconfig ipv6br up
brctl addif ipv6br eth0
brctl addif ipv6br wlan0