Skip to content

Instantly share code, notes, and snippets.

View abcdabcd987's full-sized avatar
😄
( ´ ▽ ` )ノ

Lequn Chen abcdabcd987

😄
( ´ ▽ ` )ノ
View GitHub Profile
@abcdabcd987
abcdabcd987 / ICMPPinger.py
Created May 15, 2017 10:18
Socket Programming Assignment 5: ICMP Pinger
import os
import sys
import struct
import time
import select
import socket
import binascii
ICMP_ECHO_REQUEST = 8
#!/bin/bash
# save as /root/del_user.sh
USERNAME=$1
if [[ -z "$USERNAME" ]]; then
echo "Please give me a username"
exit 1
fi
echo "This script will"
@abcdabcd987
abcdabcd987 / prog2_abp.c
Created April 28, 2017 02:06
Programming Assignment #2: Implementing a Reliable Transport Protocol (Alternating-Bit-Protocol)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* ******************************************************************
ALTERNATING BIT AND GO-BACK-N NETWORK EMULATOR: VERSION 1.1 J.F.Kurose
This code should be used for PA2, unidirectional or bidirectional
data transfer protocols (from A to B. Bidirectional transfer of data
is for extra credit and is not required). Network properties:
// g++-7 sharding.cc -Wall -std=c++17 -g -pthread -O2 -ltbb
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <string>
#include <mutex>
#include <shared_mutex>
#include <optional>
#include <random>
@abcdabcd987
abcdabcd987 / delay-fs.cc
Last active November 28, 2022 22:57
A filesystem from which reading a file incurs 50ms delay for each byte.
#if 0
set -e
binname=$(mktemp --suffix -delay-fs.bin)
g++ -o "$binname" -Wall -g -O2 "$0" -lfuse3 -lpthread
"$binname" $@
rm "$binname"
exit
#endif
// delay-fs:
// A filesystem from which reading a file incurs 50ms delay for each byte.
@abcdabcd987
abcdabcd987 / prog2_gbn.c
Created April 28, 2017 03:12
Programming Assignment #2: Implementing a Reliable Transport Protocol (Go-Back-N)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* ******************************************************************
ALTERNATING BIT AND GO-BACK-N NETWORK EMULATOR: VERSION 1.1 J.F.Kurose
This code should be used for PA2, unidirectional or bidirectional
data transfer protocols (from A to B. Bidirectional transfer of data
is for extra credit and is not required). Network properties:
#include <vector>
/**
Given an non-decreasing ordered array `arr`, search the biggest `i` that makes `arr[i] == value`.
If `i` doesn't exist, return -1
*/
int search_last_match(const std::vector<int>& arr, const int value)
{
int lef = 0, rig = static_cast<int>(arr.size());
while (rig-lef > 1)
@abcdabcd987
abcdabcd987 / c2nasm.bash
Last active December 11, 2019 22:04
C to NASM Assembly
#!/bin/bash
# thanks to http://stackoverflow.com/a/20743090
# thanks to https://github.com/diogovk/c2nasm
# install objconv: https://github.com/vertis/objconv
#
# $1: source code
set -e
C_FILE="$1"
BASE_NAME="${C_FILE%.*}"
// g++ cache-prefetching.cc -Wall -std=c++11 -g -pthread -O2
#include <string>
#include <vector>
#include <mutex>
#include <random>
#include <chrono>
#include <thread>
#include <iomanip>
#include <iostream>
diff -ruN orig/bootloader/Xargo.toml new/bootloader/Xargo.toml
--- orig/bootloader/Xargo.toml 2018-07-18 23:59:41.000000000 +0800
+++ new/bootloader/Xargo.toml 2018-07-19 22:31:03.000000000 +0800
@@ -2,10 +2,6 @@
core = {}
std_unicode = {}
-[dependencies.compiler_builtins]
-features = ["mem"]
-stage = 1