STM32F103C8T6
Continue readingCategory Archives: Memo
STM8S103F3P6 Pinout
Blue generic STM8S103F3P6 microcontroller board pinout
Continue readingHow to download Xcode simulator directly
Due to network issues, downloading the runtime is not always smooth, so it is best to download it directly with support for resuming interrupted downloads.
1. Find the downloaded URL
Use console
- Open Xcode, open preferences, go to the Components section.
- Open the
Console App
, clear the console. - Go back to the
Xcode preferences
. Start the simulator download, then cancel it. - Now in the Console, you will see something about the cancellation with the download URL. ( Process is
xcode
and maybe search keyworddownload
) - Copy the URL from the Console. Then download it by safari. ( or some other way which is authed )
Offical dowloaded from apple
- Go to apple developer website and login.
- You can find all Xcode dmg/xip files directly on https://developer.apple.com/download/all/ (requires Apple ID).
- Find the simulator runtimes you want and download.
2. Download the DMG file
Now you can download it using Safari or another authorized method.
3. Add runtime
Finally, just run
xcrun simctl runtime add iOS_xxx_Simulator_Runtime.dmg
Some Common OpenSSL Commands
OpenSSL is a robust, commercial-grade, and full-featured toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols. It’s useful but hard to remember so many commands, so I have listed some common usages below.
Continue readingESP8266 Pinout
ESP8266 Pinout
Useful bash functions
Get bash file absolute path
realpath(){
path="$1"
while [ -h "$path" ] ; do path="$(readlink "$path")"; done
echo "$(cd "$(dirname "$path")"; echo -n "$(pwd)/$(basename "$path")")";
}
Log
log() {
if [[ -n "$VERBOSE" ]]; then echo -e "$@"; else test 1; fi
}
error() {
echo "$@" >&2
exit 1
}
warning() {
echo "$@" >&2
}
function check_status {
if [ $? -ne 0 ];then
error ${@:-"Encountered an error, aborting!"}
fi
}
Loop find
find . -type f -iname "*.txt" -print0 | while IFS= read -r -d $'\0' line; do
echo "$line"
ls -l "$line"
done
Arduino Uno And Nano Pinout Diagram
Arduino Uno And Nano Pinout Diagram, as shown in the figure …
Process Substitution <(LIST) >(LIST)
Process substitution is supported on systems that support named pipes (FIFOs) or the /dev/fd method of naming open files. It takes the form of
<(list)
or
>(list)
The process list is run with its input or output connected to a FIFO or some file in /dev/fd. The name of this file is passed as an argument to the current command as the result of the expansion. If the >(list) form is used, writing to the file will provide input for list. If the <(list) form is used, the file passed as an argument should be read to obtain the output of list. Note that no space may appear between the < or > and the left parenthesis, otherwise the construct would be interpreted as a redirection.
For example:
$ cat < <(ls)
$ (echo "YES")> >(read str; echo "1:${str}:first";)> >(read sstr; echo "2:$sstr:two")> >(read ssstr; echo "3:$ssstr:three")
See also:
Invisible characters mess js and css up
Some invisible characters may cause program fault, and it’s hard to locate.
For example UTF-8 BOM in the middle of css file may interrupt the css parser, you can find it by
find . -name '*.js' -type f -print0 | xargs -0 grep -r $'\xEF\xBB\xBF'
UTF-8 Line Separator may cause the debugger misunderstand the right line, you can find it by
find . -name '*.js' -type f -print0 | xargs -0 grep -r $'\xe2\x80\xa8'
And you also can cat to display all non-printing characters
BSD cat
cat -evt file
GNU cat
cat -A file
Or sed (better for multi-byte characters)
sed -n "l" file
Fix rtl8192cu monitor mode on raspberry pi
The rtlwifi(for Wifi chips such as those based on Realtek’s 8192cu) is the upstream driver and rtl8192cu is the out-of-stream driver, and the rtlwifi driver seems to be rather unstable on the Raspberry PI (It works fine on x86 machines), so it doesn’t generally get included in most distributions, in the commit 6d4d3a978afbc332af02e548bd0e8ced16dff296 non-mainline source for rtl8192cu wireless driver
is added and rtlwifi is disabled for stabilization. The result is you can not use monitor mode any more.
$ sudo iwconfig wlan0 mode monitor
Error for wireless request "Set Mode" (8B06) :
SET failed on device wlan0 ; Invalid argument.
The only way to solve it is to build your own kernel… (T▽T)
Follow the raspberry manual to build kernel, notice you should change some files before compiling.
Enable the rtlwifi
Uncomment this line in drivers/net/wireless/Makefile
#obj-$(CONFIG_RTLWIFI) += rtlwifi/
Also uncomment this line in drivers/net/wireless/Kconfig
#source “drivers/net/wireless/rtlwifi/Kconfig”
Fixing the regulatory domain (CRDA)
The rtlwifi driver ignores the regulatory set by the CRDA service. Cause of that the card will only have channels 1 to 11 and runs at maximum 20 dBm. This is the world standard of CRDA.
The easiest way is to modified the world standard definition in the driver.
Changing this line
#define RTL819x_2GHZ_CH01_11 \
REG_RULE(2412-10, 2462+10, 40, 0, 20, 0)
To
#define RTL819x_2GHZ_CH01_11 \
REG_RULE(2412-10, 2484+10, 40, 0, 33, 0)
The REG_RULE function is defined as follow:
REG_RULE(min_freq, max_freq, kHz, max_dbm_with_antenna, max_dbm, flags)
So the value I changed will make them to use all 14 channels available worldwide and to use a maximum dBm of 33 (what is about 2000 mW). Of course you can change it to any value reasonable.
Then you can compile the kernel, after that, you have to add the 8192cu to blacklist avoiding the supplied driver. modify or add /etc/modprobe.d/8192cu.conf
blacklist 8192cu
Ok, that’s all I fixed.
I do not find any wrong using the old rtlwifi driver so far, but if you wanna recover to the original driver, just comment the blacklist in the 8192cu.conf.