2022年8月7日星期日

於Mac上關閉以Chromium為核心之瀏覽器的滑鼠平滑捲動功能

最近買了一台Macbook Pro M1及iMac 24 M1, 但總是不習慣Mac系統在使用一般滑鼠時捲動滾輪的慢速動畫,看久了眼睛會非常疲勞,且也會有暈眩的症狀出現。為解決上述問題,Google了一下現行的解決方案,立刻找到了emreyolcu在Github上的開源專案:

初次使用會發現,捲動的速度似乎有點慢,檢查其原始碼main.m發現它的預設捲動列數為3列,修改LINES=5後重新編譯再執行,捲動速度有所提升:

 捲動列數為 LINES 變數定義值,預設為3

但後來發現,用得順手的Brave瀏覽器(其核心為Chromium)卻沒有套用上直接捲動,上下滾動還是會有短暫的動畫出現,看久了眼睛依舊不適,通常可以進入brave://flags內將平滑捲動關閉,但不知為何,今年開始的Chromium卻不支援這項功能,會顯示"Not available on your platform":

2022年開始,Chromium於Mac上不支援關閉平滑捲動

經過測試,不僅是Brave,連Microsoft Edge、Google Chrome等一系列家族成員,都深陷其害。

一番折騰,終於在Google的Support中看到一則回覆:

https://support.google.com/chrome/thread/111863440/smooth-scrolling-in-chrome-91-and-92-%E2%80%93-how-to-disable?hl=en

看起來是要用Terminal加上參數去開啟App。

但每次要開啟瀏覽器,還要去Terminal下指令,其實有點麻煩,我就想說能否簡化成一個捷徑?

其實不難,請先開啟 Scirpt Editor:



接著,輸入

do shell script "open /Applications/Brave\\ Browser.app/ --args --disable-smooth-scrolling"

quit


其中的 "Brave\\ Browser.app" 可以換成您的 Chromium-like 瀏覽器名稱

接著,點選 File -> Export.. ,取個名字,下面的File Format請選擇Application

請記得選擇Application

儲存後,到該目錄資料夾,就會看到<檔案名稱>.app了,將他拖進Application目錄,或是在Dock上建立捷徑,之後點選便會套用參數去執行App了





2016年1月6日星期三

[UVa] 272 - TEX Quote

雙引號的頭尾判斷是從頭到尾的,所以旗標初始化的位置在迴圈外面
判斷flag的部分要寫清楚(改變成0 or 1的部分)


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cctype>
char input[10000];
int main(){
    memset(input,0,sizeof(input));
    int flag=1;
    memset(input,0,sizeof(input));
    while(fgets(input,sizeof(input),stdin)){
    for(int i=0;i<strlen(input);i++){
      if(input[i]=='"'){
                if(flag==1){
                    printf("``");
                }else{
                    printf("''");
                }
                flag = (flag==1)?0:1;
      }else{
                printf("%c",input[i]);
      }
  }
  memset(input,0,sizeof(input));
 }
 return 0;
}


2015年8月13日星期四

Notes for Kali penetration and Version control tools



Version Control
  • RCS: file revisions on single machine
  • CVS: offer extensive archiving and merging capabilities, keeping a central repository somewhere on the network


Penetration Test
  • offline attack : hash crack
    • hash-identifier
    • hashcat (http://hashcat.net/wiki/)
    • rtgen: Rainbow Crack (空間換時間)
      • rtsort
      • rcrack
    • samdump2: crack password of Windows account
    • John (John the Ripper/John)
      • unshadow
      • john
    • C\%windows%\system32/config
    • /etc/shadow, /etc/passwd
    • ophcrack: crack Windows hash

2015年8月4日星期二

[UVa] 524 Prime Ring Problem

運用Backtrack的技巧
一直卡在輸出的最後多出空格,導致PE

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdio>
using namespace std;
int is_prime(int a){
for(int i=2;i*i<=a;i++){
if(a%i==0)return 0;
}
return 1;
}

int sol[20];

void backtrack(int n, int m){
sol[1]=1;
if(n==m+1){
if(!is_prime(sol[1]+sol[m]))return ;
printf("1");
for(int i=2;i<=m;i++)printf(" %d",sol[i]); printf("\n");
return ;
}
for(int i=2;i<=m;i++){
int ok=1;
for(int j=2;j<n;j++){
if(sol[j]==i)ok=0;
}
if(ok){
if(is_prime(i+sol[n-1])){
sol[n]=i;
backtrack(n+1,m);
}
}
}
}
int main(){
freopen("input.txt","r",stdin);
int N,kase=0;
while(scanf("%d",&N)!=EOF){
if(kase++)printf("\n");
//memset(sol,0,sizeof(sol));
printf("Case %d:\n",kase);
backtrack(2,N);

}

2015年7月17日星期五

"BackTrack" Practice

列出所有0~4的排列組合

#include <stdio.h>
#include <stdlib.h>
int* A;
int sol[5];
void backtrack(int n){
    if(n==5){
        for(int i=0;i<n;i++)printf("%d ",sol[i]);
        printf("\n");
        return ;
    }
    for(int i=0;i<5;i++){
        int ok=1;
        for(int j=0;j<n;j++){
            if(sol[j]==i)ok=0;
        }
        if(ok){
            sol[n]=i;
            backtrack(n+1);
        }
    }
}

int main(){
    backtrack(0);
    return 0;
}

2015年7月2日星期四

DP

Thanks my buddy tought me in a easily-understand way.

1. 遞迴
2. 筆記本
3. 下到上

f(1) = 1
f(2) = 1
f(3) = 2 = f(2) + f(1)
f(4) = f(3) + f(2)
f(5) = f(4) + f(3) = f(3) + f(2) + f(3) = f(2) + f(1) + f(2) + f(2) + f(1)

...
f(n) = f(n-1) + f(n-2)



// return f(n)
// DP
// n <= 1000
int arr[1001];
Zero(arr);
arr[1] = 1; // f(1) = 1
arr[2] = 1; // f(2) = 1
int f(int n) {
        if(arr[n] != 0) return arr[n];
        else return arr[n]=(f(n-1) + f(n-2));
}    
     
f(4) + f(3)
f(3) + f(2) + f(3)
f(2) + f(1) + f(2) + f(3)
2 + f(2) + f(3) // arr[3] = 2

int f(int n) {
        if(n == 1 || n == 2) return 1;

        // n >= 3
        int n_1 = 1 /* f(2) = 1 */,
            n_2 = 1 /* f(1) = 1 */,
            n;

        for(int i = 3; i <= n; ++i) {
                n = n_1 + n_2;
                n_2 = n_1;
                n_1 = n;
        }

        return n;
}


2015年6月30日星期二

[UVa] 10976 - Fractions Again?!

一個簡單的暴力法
重點:將運算式作調整,可得 y = x*k / (x-k)
x : k+1 -> 2*k ,尋找 (x*k) % (x-k) == 0 的狀況
存入堆疊後列出

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>

int main(){
  int k;
  int note[10000][2];
  while(scanf("%d",&k)!=EOF){
    int total=0;
    memset(note,0,sizeof(note));
    for(int i=k+1;i<=2*k;i++){
      if((i*k)%(i-k)==0){
        note[total][0]=i;
        note[total][1]=(i*k)/(i-k);
        total++;
      }
    }
    printf("%d\n",total);
    for(int i=0;i<total;i++)
      printf("1/%d = 1/%d + 1/%d\n",k,note[i][1],note[i][0]);
  }
  return 0;
}