Skip to content

Instantly share code, notes, and snippets.

View wilem's full-sized avatar

Weiliang Yang wilem

  • Huawei Technology
  • Shenzhen, Guangdong, China
View GitHub Profile
@wilem
wilem / calculator
Created April 16, 2014 07:30
do math(arithmetic operation) in makefile.
# calculator by call (bash)shell command.
calc=$(shell echo $$\(\($(1)\)\))
foo=$(call calc,3*4)
SZ_1K:=$(call calc,32*32)
SZ_4K:=$(call calc,$(SZ_1K)*4)
SZ_4M:=$(call calc,$(SZ_4K)*$(SZ_1K))
SZ_4G:=$(call calc,$(SZ_4M)*$(SZ_1K))
@wilem
wilem / fft
Last active March 28, 2022 08:54
FFT(Fast Fourier Transformation algorithm in Python)
import math
def complex_dft(xr, xi, n):
pi = 3.141592653589793
rex = [0] * n
imx = [0] * n
for k in range(0, n): # exclude n
rex[k] = 0
imx[k] = 0
for k in range(0, n): # for each value in freq domain
void epoll_server()
{
for(; ;) {
nfds = epoll_wait(epfd, events, 20/*maxevents*/, 500/*timeout*/);
for(i = 0; i < nfds; ++i) {
// 如果是主socket的事件,则表示有新的连接
if (events[i].data.fd == listenfd) {
connfd = accept(listenfd,
(sockaddr *) &clientaddr,