Skip to content

Instantly share code, notes, and snippets.

View xiongyihui's full-sized avatar

Yihui Xiong xiongyihui

View GitHub Profile
@xiongyihui
xiongyihui / fix_checksum.sh
Created December 10, 2015 10:01
fix vector checksum value for NXP LPC1xxx Microcontroller
#!/bin/bash
#
# fix vector checksum value for NXP LPc1xxx
#
if [ $# != 1 ]; then
echo "Usage: $0 firmware.bin"
exit 1
fi
@xiongyihui
xiongyihui / detect_linux_drive_change.py
Last active May 25, 2016 02:39
drive detection on linux and windows
#!/usr/bin/python2
# Using dbus to detect new drive on linux
# Install dependences: sudo apt-get install python-dbus python-gobject
import dbus
import glib
from dbus.mainloop.glib import DBusGMainLoop
def handle_new_drive(sender, mount_id, data):
mounted_path = data[5][7:]
@xiongyihui
xiongyihui / CMakeLists.txt
Created February 10, 2017 09:44
Using WebRTC Audio Processing Module
cmake_minimum_required(VERSION 2.8)
project(webrtc-audio-processing)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
add_definitions("-DWEBRTC_LINUX -DWEBRTC_POSIX -DWEBRTC_NS_FLOAT")
#-DWEBRTC_UNTRUSTED_DELAY
include_directories(
@xiongyihui
xiongyihui / ubuntu-cli-install-android-sdk.sh
Created September 9, 2017 03:12 — forked from zhy0/ubuntu-cli-install-android-sdk.sh
Install Android SDK on headless Ubuntu linux machine via command line, so that you can compile open source Android apps.
#!/bin/bash
# Thanks to https://gist.github.com/wenzhixin/43cf3ce909c24948c6e7
# Execute this script in your home directory. Lines 17 and 21 will prompt you for a y/n
# Install Oracle JDK 8
add-apt-repository ppa:webupd8team/java
apt-get update
apt-get install -y oracle-java8-installer
apt-get install -y unzip make # NDK stuff
@xiongyihui
xiongyihui / gif2c.py
Created February 2, 2018 07:47
convert image (ICO, GIF, PNG, JPG and etc) to C array
import sys
from PIL import Image
if len(sys.argv) != 3:
print('Usage: python {} image.gif array.c'.format(sys.argv[0]))
sys.exit(1)
im = Image.open(sys.argv[1])
@xiongyihui
xiongyihui / CMakeLists.txt
Created December 24, 2018 08:42
paho.mqtt.cpp example
find_package(PahoMqttCpp REQUIRED)
add_executable(data_publish data_publish.cpp)
# target_link_libraries(data_publish paho-mqtt3a paho-mqttpp3)
target_link_libraries(data_publish PahoMqttCpp::paho-mqttpp3)
@xiongyihui
xiongyihui / usb-composite.sh
Last active December 11, 2024 09:43
Linux USB Gadget - UAC & HID
#!/bin/bash
modprobe libcomposite
mkdir -p /sys/kernel/config/usb_gadget/g
echo 0x1d6b > /sys/kernel/config/usb_gadget/g/idVendor # Linux Foundation
echo 0x0104 > /sys/kernel/config/usb_gadget/g/idProduct # Multifunction Composite Gadget
echo 0x0100 > /sys/kernel/config/usb_gadget/g/bcdDevice # v1.0.0
echo 0x0200 > /sys/kernel/config/usb_gadget/g/bcdUSB # USB 2.0
echo 0xef > /sys/kernel/config/usb_gadget/g/bDeviceClass # USB 2.0
echo 0x02 > /sys/kernel/config/usb_gadget/g/bDeviceSubClass # USB 2.0