解決Ubuntu 20.4 Deepin Wine QQ登入即當機的問題

(本篇已經過期,關於如何在Ubuntu上取得最新可用版的QQ,請參考以下文章:
https://zhuanlan.zhihu.com/p/428285559

自從因為一些私人原因每天都要用到QQ後,這玩意就成為了我用Linux時永遠的痛。
以前還有完美的WebQQ可以使用,現在沒有這個選項了。那麼到底該怎麼辦呢?你說用虛擬機吧,肯定不會出任何BUG,但Windows10佔的記憶體是真的太多了遭不住。
用第三方QQ客戶端吧,功能也挺完美的,但是討論組沒法正常用。

最後還是得投靠Deepin Wine上的QQ,但這玩意前陣子在更新後也沒有辦法正常運行了--只要一登入就會當住,閃退,根本沒法用。

最後的解決方案是這樣的:

1. 按照Github上的教程安裝Deepin-wine-ubuntu。
https://github.com/wszqkzqk/deepin-wine-ubuntu

2. 下載並安裝舊版的QQ軟體包:
wget https://gitee.com/wszqkzqk/deepin-wine-containers-for-ubuntu/raw/master/deepin.com.qq.im_9.1.8deepin0_i386.deb
sudo dpkg -i deepin.com.qq.im_9.1.8deepin0_i386.deb

3. 登出系統並重新登入。

4. 如同平常那樣使用Deepin QQ-看,成功了!

有夠蠢的。

Ubuntu 20.04上解決Gcin無法在FocusWriter等軟件上輸入中文的問題

Gcin和Hime一向都是我最喜歡的中文輸入法,然而前者在某些軟件上(例如我平常寫作用的FocusWriter)無法輸入中文,而Hime則是有著同樣的問題之餘,還會跟Android Studio和VLC等軟體衝突,因此一直讓我感到非常苦惱。

後來我發現Gcin社區上有人遇到跟我一樣的問題,決定在這裡分享自己的解決方法--那就是不要安裝Ubuntu 20.04自帶的Gcin!

以下是Gcin官方網站上提供的新版套件,以及它的安裝方法:

sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys 835AB0E3
sudo add-apt-repository “deb http://hyperrate.com/gcin-ubuntu2004 eliu release”
sudo apt-get update
sudo apt-get install gcin

在安裝之前,記得-一定要-徹底移除舊版Gcin,否則會發生衝突而無法順利安裝!

完成之後,FocusWriter就應該能夠順利輸入中文了。祝寫作愉快!

 

平田志穗子- Ying Yang 歌詞翻譯

no no no no “yes yes yes yes”

no no no no “yes yes yes yes”

ain’t no such thing as trust nor justice
信任也好 正義也好 這世上並不存在

so disgusting y’all ass kissers
所以你們才要隱藏自己 像條噁心的馬屁蟲般委曲求全

y’all die spell curse came from hell
我要從地獄詛咒你們全都去死!

“past is what you don’t wanna dwell”
「你也不想沉溺於過去吧?」

it’s all BS it’s all garbage
閉嘴 你們這群垃圾 說的全是廢話

“I say neither, it’s vice versa”
「不是的 並非如此」

lost in himself
他已迷失於

maze he has made
自己創造的迷宮

“just trying to reach out reach out
「無論如何努力逃避

ain’t those bluffings gonna get you out”
自欺欺人都不會讓你得到解脫」

hmm… nothing but middle finger
哼….而我卻只想對你舉中指

I hate talking to ignorants, stop the whimpers
所以我才討厭跟無知的小鬼說話,快閉上你那煩人的嘴

“misunderstanding man that’s too much overrreacting
「你誤會了 請不要如此激動

better go retract that
現在回頭還來得及

statements on it, you can’t own it”
你不能背負這一切」

I am flawless “more like thoughtless”
我是完美無缺的 「不,這只是在放棄思考」

chasing stars afar(so so far)
追遂遠方的繁星 (遙遠而漫長)

overlooks his own path(dark dark night)
卻迷失在路途上(在這深暗的夜晚)

where is light when needed he didn’t get it
在最需要光明的時侯 卻未能尋得

enough for a man to lose sight for a frail pride
足以讓人因為虛榮心而變得盲目

so lost in the starless night
在無星夜下彷徨

sun don’t rise
明日並不會迎接

on the blinded mind
陷入盲目的人

around and around there goes now
明明一切都是伸手能及

waiting for another falling
卻選擇等待他人與自己一同墮落

let their be stars to guide him the way
願那些人能成為繁星 為他指引道路

in this poor night
在這悲傷的夜晚裡

so numb he’s become so numb
變得麻木的他

ways of life
即使眼前有無數的道路

so exhausted
仍選擇放棄一切

he will not be who he’s not
因此他將無法改變自己

so sick of lies over lies but
厭惡無數謊言

can’t tell what is a lie anymore
到最後卻無法分清真假

he’s going so numb
只能停止思考

your crew love that gibberish
那些狗屁不通的話 只有你的伙伴會喜歡

to me that’s illiterate
對我來說不過是笑話

makes me want to obliterate it
讓人恨不得讓他們全數消失

“you just love being bitter-y? don’t ya
「你只是試圖用痛苦讓自己感覺好一點,不是嗎?

I am thinking you just might be
我開始覺得

you just like me I’m just lucky
你和我是如此相像…只是我比較幸運

just took it wrongfully and it just
而你則是誤入歧途

might not be entirely your fault”
但這些並非全是你的錯」

just let it go
放開執念

open the door
打開新的門扉

no words can mean anything at this point so we must battle
廢話不必多說 我們注定必須戰鬥

“that’s just you and that’s how you mishandle thing mishandle mishandle now!”
「你這樣執迷不悟 只會犯下更多的錯!」

now you’re telling me what to do?
你這是想指使我做事嗎?

let me tell you who rules
還是讓我來告訴你 誰才是掌管一切的人吧

“come on this ain’t nothing to rule over this matter brother
「不 我們並沒有上下之分

you and I we ain’t so different
你和我之間的差別

I guess I had more blessings
只是我得到更多祝福

without it you got belligerent
而你因此抽到了鬼牌

but I totally understand
但我完全明白

glass was half full for mine”
對我來說,杯子是半滿的」

and it looked half empty for me
在我看來,這卻是半空的

maybe that[one glass] made the path we took who knows?
也許就是對「杯子」的想法,讓我們走上了不同的道路?

chasing stars afar(so so far)
追遂遠方的繁星 (遙遠而漫長)

overlooks his own path(dark dark night)
卻迷失在路途上(在這深暗的夜晚)

he who knows not and knows not then he knows not…
他並不理解自身 也不明白有何意義 更一直未能察覺

but he could just easily be
但其實只要他願意

oh anyone
改變是如此簡單

so lost in the darkest night
迷失在至黑之夜裡

where’s the love?
當人需要愛時

when one needs it?
它到底在何處?

around and around there goes now
明明一切都是伸手能及

waiting for another falling
卻選擇等待他人與自己一同墮落

let their be stars to guide him the way
願那些人能成為繁星 為他指引道路

in this poor night
在這悲傷的夜晚裡

so numb he’s become so numb
變得麻木的他

ways of life
即使眼前有無數的道路

so exhausted
仍選擇放棄一切

he will not be who he’s not
因此他將無法改變自己

so sick of lies over lies but
厭惡無數謊言

can’t tell what is a lie anymore
到最後卻無法分清真假

he’s going so numb
只能停止思考

just let it go
放棄那份執念和

maze he has made
犯下的一切錯誤吧

Ubuntu 20.04 Spotify無法播放本地音樂問題

一開始以為Ubuntu20.04不能播放本地音樂是資料夾問題,結果一查才發現原來只是缺少了某些Library罷了。 

首先安裝必要的軟體:

sudo apt install ubuntu-restricted-extras ffmpeg

下載Spotify提供的Library並複製檔案至:

git clone https://github.com/ramedeiros/spotify_libraries.git
cd spotify_libraries
sudo cp lib* /usr/lib/x86_64-linux-gnu/

執行ldconfig:

sudo ldconfig
#修正檔案連結
sudo ln -frs /usr/lib/x86_64-linux-gnu/libavutil.so.52.6.100 /usr/lib/x86_64-linux-gnu/libavutil.so.52
sudo ln -frs /usr/lib/x86_64-linux-gnu/libavformat.so.54.36.100 /usr/lib/x86_64-linux-gnu/libavformat.so.54
sudo ln -frs /usr/lib/x86_64-linux-gnu/libavcodec.so.54.71.100 /usr/lib/x86_64-linux-gnu/libavcodec.so.54

 完成。其實我也只是照樣參考資料寫的,這個解法… 

參考資料:

https://community.spotify.com/t5/Desktop-Linux/Linux-Local-files-do-not-play-on-Ubuntu-16-04-SOLVED/td-p/1343831

Ubuntu 18.04解決無法使用VirtualBox共享剪貼簿的問題

裝在VirtualBox裡的Ubuntu18.04之所以辦法共享剪貼簿,是因為缺少了名為virtualbox-guest-x11的套件。 

照樣安裝VirtualBox Guest Addition後,再打開終端機輸入指令安裝此套件:

sudo apt-get update
sudo apt-get install virtualbox-guest-x11

遇到版本相容性提示訊息時,選擇安裝新版本。

再手動啟用共享剪貼簿功能即可:

sudo VBoxClient --clipboard

Drupal 8 在/admin/config頁面下新增分類

首先在自訂模組的links.menu.yml(例如your_custom_module.links.menu.yml)下新增以下內容:

system.admin_config_new:
title: 'My New Config'
route_name: system.admin_config_new
parent: system.admin_config

然後再在routing.yml(例如your_custom_module.routing.yml)新增內容:

system.admin_config_new:
  path: '/admin/config/new'
  defaults:
    _controller: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage'
    _title: 'My New Config'
  requirements:
    _permission: 'access administration pages'

清除緩存後即會生效。

以上代碼中請將自行將route名改為想要的名字,path和title同理。

Node Sass Watch不能正常使用的暫時代替方案

不知為何自從node-sass升級後,-w的選項就一直沒有生效過--能執行成功,但無法偵測指定Sass/Scss檔案的修改,這樣在無法使用IDE(例如在伺服器作業)的情況下編譯檔案會變得有點麻煩。

目前想到的解決方法是改用Gulp 監視檔案修改,有點麻煩但最少有效。

  1. 安裝gulp和gulp-sass:
npm install gulp gulp-sass
yarn add gulp gulp-sass

2.創建gulpfile.js,輸入以下內容:

vi gulpfile.js

const gulp = require('gulp');
const sass = require('gulp-sass');

gulp.task('watch', function () {
  gulp.watch('./css/*.scss', gulp.series('build:scss'));
});

gulp.task('build:scss', function() {
    return gulp.src('./css/style.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(gulp.dest('./css/'));
});

3.在Package.json加入Watch指令:

  "scripts": {
    "watch": "./node_modules/.bin/gulp watch"
  }

4.想要編譯Sass/Scss檔案時,運行Watch指令:

npm run watch
yarn watch

完成。逃避可恥但有用,對吧?

如何在使用Let’s Encrypt + Nginx 重定向的情況下避免CORS問題?

用Fetch抓取和傳輸資料雖然很方便,也遇上CORS問題的時侯就笑不出來了。查資料加上除錯了一整晚,最後終於知道要如何在API 使用Let’s Encrypt重定向的時侯到底要怎樣避免CORS問題。

首先,要在後端程式加上Access-Control-Allow-Origin的Header。這應該大家都知道了,但還是提醒一下這個是基礎第一步喔。以PHP為例子:

header("Access-Control-Allow-Origin: *");

之後你可能會發現:咦?為什麼我設定了Access-Control-Allow-Origin,還是會出現同樣的問題呢?原因非常簡單:CORS不接受2xx以外的Staus Code回應!

用Fetch POST JSON時,瀏覽器會先發出OPTION的請求。這時Nginx如果不好好處理,就會給出405回應,導致問題發生。

所以我們要在Nginx的設定裡加上這個:

location / {  
    if ($request_method = 'OPTIONS') {
        return 204;
    }
} 

重啟Nginx後就能解決問題了。

順便提醒一下,前端的Code也需要注意在CROS模式下Fetch的時侯不能帶Header,否則一樣會出現問題喔。嚶嚶嚶。

  fetch(apiUrl, {
      body:JSON.stringify({
        width: 500,
        height: 300,
        imageUrl: imgUrl,
      }),
      mode: 'cors',
      method: 'POST',
    })

鳴謝Front-End Developers Taiwan翁傳翔林坤南先生指出文中問題!

如何讓遠端伺服器使用自己電腦上的SSH Key?

習慣用Git在伺服器上部署網站後,已經不想再用FTP或者SFTP這麼老套的方法來做事了。

不過如果想用SSH的方法訪問Git,很多時侯我們需要先為伺服器準備獨立的KEY,這樣實在有點麻煩。其實最好的方法是使用SSH Agent Forwarding讓遠端伺服器也能使用你電腦原來的金鑰,做法也非常簡單。

首先,新建/修改你電腦上的~/.ssh/config檔案 ,新增以下內容:

Host your_server
HostName server.com
user root
ForwardAgent yes

Host是你設定的伺服器名稱,請隨意修改。HostName則是你的伺服器網址/IP,user是指定的伺服器用戶,至於ForwardAgent就是本次的重點,請務必設定為yes。

完成後,輸入以下指令檢查目前Agent是否正使用你的Key:

ssh-add -L

否則輸入指令:

ssh-add -K

完成後再次登入你的伺服器:(請使用之前設定的伺服器名稱登入,否則不會生效)

ssh your_server

想知道更多關於ForwardAgent的資料,可以查看以下參考網站:

SSH agent forwarding 的應用

Javascript 如何比對Object是否相同(Equal)

在沒有Key或者Id的情況下,比對Object真的是世界上最噁心的一件事情了。

最簡單的方法是這個:

const object1 = {"Name": "Hello"};
const object2 = {"Name": "Hello"};

if(JSON.stringify(object1) === JSON.stringify(object2)){
  return true;
}

很簡單對吧?然而世界沒有那麼美好。更多時侯你會遇到這種情況:

const object1 = {"Sex": "Girl", "Name": "Hello"};
const object2 = {"Name": "Hello", "Sex": "Girl"};

這種時侯用上一種方法是會Return False,失敗的。手寫排序Function是一種處理方法,但工時不足的情況下可以考慮用Sort Object這個模組解決問題:

https://github.com/doowb/sort-object
const sortObj = require('sort-object');
const object1 = sortObj({"Sex": "Girl", "Name": "Hello"});
const object2 = sortObj({"Name": "Hello", "Sex": "Girl"});

if(JSON.stringify(object1) === JSON.stringify(object2)){
  return true;
}

好了,輕鬆搞定。如果遇到更複雜的情況,需要深度比對的話,那就需要另一個名為Deep Equal的模組了。

https://github.com/substack/node-deep-equal
const sortObj = require('sort-object');
const equal = require('deep-equal');
const object1 = sortObj({"Sex": "Girl", "Name": "Hello"});
const object2 = sortObj({"Name": "Hello", "Sex": "Girl"});

if(equal(object1) === equal(object2)){
  return true;
}

過於依靠他人的模組是不好的事,但這是最簡單和最快的方法了。有空的時侯再研究一下怎麼手寫出同樣的功能吧!

◢▆▅▄▃崩╰(〒皿〒)╯潰▃▄▅▇◣

Mastodon