2021年5月28日 星期五

power point 調整圖片透明

Power point沒辦法直接調整圖片透明度,but有個work around
1.插入圖形方塊
*不是直接插入圖片喔
2.將方塊的線條調整成無線條
3.將方塊的背景填滿改成以圖形填滿,再去選擇要插入的圖片,這時候就可以調整透明度囉

測試office版本2019

power point 調整圖片透明

2021年5月27日 星期四

MPV ubuntu 下好用的播放器 video player


本來是用VLC player,但因為有些影片只有部份是有效資訊,vlc的放大跟平移又是世界難用,所以找到了MPV
mpv 基本用法是
$ mpv 要播放的檔名

舊版本自訂熱鍵

用Ubuntu 18.04內建的reopsitry抓到的是有點舊的版本 雖然是可以透過自訂熱鍵達成zoom跟pan,
方法是:
在 ~/.config/mpv/ 中新增 input.conf 內容是
Alt+- add video-zoom -0.25
Alt+= add video-zoom 0.25
Alt+h add video-pan-x 0.05
Alt+l add video-pan-x -0.05
Alt+k add video-pan-y 0.05
Alt+j add video-pan-y -0.05

自行compile

但要是抓新版的就不用這麻煩了
本來想說要去github抓下來自己build,但過程中一直缺fribidi這個套件,
但其中遇到一些問題 
0. 可以先做這步,git 的readme有提到,但我之前沒看到
$ apt-get install devscripts equivs
$ mk-build-deps -s sudo -i
$ dpkg-buildpackage -uc -us -b -j4
完成之後mpv_<version>_<architecture>.deb會在上層目錄被產生,用下面指令安裝
$ sudo dpkg -i ../mpv_<version>_<architecture>.deb
1.需要 fribidi
其實是需要 fribidi-dev 
2.yasm太舊
$ sudo apt-get install yasm 

直接用第三方repository安裝

$ sudo add-apt-repository ppa:mc3man/mpv-tests
$ sudo apt-get install mpv

Hotkeys

alt+方向鍵: pan
alt++/-: zoom

MPV ubuntu 下好用的播放器 video player

2021年5月20日 星期四

[Ubuntu] Silver Searcher , a fast code searching tool

The Silver Searcher 

A code searching tool similar to ack, with a focus on speed.

github

install on ubuntu

sudo apt-get install silversearcher-ag

usage

search i_am_sample_code in /

sudo ag --silent i_am_sample_code /

[Ubuntu] Silver Searcher , a fast code searching tool

2021年5月19日 星期三

Install Bash 5.1 on ubuntu 18.04

在看bash reference manual的時候發現一些功能不能用,懷疑是18.04的bash版本太舊想說更新看看
需要自己build bash
sudo apt-get install build-essential

clone the source 

https://github.com/bminor/bash

cd to the code directory
./configure
make
sudo make install
sh

完成之後,bash會被放到/usr/local/bin/bash
接著如果要指定成預設的shell,要編輯 /etc/shells 將 /usr/local/bin/bash加入
之後再
$ chsh
輸入密碼之後
/usr/local/bin/bash
之後重新登入

Install Bash 5.1 on ubuntu 18.04

cherrytree on ubuntu 18.04

it's hard to install the latest (0.99.36) cherrytree on ubuntu 18.04
I think the easiest way is install the flatpak package
0.99.36 have improved a lot from the default 0.39.4 version, it's worth for update

cherrytree on ubuntu 18.04

2021年5月8日 星期六

[linux] 用sed將文件中的換行換成空白

最近因為需要翻譯(用google translate)一些文件,但那些文件因為排版需要,有很多不必要的換行,擔心會影響到翻譯品質
但有個好處是,他真的要換行的地方連續換行兩次

如果在windows中有msWord,可以用搜尋找出連續換行,取代成特殊符號,再取代獨立的換行
linux中邏輯也類似,但用sed這套很強的搜尋取代程式來做到

除此之外順便把他弄成script,以後要使用比較方便 

$1是來源檔案$2是目標檔案
#!/bin/bash
# remove $1's single \n and save to $2
sed ':a;N;$!ba;s/\n\{2\}/%@%/g;s/\n/ /g; s/%@%/\n/g' $1 > $2

將上面這段存成 fixNl.sh再用
$fixNl.sh source dest

就會將source中了內容轉換dest了

source sample:
1
2
3

4
5
6

7
8
9

dest sample:
1 2 3
4 5 6
7 8 9

[linux] 用sed將文件中的換行換成空白

2021年5月6日 星期四

[C++] && rvalue 暫時存在的Object

 ref

myClass f() {...};
myClass X,Y; 
myClass A(X);        // 1.
myClass B(X+Y);      // 2.
myClass C(f());      // 3.
在三種狀況中 2,3 與 1是不一樣的﹔
 2,3 中的 X+Y與f(X) 都會產生一個暫時性的Object,在執行完該行後消失。
 因此C++ 11為這種狀況搞了個rvalue, 2,3就屬於rvalue
相對於rvalue的就是lvalue
lvalue: locator value: an object that occupies some identifable location in memory: 在記憶體上佔有一定空間的物件 

在 C++ 中有兩種constructor

//copy constructor
myClass(myClass const& other){} 
//move constructor
myClass(myClass&& other){}
其中move constructor就是當傳入的是rvalue (myClass&&)的時候可以做一些特殊處理
譬如說,可以把rvalue的記憶體拿來使用,因為這行程式結束之後rvalue也不不存在了

[C++] && rvalue 暫時存在的Object

[c++] method()=delete

C++11的新功能
這是 suppressing operation
當寫 method()=delete的時候,呼叫method()是被compiler禁止的

[c++] method()=delete

2021年5月5日 星期三

[ubuntu] 文件瀏覽器less使用教學

less使用說明

f下一頁b 上一頁
用/可以向下搜尋字串 n是下一個match shift+n上一個match
g去檔頭G去檔尾,g後面也可以輸入行數
q離開
h叫出使用說明
有趣的是,less的說明也是用less開的

[ubuntu] 文件瀏覽器less使用教學

ubuntu bash教學

$man bash
會用less打開bash的說明書

less 的用法可以參考 less教學

可以搜尋moving
或history等等關鍵字

ubuntu bash教學

[ubuntu] bash 搜尋歷史指令

用
$history 
可以看完整歷史
另外用
ctrl+r可以 往回搜尋之前用過的指令

[ubuntu] bash 搜尋歷史指令

[ubuntu] bash幫指令取縮寫

前面提到要把檔案丟到回收桶要用指令
$gio trash 檔名,可不可以改成用trash?
在~/.bashrc中加入
alias trash='gio trash'
之後再
$source .bashrc就可以囉
其他覺得新手可以加入的alias還有
alias rm='rm -i'
避免一次砍掉太多不該砍的東西
這樣一次真要刪除很多檔案的時候可以用
$rm -I 

[ubuntu] bash幫指令取縮寫

ubuntu刪除多個檔案

上一篇有提到一次建立test1, test2, test3三個檔案的方式,如果要一次刪除他們
$rm test*
這樣就會全部刪掉,但如果怕誤刪其他test什麼的可以用
$rm test* -i
在刪除每個檔案前會再次確認
或是丟到資源回收筒再一次刪除可能比較安心可以用
$gio trash test*

ubuntu刪除多個檔案

ubuntu建立多個檔案

ubuntu快速建立檔案內容

譬如說要建立一個檔案,名稱是test, 內容是 "test file"可以用下面指令
$echo "test file">test

ubuntu快速建立檔案內容

[ubuntu]不需要sudo權限重開機

一般在ubuntu要重開機要用
$sudo reboot
但這樣會被要求輸入admin的密碼
這時候可以在 /etc/sudoers.d/中新增任意檔名的檔案
內容是
username ALL = NOPASSWD: /sbin/reboot

[ubuntu]不需要sudo權限重開機

2021年4月26日 星期一

[Raspbian]raspberry pi 中文輸入法

 不知為何gcin就是無法在我的8G版本上work

後來改用fcitx就沒問題了..

安裝指令

$ sudo apt-get install fcitx fcitx-chewing

安裝完成後再去

menu > preference > input method 去選fcitx

安裝方式請參考

https://medium.com/gcc-me-c/fcitx-chewing-%E6%96%B0%E9%85%B7%E9%9F%B3%E4%B8%AD%E6%96%87%E8%BC%B8%E5%85%A5%E6%B3%95%E5%AE%89%E8%A3%9D-7f06b16b3e51

[Raspbian]raspberry pi 中文輸入法

[Raspbian][ raspberry pi ] dock window 與熱鍵修改

 pi 的os 竟然沒辦法dock window...

這樣基本的功能,難道沒人把它當便宜主機用嗎?

因為解決方法有點小麻煩,這邊就紀錄一下

ref: https://pastebin.com/NBkccE7B

使用方法基本上就是用win + q/w/e/a/d/z/x/c 將視窗移到各個角落

win + s 全螢幕, win+shift+s縮小

but.. 因為pi 預設 win 一按下去就會打開 lxpanelctl menu我把<keybind key="Super_L">小改了一下變成

    <keybind key="Super_L-m">
      <action name="Execute">
        <command>lxpanelctl menu</command>
      </action>
    </keybind>

首先要先找到設定熱鍵的檔案(/home/pi/.config/openbox/lxde-pi-rc.xml),然後用某個文字編輯器(pi os 預裝有geany,就決定是你了)開啟它

~$ geany /home/pi/.config/openbox/lxde-pi-rc.xml

這個檔案裡面可以找到所有pi可以用的hotkeys~
首先找到 <keyboard> 這個tag 
加入下面一狗票,改完之後存檔重開機 或是在terminal 中輸入
$ openbox-lxde --reconfigure
就可以囉

    <keybind key="W-a">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>100%</height>
    <x>0%</x>
    <y>0%</y>
  </action>
</keybind>
<keybind key="W-d">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>100%</height>
    <x>50%</x>
    <y>0%</y>
  </action>
</keybind>
<keybind key="W-x">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>100%</width>
    <height>50%</height>
    <x>0%</x>
    <y>50%</y>
  </action>
</keybind>
<keybind key="W-w">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>100%</width>
    <height>50%</height>
    <x>0%</x>
    <y>0%</y>
  </action>
</keybind>
<keybind key="W-q">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>50%</height>
    <x>0%</x>
    <y>0%</y>
  </action>
</keybind>
<keybind key="W-e">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>50%</height>
    <x>50%</x>
    <y>0%</y>
  </action>
</keybind>
<keybind key="W-z">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>50%</height>
    <x>0%</x>
    <y>50%</y>
  </action>
</keybind>
<keybind key="W-c">
  <action name="UnmaximizeFull"/>
  <action name="MoveResizeTo">
    <width>50%</width>
    <height>50%</height>
    <x>50%</x>
    <y>50%</y>
  </action>
</keybind>
<keybind key="W-s">
  <action name="Maximize"/>
</keybind>
<keybind key="W-S-s">
  <action name="Iconify"/>
</keybind>


[Raspbian][ raspberry pi ] dock window 與熱鍵修改

2021年4月25日 星期日

raspberry pi 截圖 without printscreen 按鍵

Microsoft的all in one 鍵盤加觸控板不知為何沒有printscreen鍵..

只好用terminal呼叫截圖程式

先用ctrl+alt+t打開termainal

呼叫scrot截圖

它還可以帶一些參數呼叫

scrot -s 框選擷取範圍

scrot -sb 選取視窗

scrot -d num num秒後截圖

scrot -cd num 倒數num秒後截圖

截下來的圖都會放在 ~目錄

raspberry pi 截圖 without printscreen 按鍵

[Raspbiam]raspberry pi4時鐘格式

 用Raspbian OS 若想把toolbar換到左/右邊可以在工具列上

右鍵 > Panel settings > Position > Edge 去選擇工具列位置

如果選側邊,可以把Size調整成跟icon size差不多比較簡潔

後pi預設是多的視窗不會合併,這可以從

task bar(window list) settings > combine multiple application windows into a single button 去設定

這時候還有個問題,時鐘分的部份會看不到分

這可以在時鐘那邊按右鍵

digital clock settings > clock format

例如我用的是

%a%n------%n %d%n%b%n------%n%H%n:%M

效果像這樣







[Raspbiam]raspberry pi4時鐘格式