Skip to content

Instantly share code, notes, and snippets.

View bugparty's full-sized avatar
🎯
Focusing

Bowen Han bugparty

🎯
Focusing
View GitHub Profile
@bugparty
bugparty / ros1_kobuki.sh
Last active May 22, 2024 05:41
install ros1 and kobuki
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Function to install ROS Noetic
install_ros() {
echo "Setting up sources.list for ROS Noetic"
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
@bugparty
bugparty / kobuki_install.sh
Created May 22, 2024 04:17
kobuki install script
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Install ROS Noetic Kobuki core packages
echo "Installing ROS Noetic Kobuki core packages"
sudo apt-get install -y ros-noetic-kobuki-core
# Install additional dependencies
@bugparty
bugparty / ros1_install.sh
Created May 22, 2024 04:05
script to install ros1
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Setup sources.list
echo "Setting up sources.list"
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
# Setup your keys
@bugparty
bugparty / avx_mathfun.h
Created February 16, 2024 16:20
comment version of avx2 log
/*
AVX implementation of sin, cos, sincos, exp and log
Based on "sse_mathfun.h", by Julien Pommier
http://gruntthepeon.free.fr/ssemath/
Copyright (C) 2012 Giovanni Garberoglio
Interdisciplinary Laboratory for Computational Science (LISC)
Fondazione Bruno Kessler and University of Trento
via Sommarive, 18
class Solution {
public:
double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
if(nums1.size() == 0 || nums2.size() == 0 || (nums1.size() > 1 && *nums1.begin() == *nums1.rbegin()) ||(nums2.size() > 1 && *nums2.begin() == *nums2.rbegin())){
vector<int> &ref = (nums1.size() > 0 ? nums1 : nums2);
if(nums1.size() > 0 && nums2.size() > 0){
if (*nums1.begin() == *nums1.rbegin()){
ref = nums2;
@bugparty
bugparty / install.sh
Created July 29, 2019 15:15
install docker on ubuntu 18.04
#!/bin/bash
apt -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
apt update && apt -y install docker-ce docker-compose
@bugparty
bugparty / Attack.sol
Created February 2, 2018 21:42 — forked from anonymous/Attack.sol
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.17-nightly.2017.9.11+commit.fbe24da1.js&optimize=false&gist=
contract AbstractVault {
address[] public authorizedUsers;
address public owner;
address public withdrawObserver;
address public additionalAuthorizedContract;
address public proposedAAA;
uint public lastUpdated;
bool[] public votes;
address [] public observerHistory;
modifier onlyAuthorized() {
@bugparty
bugparty / ExceptionWriter.java
Created June 29, 2017 07:44
Write Exception object to string
import android.support.annotation.NonNull;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
@bugparty
bugparty / AndroidMockUtil.java
Created June 23, 2017 10:09 — forked from dpmedeiros/AndroidMockUtil.java
Mock main thread handler for use in Android unit tests (requires Mockito and PowerMock)
package com.dpmedeiros.androidtestsupportlibrary;
import android.os.Handler;
import android.os.Looper;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito;
import java.util.concurrent.Executors;
@bugparty
bugparty / cal.py
Created April 26, 2017 11:01
how to cal how many bytes do you shrink from png ..etc to webp in android studio
# coding: utf8
#see https://developer.android.com/studio/write/convert-webp.html
from functools import reduce
intBase = 1024
intKB = intBase
intMB = intKB * intBase
intGB = intMB * intBase