Skip to content

Instantly share code, notes, and snippets.

View Bowenislandsong's full-sized avatar

Bowen Song Bowenislandsong

  • USC
View GitHub Profile
@Bowenislandsong
Bowenislandsong / Graph_3d_steps.py
Created March 15, 2022 21:54
This graph generator plots different step signals and show them in a 3d plot with colorful views.
from matplotlib import pyplot as plt
from matplotlib.collections import PolyCollection
import numpy as np
# Graph Auxilary
'''
Graph_runsteps_3D super positions different running step signals and show them on the same
timeline. Each signal has a different color and provide a general view of the signals.
mtx_time: time of a signal. (optional) If black, plot them by samples. Dimention should be the same as mtx_signal
mtx_signal: array of signals. Each run step is represented by a array of values (signal). The mtx layout is run-step X signal.
@Bowenislandsong
Bowenislandsong / trojancheck.js
Last active January 5, 2022 22:23
Add the following to book mark for easy trojancheck clicking. Trojancheck always change the question layout, this code needs to be updated accordingly. To use it, create a book mark with this js script. Navigate to trojancheck page and click this bookmark till the last page (~4 clicks).
javascript: (() => {
if (location.href=="https://trojancheck.usc.edu/login"){
document.querySelector('[aria-label="Log in with your USC NetID"]').click();
}
else if (location.href=="https://trojancheck.usc.edu/consent"){
document.querySelector('.submit-button').click();
}
else if (location.href=="https://trojancheck.usc.edu/dashboard"){
document.querySelector('.btn-begin-assessment').click();
}
%% Graph IBLT
clear all
close all
t=csvread("./setDiff_iblt.txt");
i=csvread("./setDiff_intercpi.txt");
samples = 50;
dataLength = 50;
plotIBLTPerf_diff(t,i,samples,dataLength,"Communication and Time Cost vs. Diffrences Between 2 DB");
// Project trigger is available in UI.
function SendEmail() {
var agendaSheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
var emailTempSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Email Template")
var startRow = 2;
var emailTemp = emailTempSheet.getDataRange().getValues()
var address = emailTemp[0][1]
var subject = emailTemp[1][1]
var meetingTP = emailTemp[2][1]
# have raw-pull-secret by Visit https://cloud.redhat.com/openshift/install/aws/installer-provisioned for aws pull-secret
# Login to OC using https://api.ci.openshift.org/ and upper right corner you'll see the dropdown to Command Line Tools that'll give you an oc login command to cp/paste in your terminal.
cp raw-pull-secret pull-secret
oc registry login --to=pull-secret
tr -d ' \t\n\r\f' <pull-secret >openshift-pull-secrets.yaml
pullsecret=`cat openshift-pull-secrets.yaml`
sed -i "/^\([[:space:]]*pullSecret: \).*/s//\1'${pullsecret}'/" install-config.yaml
#!/bin/bash
# make a dir with time
dir_name="olm_$(date +"%m_%d-%T")"
mkdir "$dir_name"
for pod_name in $(oc get pods -n olm | awk 'NR>1 {print $1}')
do
oc logs --all-containers $pod_name -n olm > "$dir_name/$pod_name.txt"
done
import test "github.com/openshift/windows-machine-config-operator/tools/windows-node-installer/pkg/cloudprovider/aws"
func getInstance(a *test.awsProvider, instanceID string) (*ec2.Instance, error) {
instances, err := a.EC2.DescribeInstances(&ec2.DescribeInstancesInput{
InstanceIds: aws.StringSlice([]string{instanceID}),
})
if err != nil {
return nil, err
}
#!/bin/bash
# move content of clusterN to cluster dir and destroy cluster
# cp install-config from current dir to clusterN and edit cluster name with random suffix
# create the OpenShift Cluster there.
# Pre-req: dir(cluster, clusterN), installer-config.yaml, and openshift-install binary.
rm -rf cluster/*
mv clusterN/* cluster/
./openshift-install destroy cluster --dir cluster &
cp install-config.yaml clusterN/
nameSufix=$RANDOM % 100000 | bc
# we edit the grades off-line from blackboard
# we assume the combination of Student ID and BU emails as unique and valid identity (either should do)
# group assignment list should be with this script
# Mode 1:
# we input csv files for grade assignments
# Mode 2:
# we input a grade for a group
import csv
import os
import copy as c
@Bowenislandsong
Bowenislandsong / TaigaCreator.py
Created February 16, 2019 17:14
Creating Taiga Project with invitation
# Creating projects in Taiga from a list
# Add people from the list to their projects
# by Bowen Song
# Input List File Format:
# <Project name> | <Member username/email>
# $ pip install PyGithub
# use Normal Access