Skip to content

Instantly share code, notes, and snippets.

View MelvinTo's full-sized avatar

Melvin MelvinTo

View GitHub Profile
@MelvinTo
MelvinTo / adv_linklist.go
Created March 28, 2012 08:24 — forked from JeffreyZhao/gist:2216546
try to answer question gist: 2216546, 刚学习Go,写得比较粗糙,简单测试一下没发现问题
@MelvinTo
MelvinTo / shrink_image.sh
Last active March 29, 2017 01:55
Reduce the size of an image file
#!/bin/bash
# This script will shrink a given image file to the minimal size to store existing data
# Which is very helpful to reduce the disk space fot the image file
#
# Limitation
# Only ext4 is supported
# Only support single partition
#
# melvinto@gmail.com
@MelvinTo
MelvinTo / enlarge_image.sh
Created March 29, 2017 01:56
Enlarge filesystem to use the entire device storage space after dd image to device
#!/bin/bash
# This script is doing exactly the opposite of what shrink_image.sh is,
# which will resize the filesystem to use maximum storage space of
# the given device
#
# This is typically done after dd a shrinked image file to this given device
#
DEVICE_FILE=$1
@MelvinTo
MelvinTo / watchdog_sample.c
Created April 2, 2017 15:30
watchdog sample code
cat a.c
/*
* Linux watchdog demo for LPC313x
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@MelvinTo
MelvinTo / dedup.js
Created July 14, 2017 09:46
dedup words (streaming process from stdin)
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
let hash = {};
rl.on('line', function(line){
@MelvinTo
MelvinTo / ss_setup.sh
Last active November 20, 2018 17:20
SS Install
#!/bin/bash
echo "Warning: This script is only tested on ubuntu 18.04 LTS"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# Require sudo privilege to setup and install packages
echo "Turning on BBR..."
sudo bash -c "modprobe tcp_bbr" &>/dev/null
cd /home/pi
mkdir -p /home/pi/stress_data
truncate -s 1G DISK; mke2fs -q -t ext4 -F DISK
sudo mount DISK /home/pi/stress_data
sudo chmod 777 /home/pi/stress_data
stressdisk -duration 5m -s 100000000 cycle /home/pi/stress_data
awk '/Errors:/ {print $2}' /home/pi/stressdisk.log | tail -1
@MelvinTo
MelvinTo / foo.md
Created July 4, 2021 13:41 — forked from sdstrowes/foo.md
Reverse Engineering the Speedtest.net Protocol, Gökberk Yaltıraklı

Source: https://web.archive.org/web/20141216073338/https://gkbrk.com/blog/read?name=reverse_engineering_the_speedtest_net_protocol Author: Gökberk Yaltıraklı

Reverse Engineering the Speedtest.net Protocol

After finishing my command line speed tester written in Rust, I didn't have a proper blog to document this process. A few days ago I wrapped up a simple blogging script in Python so hopefully it works good enough to explain how everything works.

By now I have already figured out the whole protocol for performing a speed test but I will write all the steps that I took so you can learn how to reverse engineer a simple protocol.

The code that I wrote can be found at https://github.com/gkbrk/speedtest-rust.

@MelvinTo
MelvinTo / auto-artifact-export.yml
Created November 27, 2023 08:27 — forked from piyoki/auto-artifact-export.yml
mosdns-v5 config template
---
- name: Update dat files
hosts: all
become: yes
vars:
- base_path: /etc/mosdns
- restart_daemon: yes
- daemon_service_name: mosdns
- clean_up_after: yes