Skip to content

Instantly share code, notes, and snippets.

View fuji246's full-sized avatar

Jiantao Fu fuji246

View GitHub Profile
@fuji246
fuji246 / onchange.sh
Created August 4, 2012 15:56 — forked from senko/onchange.sh
Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@fuji246
fuji246 / onchange.sh
Created August 4, 2012 15:58 — forked from senko/onchange.sh
Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@fuji246
fuji246 / blockstack-verify
Created February 24, 2018 05:18
blockstack-verify
Verifying my Blockstack ID is secured with the address 12eBN1w3qKPKJNk9hRrtYuyZYh2A6LkWBA https://explorer.blockstack.org/address/12eBN1w3qKPKJNk9hRrtYuyZYh2A6LkWBA
@fuji246
fuji246 / bbb-video-docks.md
Created March 27, 2018 07:06
Bigbluebutton video UI enhancement

bigbluebutton video UI enhancement

There are two feature requests relate to bigbluebutton video UI.

1 Add outline for selfview

This is used for guiding the user to adjust the header and shoulder place before camera, by showing an outline in selfview video.

To do this we can simply add a foreground image, and put that image in the center of selfview window.

@fuji246
fuji246 / pinch_scale.md
Last active November 9, 2019 00:34
UIPinchGestureRecognizer Scale

I find the scale of UIPinchGestureRecognizer is confusing, so I did two experiments below, two ways to do the same thing.

Method 1

gestureRecognizer.scale start with 1.0 at the beginning of pinch (gestureRecognizer.state == .began), and gestureRecognizer.scale in later state (.changed or .end) is always based on that, for example, if the view size is view_size at the beginning of pinch (might not be the same with the original size orig_view_size), gestureRecognizer.scale always starts with 1.0, and if it becomes 2.0 later, it's size will be 2 * view_size, so the scale always based on that when the pinch starts. And we can get the scale at the beginning of pinch (gestureRecognizer.state == .began) lastScale = self.imageView.frame.width/self.imageView.bounds.size.width, so the scale of the original image now should be lastScale * gestureRecognizer.scale

  • lastScale: The scale of last round of Pinch, a round of Pinch is from state.start to state.end, and the scale is based on the o
@fuji246
fuji246 / emulator.sh
Created December 6, 2018 00:07
emulator script
#!/bin/bash
set -x
set -e
GEMODEL_P=8.8235
GEMODEL_R=50
INPUT_INF="enp2s0"
OUTPUT_INF="enp3s0"
wget https://github.com/nginx/nginx/archive/branches/stable-1.16.zip
git clone https://github.com/arut/nginx-rtmp-module.git
unzip stable-1.16.zip
cd nginx-branches-stable-1.16/
sudo apt-get install zlib-devel libssl-dev
./auto/configure --with-http_ssl_module --without-http_rewrite_module --add-module=../nginx-rtmp-module
make
sudo make install
@fuji246
fuji246 / cpu-mem-plot
Last active July 10, 2019 00:16
plot cpu and memory usage
import matplotlib.pyplot as plt
import sys
'''
#!/bin/bash
while sleep 1; do
sudo netstat -anp | grep "80 " | wc -l
top -n 1 -b | grep -E "Cpu|Mem"
done
@fuji246
fuji246 / boxplot-example.py
Last active July 10, 2019 00:14
box plot example
'''
server, direction, bitrate, case, buftune, frto_response, tcp_abc
HZ, uplink, 15, 150 ms, 0, 0, 0
HZ, uplink, 22.1, 150 ms, 0, 0, 0
HZ, uplink, 20.6, 150 ms, 0, 0, 0
HZ, uplink, 11.5, 150 ms, 0, 0, 0
HZ, uplink, 9.83, 150 ms, 0, 0, 0
HZ, uplink, 7.8, 150 ms, 0, 0, 0
HZ, uplink, 14.4, 150 ms, 0, 0, 0
HZ, uplink, 12.7, 150 ms, 0, 0, 0
$ uname -a
Linux pi3 3.6.11+ #538 PREEMPT Fri Aug 30 20:42:08 BST 2013 armv6l GNU/Linux
$ zgrep "* firmware as of" /usr/share/doc/raspberrypi-bootloader/changelog.Debian.gz | head -1 |
awk '{ print $5 }'
d4f5315cfac4e
On the build host fetch the equivalent R-PI firmware.
$ mkdir -p /embedded/raspbian/build/