Skip to content

Instantly share code, notes, and snippets.

View John-Lin's full-sized avatar
👋
hi

Che-Wei Lin John-Lin

👋
hi
View GitHub Profile
@John-Lin
John-Lin / Vagrantfile
Created May 2, 2017 07:20
OVS with Docker Networking
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox" do |vb|
vb.customize ['modifyvm', :id, '--nictype1', 'Am79C973']
vb.customize ['modifyvm', :id, '--nicpromisc1', 'allow-all']
end
config.vm.provision :shell, path: "bootstrap.sh"
end
@John-Lin
John-Lin / Jakefile
Last active May 30, 2016 07:04
iperf command alias
namespace('iperf', function () {
desc('Iperf server receiving 64 byte');
task('s64', { async: true }, function () {
var cmds = ['iperf -s -u -l 64 -i 1'];
jake.exec(cmds, { interactive: true }, function () {
complete();
});
});
desc('Iperf server receiving 128 byte');
#!/usr/bin/env python
"""Run `snort -A console` command using a pipe.
Warning! Alerts are delayed until snort's stdout buffer is flushed.
"""
from __future__ import print_function
from subprocess import Popen, PIPE, STDOUT
snort_process = Popen(['snort', '-A', 'console', '-c', 'snort.conf'],
stdout=PIPE, stderr=STDOUT, bufsize=1,
@John-Lin
John-Lin / simple_loop.py
Last active January 19, 2022 01:14
Mininet Simple Topology
#!/usr/bin/python
from mininet.topo import Topo
from mininet.cli import CLI
from mininet.net import Mininet
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel
from mininet.node import RemoteController
@John-Lin
John-Lin / packer_spec.rb
Last active March 3, 2016 15:17
Assignment: Data Packer
require 'minitest/autorun'
require './short_string_packer'
def random_string
[*'a'..'z'].sample(rand(1..12)).join
end
test_cases = %w(a z asdf abcdefghijkl aaaaaazzzzzz)
describe 'Test whether packing methods are valid' do
@John-Lin
John-Lin / tsv_to_yml.rb
Created September 28, 2015 15:15
For SOA Serialization homework
# Check the output file
if ARGV[1].nil?
print 'Insert the name of your output file (yml file) '
outname = $stdin.gets.chomp
else
outname = ARGV[1]
end
# Build the array of Hashes
require 'yaml'
survey = []
@John-Lin
John-Lin / yml_to_tsv.rb
Created September 28, 2015 15:14
For SOA Serialization homework
if ARGV[1].nil?
print 'Insert the name of your output file (tsv file) '
outname = $stdin.gets.chomp
else
outname = ARGV[1]
end
# Deserialize
require 'yaml'
survey = YAML.load(File.read(ARGV[0]))
# Create the TSV file
@John-Lin
John-Lin / fizzbuzz.rb
Created September 28, 2015 15:10
For SOA fizzbuzz homework
def fizzbuzz(num, &strategy)
arr = []
1.upto(num) do |i|
if i % 5 == 0 and i % 3 == 0
arr.push("FizzBuzz")
if strategy
yield 'FizzBuzz'
end
elsif i % 3 == 0
arr.push("Fizz")
var request = require('request');
var config = require('./config');
module.exports = {
startPkt: function() {
dpid = config.dpid;
urlApi = 'http://127.0.0.1:8080/packetgen/start/' + dpid;
request(urlApi, function(error, response, body) {
if (!error && response.statusCode == 200) {
@John-Lin
John-Lin / delete_all_flows.py
Created July 21, 2015 09:54
Delete all flows
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import CONFIG_DISPATCHER
from ryu.controller.handler import set_ev_cls
class DeleteAll(app_manager.RyuApp):
def __init__(self, *args, **kwargs):
super(DeleteAll, self).__init__(*args, **kwargs)