Skip to content

Instantly share code, notes, and snippets.

@thomasweng15
thomasweng15 / open efort depth img.py
Created February 15, 2019 23:01
open efort depth img
import numpy as np
import matplotlib.pyplot as plt
import cv2
im = cv2.imread("2019-02-13-19-03-1912345DepthImage.png", cv2.IMREAD_UNCHANGED)
color_im = cv2.applyColorMap(im.astype(np.uint8), cv2.COLORMAP_JET)
plt.imshow(color_im)
plt.show()
@thomasweng15
thomasweng15 / setup.sh
Created February 13, 2019 17:30
Lab account setup
rosdep update
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin build
cp -r packages/.* ~/catkin_ws/src/.*
catkin build
cp ~/setup/scripts/thing1.sh ~/catkin_ws/thing1.sh
cp ~/setup/scripts/thing2.sh ~/catkin_ws/thing2.sh
@thomasweng15
thomasweng15 / scraper.py
Created August 25, 2018 21:57
R:SS web scrape
from bs4 import BeautifulSoup
import requests
def save_pdf(base_url, year, href):
chunk_size = 2000
pdf_url = base_url + href
pdf_req = requests.get(pdf_url, stream=True)
fname = year + "_" + href
with open("./data/%s" % fname, 'wb') as fd:
for chunk in pdf_req.iter_content(chunk_size):
@thomasweng15
thomasweng15 / post-receive
Created May 3, 2018 21:20
Git deploy post-receive hook
#!/bin/bash
TARGET="/home/thomas_weng11/deploy-robopubs"
GIT_DIR="/home/thomas_weng11/robopubs.git"
BRANCH="master"
while read oldrev newrev ref
do
# only checking out the branch to deploy
if [[ $ref = refs/heads/"$BRANCH" ]];
@thomasweng15
thomasweng15 / qemu_osx_rpi_raspbian_jessie.sh
Last active April 9, 2018 22:11 — forked from hfreire/qemu_osx_rpi_raspbian_jessie.sh
How to emulate a Raspberry Pi (Raspbian Jessie) on Mac OSX (Sierra)
# Install QEMU OSX port with ARM support
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" && brew update && brew install qemu
export QEMU=$(which qemu-system-arm)
# Dowload kernel and export location
curl -OL \
https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/kernel-qemu-4.4.34-jessie
export RPI_KERNEL=./kernel-qemu-4.4.34-jessie
# Download filesystem and export location
@thomasweng15
thomasweng15 / torso_script.sh
Created February 3, 2018 02:28
PR2 torso script
#!/bin/bash
rostopic pub /torso_controller/position_joint_action/goal pr2_controllers_msgs/SingleJointPositionActionGoal "header:
seq: 0
stamp:
secs: 0
nsecs: 0
frame_id: ''
goal_id:
stamp:
https://codepen.io/thomasweng/pen/QQWZaO
@thomasweng15
thomasweng15 / install_cse481c.bash
Created January 11, 2018 19:38
ros/fetch install script
#! /bin/bash
# Basic stuff
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get install -y build-essential vim git tmux python-dev curl python-pip cmake libgif-dev
rm -r Documents Pictures Videos Templates Public Music examples.desktop
@thomasweng15
thomasweng15 / Code.gs
Created January 8, 2018 20:12
Turning column-based data in google sheets to row-based
function populatePivotTableData() {
spreadsheetId = "1AJbG6ZhqJCyU7vlb2D2d81ZG3dU5ICGkA4GPb0Xa0q8";
var ss = SpreadsheetApp.openById(spreadsheetId);
SpreadsheetApp.setActiveSpreadsheet(ss);
// Get sheet containing data
var srcSheetName = "Reordered Data";
SpreadsheetApp.setActiveSheet(ss.getSheetByName(srcSheetName));
var srcSheet = ss.getActiveSheet();
@thomasweng15
thomasweng15 / getAnnotionCenter.cpp
Created December 28, 2017 03:23
Check collision between objects and arrow label
// get corner vertices of the label
std::vector<geometry_msgs::Point> label_rect;
geometry_msgs::Point pt;
pt.x = center.position.x - side_length / 2;
pt.y = center.position.y - side_length / 2;
label_rect.push_back(pt);
pt.x = center.position.x + side_length / 2;
pt.y = center.position.y - side_length / 2;