2022年3月13日 星期日
解決Firefox觀看twitch、youtube直播時的卡頓問題
2022年1月30日 星期日
2021年6月6日 星期日
2021年6月5日 星期六
2021年6月1日 星期二
程式三大定律
最近閱讀「我Rust我驕傲」,書中提到程式的三大定律
- 程式必須正確
- 程式必須可維護,但不能違反第一項定律
- 程式必須高效,但不能違反前兩項定律
2019年3月29日 星期五
Doom emacs installation
Doom emacs installation
git clone https://github.com/hlissner/doom-emacs ~/.emacs.d cd ~/.emacs.d git checkout develop cd bin/ ~/.emacs.d/bin/doom -y quickstart ~/.emacs.d/bin/doom -y refresh
2019年3月20日 星期三
cscope and gtags
cscope
find ./ -name "*.c" -o -name "*.h" | awk '{printf("\"%s\"\n", $0)}' > cscope.files cscope -Rbq -i cscope.files
we need to deal with spaces in the path for cscope.
global gtags
find ./ -name "*.c" -o -name "*.h" > gtags.files gtags
2019年1月31日 星期四
孟氏定理或梅涅劳斯定理
證明
透過正弦定理,有\[\frac{AN}{AM} = \frac{\sin\beta}{\sin\alpha} \] 同理可得,\[\frac{BL}{BN} = \frac{\sin\alpha}{\sin\gamma} , \frac{CM}{CL} = \frac{\sin\gamma}{\sin\beta} \] 相乘即可得 \[\frac{AN}{AL} \cdot \frac{BL}{BN} \cdot \frac{CM}{CL} = \frac{\sin\beta}{\sin\alpha} \cdot \frac{\sin\alpha}{\sin\gamma} \cdot \frac{\sin\gamma}{\sin\beta} = 1 \]
2018年2月24日 星期六
2017年2月12日 星期日
ubuntu 中使用 usb 連接 iphone 並傳送檔案給 app
目錄
需要環境
libimobiledevice4
ifuse
usbmuxd
安裝 libimobiledevice4
執行
sudo apt-get build-dep libimobiledevice4 git clone https://github.com/libimobiledevice/libimobiledevice cd libimobiledevice/ ./autogen.sh make sudo make install
注意:可以先記錄 build-dep 所安裝的 packages,以免失敗時可以解除安裝
安裝 ifuse
執行
sudo apt-get build-dep ifuse git clone https://github.com/libimobiledevice/ifuse.git cd ifuse/ ./autogen.sh make sudo make install
注意:可以先記錄 build-dep 所安裝的 packages,以免失敗時可以解除安裝
安裝 usbmuxd
sudo apt-get install usbmuxd
連接 iphone usb
先執行
usbmuxd
接著插入iphone usb,並執行
dmesg | grep ipheth
連接成功應該會出現 Apple iPhone USB Ethernet device attached 等類似字樣,若無則重覆上述二步驟
配對 iphone
執行
idevicepair pair
配對成功應該會出現 SUCCESS: Paired with device … 等類似字樣 注意:在配對時,要在iphone上按下「信任」鍵
列出iphone可以分享檔案的app
執行
ifuse --list-apps
應該會出現類現以下的字樣: com.kmplayer.mplayer, "2.1.3", "KMPlayer" com.foxitcorporation.reader, "5.3.2.0117", "Foxit PDF"
掛載分享檔案的資料夾
下面以kmplayer為例 執行
mkdir kmplayer ifuse --documents com.kmplayer.mplayer kmplayer/
接著便可以將影片檔案放入此資料夾內
卸載 和 取消配對
執行
fusermount -u kmplayer idevicepair unpair
2014年4月22日 星期二
中州韻 fcitx-rime 嘸蝦米 配置 ~~用了我二十分鐘
目錄
安裝fcitx-rime
使用apt-get
sudo apt-get install fcitx-rime
"重新啟動fcitx"
取得Rime schema與dict檔
由於有版權問題~~,所以請參考下面的連結
接下來,複製壓縮檔內4個文件(liur.schema.yaml、liur.dict.yaml、Phonetic_tw.schema.yaml、Phonetic_tw.dict.yaml)
到 ~/.config/fcitx/rime/ 裡
編譯 (文件中似乎沒有提到,但不用不行)
cd ~/.config/fcitx/rime rime_deployer --compile liur.schema.yaml . rime_deployer --compile Phonetic_tw.schema.yaml .
修改 default.yaml
在schema_list選項中,加入 - schema: liur
"重新啟動fcitx"
直接看影片教學
(尚未製作)
2014年4月2日 星期三
安裝最新版的 emacs ppa
第一步:
加入ubuntu-elisp ppa
sudo add-apt-repository ppa:ubuntu-elisp/ppa
第二步:
更新
sudo apt-get update
第三步:
安裝emacs-snapshot
sudo apt-get install emacs-snapshot
參考資料:
By my own
2014年3月20日 星期四
latex 使用 titlesec package 修改 section 標題時會影響 toc
解決方法
不使用titlesec,直接重新定義section 與 subsection
\makeatletter
\renewcommand{\section}{\@startsection
{section}% % the name
{1}% % the level
{\z@}% % the indent / 0mm
{-\baselineskip}% % the before skip / -3.5ex \@plus -1ex \@minus -.2ex
{0.5\baselineskip}% % the after skip / 2.3ex \@plus .2ex
{\hspace{25pt}\normalsize}} % the style
\makeatletter
\renewcommand{\subsection}{\@startsection
{subsection}% % the name
{1}% % the level
{\z@}% % the indent / 0mm
{-\baselineskip}% % the before skip / -3.5ex \@plus -1ex \@minus -.2ex
{0.5\baselineskip}% % the after skip / 2.3ex \@plus .2ex
{\hspace{50pt}\normalsize}} % the style
2014年3月18日 星期二
MathJax -- JavaScript display math engine
- This is an inline math use \( \backslash ( \) and \( \backslash ) \) example: \( sin^\theta + cos^\theta = 1 \)
- This is an display math use \( \backslash[ \) and \( \backslash[ \) example: \[ e^{i\theta} = cos\theta + isin\theta \]
- If you want to know about the TeX Command(if the formula write by TeX) or MathML code just right click the formula.
2014年3月4日 星期二
UVA 10295 - Hay Points
#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <climits> #include <vector> #include <string> #include <sstream> #include <algorithm> #include <map> #include <bitset> #define MAX 10000 using namespace std; typedef long long int lli; int main(int argc, char *argv[]){ int m, n; string word; int value; map<string, int> dictionary; map<string, int>::iterator it; cin >> m >> n; for (int i=0; i<m; ++i){ cin >> word >> value; dictionary[word]=value; } string s; while (n--){ int salary = 0; while (cin >> s && s!="."){ it = dictionary.find(s); if (it!=dictionary.end()) salary += it->second; } cout << salary << endl; } return 0; }
2014年2月24日 星期一
UVA 10127 - Ones
#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <vector> #include <string> #include <sstream> #include <algorithm> #include <map> #include <bitset> #define MAX 1000000 using namespace std; typedef long long int lli; int main(int argc, char *argv[]){ int n; while (cin >> n){ int digit=1, number=1; for (int number=1; number%n!=0; number=number*10+1, number%=n) digit++; cout << digit << endl ; } return 0; }
c048: Ant on a Chessboard
#include <stdio.h> #include <math.h> int main(int argc, char *argv[]) { int N ; int layer ; int base ; int displace ; int coor[2] ; while(scanf("%d",&N) && N){ N-- ; layer = floor(sqrt(N))+1; base = layer*(layer-1) ; displace = N-base ; coor[0] = coor[1] = layer ; if(layer%2 == 1) if(displace > 0) coor[0] -= displace ; else coor[1] += displace ; else if(displace > 0) coor[1] -= displace ; else coor[0] += displace ; printf("%d %d\n", coor[0], coor[1]) ; } return 0; }
2014年2月14日 星期五
UVA 10340 - All in All
#include <iostream> #include <cstdio> #include <cmath> #include <vector> #include <string> #include <sstream> #include <algorithm> #include <map> #include <bitset> #define MAX 1000000 using namespace std; typedef long long int lli; int main(int argc, char *argv[]){ string s, t; int i, j; while (cin >> s >> t){ i=0, j=0; while (i!=t.length()){ if (s[j]==t[i]) ++j; ++i; } cout << (j==s.length() ? "Yes" : "No") << endl; } return 0; }
UVA 10298 - Power Strings
#include <iostream> #include <cstdio> #include <cmath> #include <vector> #include <string> #include <sstream> #include <algorithm> #include <map> #include <bitset> #define MAX 1000000 using namespace std; typedef long long int lli; int main(int argc, char *argv[]){ string s; bool isPowerString=true; while (getline(cin, s) && s!="."){ for (int i=1; i<=s.length(); ++i){ if (s.length()%i != 0) continue; isPowerString = true; for (int j=i; j<s.length(); j+=i){ for (int k=0; k<i; ++k) if (s[k] != s[k+j]){ isPowerString=false; break; } if (isPowerString==false) break; } if (isPowerString==true){ cout << s.length()/i << endl; break; } } } return 0; }



