[keychron] set function keys(f1-f12) to work on Ubuntu

According to the cheatsheet comes with the the products, one can press fn + X + L more than 3 secs to switch between function and multimedia keys.

However, this doesn’t work on Ubuntu. No matter how many times (even, odd… -_-) I try, the f1-f12 always perform as multimedia keys.

In order to change them to work as function key we can change the following settings:

ctrl + alt + t # Turn on the terminal

cd /sys/module/hid_apple/parameters
sudo nano ./fnmode

Then change the fnmode’s content from 1 to 0

try fn + X + L (more than 3 secs until the keyboard lights)

yay it works!

source: https://devlog.jwgo.kr/2019/12/13/how-to-fix-fn-key-not-working-between-keychron-and-ubuntu/

[Matplotlib] 한글 폰트 추가

https://financedata.github.io/posts/matplotlib-hangul-for-ubuntu-linux.html

위 사이트를 참고하면 굉장히 상세하게 (한글) 폰트 추가 과정이 나와있다. (감사합니닷)

Jupyter notebook으로 코딩 중 위 문제를 만나게 되면, 자칫 Jupyter notebook을 켜놓고 위의 과정을 진행하게 되어, 시키시는 대로 따라했음에도 Matplotlib에서 새로 추가한 폰트를 인식하지 못하는 경우가 생긴다.

위 사이트 [글꼴 설치] 파트에서 아래 과정을 진행할 때 꼭 Jupyter Notebook이나 이미 matplotlib를 호출해 놓고 있는 프로세스를 종료하고 해야한다!

$ sudo cp /usr/share/fonts/truetype/nanum/Nanum* /usr/local/lib/python3.4/dist-packages/matplotlib/mpl-data/fonts/ttf/
$ rm -rf /home/ubuntu/.cache/matplotlib/*

Jupyter notebook 끄기 ! -> 위의 코드 진행 -> 다시 키기 ! :::: 마법처럼 되었다! 끝!

예시:

import matplotlib as mpl

import matplotlib as mpl
import matplotlib.font_manager as fm

set(sorted([f.name for f in fm.fontManager.ttflist]))
#---> 사용 가능한 폰트들이 뜬다!!\

#이 중 NanumBarunGothic을 사용하려면, 
mpl.rcParams['font.family'] = 'NanumBarunGothic' 

#폰트를 바꾸고 그래프를 그리면 -부호가 안 나오는 경우가 있는데 아래와 같이 하면 나온당.
matplotlib.rcParams['axes.unicode_minus'] = False

[Javascript] Entering Letter grades Automatically at UMEG

Entering letter grades automatically at UMEG

Putting letter grades in UMEG with 300 + clicks is cumbersome and prone to mistakes, especially for large sized classes.

An  alternative is to use Canvas(elms) to convert grades into UMEG. However, the functions provided by Canvas are rather restrictive (and slow). And we don’t want to create numerous alarms to be sent to students.

So we can try using the following script at UMEG to fill out the grades automatically.

var t = document.getElementsByTagName(“table”)[5];
var trs = t.getElementsByTagName(“tr”);

// input the grades you want to enter following the order in UMEG (name – ascending order)
var grades = [“A+”, “C”, “D”];

function to_num(letter) {
var i = null;
var j = 2;
if (letter[0] == “A”) {
i = 1
} else if (letter[0] == “B”) {
i = 2
} else if (letter[0] == “C”) {
i = 3
} else if (letter[0] == “D”) {
i = 4
}
if (letter.slice(-1) == “+”) {
j = 1
} else if (letter.slice(-1) == “+”) {
j = 3
}
return [i, j]
}

// change num as the number of students in your class
var num = 374
for (var i = 0; i<num; i++) {
var str_ = “grd” + i
var letter = to_num(grades[i])
var grade = trs[9*i + 1].getElementsByTagName(“td”)[letter[0]*4-2 + letter[1]].getElementsByTagName(“input”)[str_]
grade.checked = false;
grade.checked = true;
console.log(i)
}