Skip to content

Instantly share code, notes, and snippets.

@tom-code
tom-code / gt.r
Created January 19, 2018 15:51
R notes
M = matrix(c(10,10,1,3, 10,8,1,3, 8,11,1,3, 1,1,1,3, 20,20,2,3, 11,11,13,3), nrow=6, ncol=4)
require(scales)
apply(M, 1, rescale)
akmeans(M, min.k = 2)
Z = akmeans(M,d.metric=2,ths3=0.8,mode=3, min.k = 2)
Z[cluster]
@tom-code
tom-code / tclcall.c
Created February 1, 2018 15:16
call tcl command
int rc; char *stringValue;
Tcl_Obj *command = Tcl_NewObj();
Tcl_IncrRefCount(command);
Now add the command name
Tcl_ListObjAddElement(0,command,Tcl_NewStringObj("command-name",-1));
@tom-code
tom-code / raw.c
Created April 8, 2018 21:24
macOS raw net
#include <sys/socket.h>
#include <net/bpf.h>
#include <net/if.h>
#include <net/ethernet.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
@tom-code
tom-code / raw.c
Created April 8, 2018 21:24
macOS raw net
#include <sys/socket.h>
#include <net/bpf.h>
#include <net/if.h>
#include <net/ethernet.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
@tom-code
tom-code / bp.sh
Created April 23, 2018 17:58
bluepibb
../src/openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg
telnet localhost 4444
reset halt
first time: stm32f1x unlock 0
flash write_image erase /data/blue/openmc3/opencm3-cppcomp/test1.bin 0x08000000
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
#modprobe uio_pci_generic
#./usertools/dpdk-devbind.py -s
#./usertools/dpdk-devbind.py -b uio_pci_generic 0000:02:00.0
modprobe uio
insmod build/kmod/igb_uio.ko
./usertools/dpdk-devbind.py -b igb_uio 0000:02:00.0
@tom-code
tom-code / procmon.go
Created September 8, 2018 12:08
monitor and restart child process in go; with possibility to stop it with sigterm
package main
import (
"syscall"
"time"
"os/exec"
"fmt"
"os"
)
@tom-code
tom-code / ostree.sh
Created September 9, 2018 17:12
ostree demo
mkdir demo
echo "test" >demo/hello.txt
./ostree/ostree --repo=repo init --mode=archive
./ostree/ostree --repo=repo commit --branch=foo demo
./ostree/ostree --repo=repo refs
./ostree/ostree --repo=repo ls foo
./ostree/ostree-trivial-httpd -P 9999 ./repo
@tom-code
tom-code / kube.sh
Last active January 16, 2019 08:28
kubeadm
#install centos7 - accessiable via 192.168.99.20 (or change bellow)
yum install -y docker
systemctl start docker
systemctl enable docker
>> setup docker http proxy https://docs.docker.com/config/daemon/systemd/
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
@tom-code
tom-code / multus config
Created November 8, 2018 19:33
multus config
https://github.com/intel/multus-cni/blob/master/images/multus-daemonset.yml
[root@kube1 ~]# cat /etc/cni/net.d/00-multus.conf
{
"name": "multus-cni-network",
"type": "multus",
"delegates": [
{
"bridge":"kube-bridge",
"ipam":{