Micro:bit 使用 c 開發,可使用 線上開發 或 離線開發
但是 線上開發的版本沒有更新,導致新的板子無法使用
加速度和磁力計有兩種不同版本, MMA8653 和 LSM303
離線開發是使用 yotta
yotta 安裝方式
參考 yotta Documentation 和 Yotta
$ sudo apt-get update
$ sudo apt-get install python-setuptools cmake build-essential ninja-build python-dev libffi-dev libssl-dev
$ sudo easy_install pip
$ pip install yotta
$ sudo mkdir -p /usr/local/lib/yotta_modules
$ sudo chown $USER /usr/local/lib/yotta_modules
$ chmod 755 /usr/local/lib/yotta_modules
$ sudo apt-get remove binutils-arm-none-eabi gcc-arm-none-eabi
$ sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
$ sudo apt-get update
$ sudo apt-get install gcc-arm-embedded
$ sudo apt-get install clang-3.9
$ pip install --upgrade cryptography
$ sudo apt-get install srecord
$ git clone https://github.com/lancaster-university/microbit-samples
$ yt target bcc-microbit-classic-gcc
$ cd microbit-samples
$ cp source/examples/bluetooth-services/* source/
$ yt clean
$ yt build
資料產生於 build/bcc-microbit-classic-gcc/source/microbit-samples-combined.hex
2020年5月4日 星期一
2020年4月27日 星期一
sftp lftp
伺服器端可以安裝簡易版的 Rebex Tiny SFTP Server
客戶端
若是 win7 需要
安裝 Microsoft .NET Framework 4
安裝 Microsoft .NET Framework 4.5
安裝 PowerShell 3.0
使用 administrator 開啟 powershell
install Chocolatey 它就像是 windows 版的 apt-get
再安裝 lftp
man lftp
download
lftp -c "set sftp:auto-confirm yes; open -u username,passowrd -p port sftp://ip; mirror -e -p remote_path local_path; quit"
upload
lftp -c "set sftp:auto-confirm yes; open -u username,passowrd -p port sftp://ip; mirror -e -p -R local_path remote_path; quit"
windows path to unix path
d:\path
/cygdrive/d/path
客戶端
若是 win7 需要
安裝 Microsoft .NET Framework 4
安裝 Microsoft .NET Framework 4.5
安裝 PowerShell 3.0
使用 administrator 開啟 powershell
install Chocolatey 它就像是 windows 版的 apt-get
再安裝 lftp
PS C;\> Get-ExecutionPolicy
PS C;\> Set-ExecutionPolicy AllSigned
PS C;\> Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
PS C;\> choco install lftp
man lftp
download
lftp -c "set sftp:auto-confirm yes; open -u username,passowrd -p port sftp://ip; mirror -e -p remote_path local_path; quit"
upload
lftp -c "set sftp:auto-confirm yes; open -u username,passowrd -p port sftp://ip; mirror -e -p -R local_path remote_path; quit"
mkdir
lftp -c "set sftp:auto-confirm yes; open -u username,password -p port sftp://ip; mkdir -p /pathA/pathB; quit"
cd, lcd, mput
lftp -c "set sftp:auto-confirm yes; open -u username,password -p port sftp://ip; lcd /localPath; cd /remotePath; mput *; quit"
mirror with Regular Expression
lftp -c "set sftp:auto-confirm yes; open -u username,password -p port sftp://ip; mirror -x 'jpg$' -R /localPath /remotePath; quit"
lftp -c "set sftp:auto-confirm yes; open -u username,password -p port sftp://ip; mirror -i 'ini$|sign$' -R /localPath /remotePath; quit"
windows path to unix path
d:\path
/cygdrive/d/path
2020年4月22日 星期三
git rebase 更改 commit 順序
git checkout master
git rebase -i <要修改的前一個 hash>
更改 pick 順序,越上面越舊,越下面越新
git push origin +master
更改遠端
2020年4月10日 星期五
git 跟上 fork 出的進度
怎麼跟上當初 fork 專案的進度?
最簡單的方式,就是砍掉重練
或是,展現你手動的技術
查詢遠端節點
$ git remote -v
一開始應該只有你 fork 出的 origin
加入 upstream
$ git remote add upstream http://192.168.0.101:8080/user1/VisualStudioTest.git
若是 url 寫錯
$ git remote set-url upstream http://192.168.0.101:8080/user/VisualStudioTest.git
$ git remote -v
最簡單的方式,就是砍掉重練
或是,展現你手動的技術
查詢遠端節點
$ git remote -v
一開始應該只有你 fork 出的 origin
加入 upstream
$ git remote add upstream http://192.168.0.101:8080/user1/VisualStudioTest.git
若是 url 寫錯
$ git remote set-url upstream http://192.168.0.101:8080/user/VisualStudioTest.git
$ git remote -v
此時就可查到 origin 和 upstream
下載 upstream 的更新
$ git fetch upstream
merge 本地的 master 到 upstream 的 master
$ git merge upstream/master
更新 fork 出的專案
$ git push origin master
Windows route for two networks
regedit.exe
設定
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\IPEnableRoute 為 1
Services.msc
Routing and Remote Access
Startup type: Automatic
按 Start
設定
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\IPEnableRoute 為 1
Services.msc
Routing and Remote Access
Startup type: Automatic
按 Start
2020年3月23日 星期一
mysql 操作
$ sudo mysql -u root -p
[sudo] password for user: 輸入 os root 密碼
Enter password: 輸入 mysql root 密碼
顯示所有 database
> show databases;
進入某個資料庫
> use db_name;
顯示 資料庫內 所有資料表
> show tables;
顯示 資料表的欄位
> describe tab_name;
顯示 資料表的欄位細節
> show full columns from tab_name;
顯示所有使用者
> describe mysql.user;
> select host, user from mysql.user;
顯示使用者權限
> describe mysql.db;
> select host, db, user from mysql.db;
顯示 grant 的權限
> show grants for 'user'@'%';
> show grants for 'user'@'localhost';
建立使用者
> create user 'user'@'hostname' identified by 'password';
hostname 可以為 ip 或 % 表示任何ip
刪除使用者
> drop user 'user'@'hostname';
grant 權限
> grant all on db_name.* to 'user'@'localhost';
移除 grant 權限
> revoke all privileges on db_name.table from 'user'@'hostname';
建立資料庫
> create database db_name;
刪除資料庫
> drop database db_name;
建立資料表
> create table tab_name (
id int not null auto_increment,
name varchar(50) not null,
desc varchar(200),
price int not null,
primary key(id)
);
刪除資料表
> drop table tab_name;
執行 sql 檔
> source file.sql
> \. file.sql
shell 直接執行 sql
$ mysql -u root -p < file.sql
執行 shell
> system ls
> \! ls
[sudo] password for user: 輸入 os root 密碼
Enter password: 輸入 mysql root 密碼
顯示所有 database
> show databases;
進入某個資料庫
> use db_name;
顯示 資料庫內 所有資料表
> show tables;
顯示 資料表的欄位
> describe tab_name;
顯示 資料表的欄位細節
> show full columns from tab_name;
顯示所有使用者
> describe mysql.user;
> select host, user from mysql.user;
顯示使用者權限
> describe mysql.db;
> select host, db, user from mysql.db;
顯示 grant 的權限
> show grants for 'user'@'%';
> show grants for 'user'@'localhost';
建立使用者
> create user 'user'@'hostname' identified by 'password';
hostname 可以為 ip 或 % 表示任何ip
刪除使用者
> drop user 'user'@'hostname';
grant 權限
> grant all on db_name.* to 'user'@'localhost';
移除 grant 權限
> revoke all privileges on db_name.table from 'user'@'hostname';
建立資料庫
> create database db_name;
刪除資料庫
> drop database db_name;
建立資料表
> create table tab_name (
id int not null auto_increment,
name varchar(50) not null,
desc varchar(200),
price int not null,
primary key(id)
);
刪除資料表
> drop table tab_name;
執行 sql 檔
> source file.sql
> \. file.sql
shell 直接執行 sql
$ mysql -u root -p < file.sql
執行 shell
> system ls
> \! ls
ubuntu eclipse install
參考 Ubuntu 1804 桌面版 Eclipse + JSP 學習記錄
$ java -version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number:
$ vi ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export CLASSPATH=.:${JAVA_HOME}/lib
export PATH=${JAVA_HOME}/bin:${PATH}
$ source ~/.bashrc
到網頁 https://www.eclipse.org/
找到要下載的 linux 64 bit 版本 https://www.eclipse.org/downloads/download.php?file=/oomph/epp/2020-03/R/eclipse-inst-linux64.tar.gz
$ cd Downloads/
$ tar xvf eclipse-inst-linux64.tar.gz
$ cd eclipse-installer/
為避免
Caused by: java.io.FileNotFoundException: /home/user1/Downloads/eclipse-installer/configuration/org.eclipse.osgi/.manager/.fileTableLock (Permission denied)
$ sudo chown -RH mark: configuration/
有人使用 $ sudo ./eclipse-inst, 但安裝完成後,只能用 $ sudo ./eclipse 啟動
$ ./eclipse 會出現 /root/.p2/pool/plugins/org.eclipse.equinox.launcher.gtk.linuxx86_64.1.1.1100.v20190907-0426: cannot open shared object file: Permission denied
$ ./eclipse-inst
選擇 Eclipse IDE for Enterprise Java Developers
選擇 java 版本和安裝路徑
$ sudo rm -rf eclipse-installer/ eclipse-inst-linux64.tar.gz
$ cd
安裝桌面啟動捷徑
$ vi ~/.local/share/applications/eclipse.desktop
$ chmod +x ~/.local/share/applications/eclipse.desktop
下載 gson-2.8.6.jar 到 專案下的 WEB-INF/lib 下
Project Explorer/專案名稱 右鍵 Export/WAR file
$ java -version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)
$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode
1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode
2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
Press <enter> to keep the current choice[*], or type selection number:
$ vi ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export CLASSPATH=.:${JAVA_HOME}/lib
export PATH=${JAVA_HOME}/bin:${PATH}
$ source ~/.bashrc
到網頁 https://www.eclipse.org/
找到要下載的 linux 64 bit 版本 https://www.eclipse.org/downloads/download.php?file=/oomph/epp/2020-03/R/eclipse-inst-linux64.tar.gz
$ cd Downloads/
$ tar xvf eclipse-inst-linux64.tar.gz
$ cd eclipse-installer/
為避免
Caused by: java.io.FileNotFoundException: /home/user1/Downloads/eclipse-installer/configuration/org.eclipse.osgi/.manager/.fileTableLock (Permission denied)
$ sudo chown -RH mark: configuration/
有人使用 $ sudo ./eclipse-inst, 但安裝完成後,只能用 $ sudo ./eclipse 啟動
$ ./eclipse 會出現 /root/.p2/pool/plugins/org.eclipse.equinox.launcher.gtk.linuxx86_64.1.1.1100.v20190907-0426: cannot open shared object file: Permission denied
$ ./eclipse-inst
選擇 Eclipse IDE for Enterprise Java Developers
選擇 java 版本和安裝路徑
$ sudo rm -rf eclipse-installer/ eclipse-inst-linux64.tar.gz
$ cd
安裝桌面啟動捷徑
$ vi ~/.local/share/applications/eclipse.desktop
[Desktop Entry]
Type=Application
Name=Eclipse
Comment=Eclipse Integrated Development Environment
Icon=/home/user1/eclipse/jee-2020-03/eclipse/icon.xpm
Exec=/home/user1/eclipse/jee-2020-03/eclipse/eclipse
Terminal=false
Categories=Development
StartupWMClass=Eclipse
重新開機
按 Search, 找 Eclipse, 按右鍵, Add to Favorites
Eclipse 設定 Tomcat server
$ wget http://ftp.tc.edu.tw/pub/Apache/tomcat/tomcat-9/v9.0.33/bin/apache-tomcat-9.0.33.tar.gz
$ tar xvf apache-tomcat-9.0.33.tar.gz
開啟 eclipse
Window/Preferences
Server/Runtime Environment
按 Add, 選擇 Apache Tomcat v9.0
設定 Tomcat installation directory: 到剛才解壓縮的路徑
Window/Show View/Other...
選擇 Servers
按 ProjectExplorer/Servers/Tomcat v9.0 Server at localhost-config/server.xml
修改 port
建立 Eclipse 專案
File/New/Dynamic Web Project
輸入專案名稱
在 Web Module 頁中,將 Generate web.xml deployment descriptor 打勾
Project Explorer/專案名稱/WebContent 右鍵 New/JSP File
下載 gson-2.8.6.jar 到 專案下的 WEB-INF/lib 下
處理 json
Project Explorer/專案名稱 右鍵 Export/WAR file
訂閱:
文章 (Atom)