Skip to content

Instantly share code, notes, and snippets.

View Sanghyun-Hong's full-sized avatar

Sanghyun Hong Sanghyun-Hong

View GitHub Profile
@Sanghyun-Hong
Sanghyun-Hong / subgraphs.py
Created October 12, 2016 20:58 — forked from adamobeng/subgraphs.py
Random sub-samples of a network in python-igraph
# Copyright (c) 2012 Adam Obeng
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR T
@Sanghyun-Hong
Sanghyun-Hong / perf-test.c
Created August 10, 2016 02:26 — forked from dubik/perf-test.c
Performance counters using PAPI
#include <stdio.h>
#include <stdlib.h>
#include <papi.h>
#define NUM_EVENTS 4
void matmul(const double *A, const double *B,
double *C, int m, int n, int p)
{
int i, j, k;
/*
* memprofiletest
*
* USAGE: ./memprofiletest size_kb
*
* eg, ./memprofiletest 10240 # make larger than LLC cache for misses
*/
#include <stdio.h>
#include <stdlib.h>
#!/usr/bin/sh
#
# intelcpi - measure CPI and utilization on Intel processors.
#
# USAGE: intelcpi [interval]
# eg,
# intelcpi 0.1 # for 0.1 second intervals
#
# CPI shows how memory intensive CPU workloads are.
#

Testing of Xen vPMU filter options.

Three tests are executed on a simple program (noploop, which runs NOP in a loop). The first two show Linux "perf stat" summaries, and the third tests specific counters: the IPC ones, an architectural one, and a few extras. Which of these will work depends on the filter mode.

I'll begin by showing off and on, the current modes, and then the new modes: ipc and arch.

vpmu=off (default)

root@lgud-bgregg:~> xl dmesg | grep vpmu
@Sanghyun-Hong
Sanghyun-Hong / vif-bridge.sh
Created July 17, 2016 21:34 — forked from mmoya/vif-bridge.sh
vif-bridge with ebtables
#!/bin/bash
#============================================================================
# ${XEN_SCRIPT_DIR}/vif-bridge
#
# Script for configuring a vif in bridged mode.
# The hotplugging system will call this script if it is specified either in
# the device configuration given to Xend, or the default Xend configuration
# in ${XEN_CONFIG_DIR}/xend-config.sxp. If the script is specified in
# neither of those places, then this script is the default.
#
#!/usr/bin/env python
# SLLabs.com vif hotplug script
# Copyright (C) 2013 SLLabs.com <support@sllabs.com>
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
# Written in 2013 for Kamilion@SLLabs.com by ircs://irc.ospnet.org/#sllabs residents
# "If you have an apple and I have an apple and we exchange these apples
# then you and I will still each have one apple.
#!/bin/sh
IF=eth0
iptables -F
iptables -t nat -F
iptables -X
iptables -Z
# drop all packets by default
#!/bin/sh
# Réinitialise les règles
iptables -t filter -F
iptables -t filter -X
# Bloque tout le trafic
iptables -t filter -P INPUT DROP
iptables -t filter -P FORWARD DROP
iptables -t filter -P OUTPUT DROP
#!/bin/sh
#toriptables.sh
# I learned this from https://wiki.torproject.org/noreply/TheOnionRouter/TransparentProxy
#Reject all ICMP packets because they have no owner which creates a leak
iptables -A OUTPUT -p icmp -j REJECT
#All traffic for the user root will go through tor
iptables -t nat -A OUTPUT ! -o lo -p tcp -m owner --uid-owner root -m tcp -j REDIRECT --to-ports 9040
iptables -t nat -A OUTPUT ! -o lo -p udp -m owner --uid-owner root -m udp --dport 53 -j REDIRECT --to-ports 53