Skip to content

Instantly share code, notes, and snippets.

View singchia's full-sized avatar
🎯
Focusing

singchia

🎯
Focusing
View GitHub Profile
@singchia
singchia / list_dpdk_nics.go
Last active January 30, 2024 07:01
list dpdk supported nics
package main
import (
"encoding/json"
"fmt"
"github.com/jaypipes/ghw"
)
var (
@singchia
singchia / add_license_to_missing.sh
Created January 28, 2022 07:13 — forked from magnific0/add_license_to_missing.sh
Add a copyright license header to all CPP and H files
#!/bin/bash
read -r -d '' license <<-"EOF"
/* Copyright (c) 2010-2017, Delft University of Technology
* All rights reserved
*
* This file is part of the Tudat. Redistribution and use in source and
* binary forms, with or without modification, are permitted exclusively
* under the terms of the Modified BSD license. You should have received
* a copy of the license with this file. If not, please or visit:
* http://tudat.tudelft.nl/LICENSE.
@singchia
singchia / qemu-networking.md
Created October 8, 2018 00:18 — forked from extremecoders-re/qemu-networking.md
Setting up Qemu with a tap interface

Setting up Qemu with a tap interface

There are two parts to networking within QEMU:

  • The virtual network device that is provided to the guest (e.g. a PCI network card).
  • The network backend that interacts with the emulated NIC (e.g. puts packets onto the host's network).

Example: User mode network

package main
import (
"fmt"
"math/rand"
"os"
"strconv"
"sync"
"time"
)
@singchia
singchia / gist:0e976ef956451e9b754acc26a1ee6b1f
Created March 14, 2018 09:13 — forked from tonyc/gist:1384523
Using strace and lsof

Using strace and lsof to debug blocked processes

You can use strace on a specific pid to figure out what a specific process is doing, e.g.:

strace -fp <pid>

You might see something like:

select(9, [3 5 8], [], [], {0, 999999}) = 0 (Timeout)

@singchia
singchia / epoll.cpp
Created March 11, 2018 09:06 — forked from dtoma/epoll.cpp
C++ epoll
// https://banu.com/blog/2/how-to-use-epoll-a-complete-example-in-c/
// http://www.kegel.com/poller/
/** Todo
* - [ ] Split i/o and logic
* - [ ] Unit test logic
* - [ ] Logging
* - [ ] Continuous integration
* - [ ] Linux
* - [ ] Windows
@singchia
singchia / Makefile
Created January 31, 2018 13:17 — forked from turtlemonvh/Makefile
Golang Project Makefile Template
# Borrowed from:
# https://github.com/silven/go-example/blob/master/Makefile
# https://vic.demuzere.be/articles/golang-makefile-crosscompile/
BINARY = superdo
VET_REPORT = vet.report
TEST_REPORT = tests.xml
GOARCH = amd64
VERSION?=?
package main
import (
"flag"
"fmt"
"net"
"os"
"sync"
"time"
)
package main
import (
"flag"
"net"
"os"
"time"
"github.com/singchia/go-hammer/circulinker"
)
package main
import (
"flag"
"net"
"os"
)
func main() {
var addr string