Category: computer science

  • Documents folder in Windows

    In the Windows system, there are likely up to four different types of ‘Documents’ that you can find in your Windows system:

    In your local user account folder:

    x:\Users\{user}\Documents\

    In your OneDrive private user account folder:

    C:\Users\{user}\OneDrive\document

    In your OneDrive organization user account folder:

    C:\Users\sudos\OneDrive – Harvard University\Documents

    In the Documents shortcut (this shortcut links to the first user account folder you logged in):

    Documents

  • A SQL procedure to query a column in all the tables

    The procedure to query

    DELIMITER $$
    CREATE PROCEDURE FindCSourceRecords()
    BEGIN
      DECLARE done INT DEFAULT FALSE;
      DECLARE tableName VARCHAR(255);
      DECLARE cur CURSOR FOR 
        SELECT TABLE_NAME 
        FROM INFORMATION_SCHEMA.COLUMNS 
        WHERE COLUMN_NAME = 'c_source' 
        AND TABLE_SCHEMA = 'cbdb_data'; -- Replace with your database name
      DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
    
      OPEN cur;
    
      read_loop: LOOP
        FETCH cur INTO tableName;
        IF done THEN
          LEAVE read_loop;
        END IF;
    
        -- Corrected dynamic SQL to properly execute and check for existence
        SET @s = CONCAT('SELECT EXISTS (SELECT 1 FROM ', tableName, ' WHERE c_source = 38299) INTO @exists;');
        PREPARE stmt FROM @s;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;
    
        -- Check if the query found a row and then do something with the result
        IF @exists THEN
          -- This is a placeholder action; you might want to SELECT the table name or insert it into a log
          SELECT CONCAT('Found in table: ', tableName) AS Result;
        END IF;
    
      END LOOP;
    
      CLOSE cur;
    END$$
    
    DELIMITER ;

    Call query procedure

    CALL FindCSourceRecords();

    Remove query procedure

    DROP PROCEDURE IF EXISTS FindCSourceRecords;

    The procedure to update

    DELIMITER $$
    
    CREATE PROCEDURE UpdateCSourceRecords()
    BEGIN
      DECLARE done INT DEFAULT FALSE;
      DECLARE tableName VARCHAR(255);
      DECLARE cur CURSOR FOR 
        SELECT TABLE_NAME 
        FROM INFORMATION_SCHEMA.COLUMNS 
        WHERE COLUMN_NAME = 'c_source' 
        AND TABLE_SCHEMA = 'cbdb_data'; -- Replace with your actual database name
      DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
    
      OPEN cur;
    
      read_loop: LOOP
        FETCH cur INTO tableName;
        IF done THEN
          LEAVE read_loop;
        END IF;
    
        -- Dynamic SQL for updating c_source values
        SET @s = CONCAT('UPDATE ', tableName, ' SET c_source = 9334 WHERE c_source = 38299;');
        PREPARE stmt FROM @s;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;
    
      END LOOP;
    
      CLOSE cur;
    END$$
    
    DELIMITER ;

    Call update procedure

    CALL UpdateCSourceRecords();

    Remove update procedure

    DROP PROCEDURE IF EXISTS UpdateCSourceRecords;
  • Win11 環境下在 MS Access 中複製數據頻繁卡死的解決方案

    某次升級之後,即使從 MS Access 中複製很少量的數據,系統也會卡死。關於這個問題的解決,除了卸載對應的升級包以外,也可以嘗試用 admin 權限啟動 Access,之後再打開所需要的數據庫來複製數據。

    參考:https://techcommunity.microsoft.com/t5/access/access-freezes-when-i-copy-a-record/m-p/3699497/highlight/true#M7066

  • 艾略特荒原的英語語言評分

    I trained a multi-output regression model(training data: https://www.kaggle.com/competitions/feedback-prize-english-language-learning) to grade the first paragraph of T.S. Eliot’s The Waste Land. You can imagine that AI saying: Well, your vocabulary is good(3 out of 5). Syntax and grammar are not bad(2.95 out of 5), but you still need to improve your cohesion, phraseology and conventions.

  • Deep Learning Network

    【 kaggle.com 】的領導人之一是【Jeremy Howard】:

    【Jeremy Howard】 and 【Sylvain Gugger】 合作了一本書叫: Deep Learning for Coders with 【Fastai and PyTorch】: AI Applications Without a PhD https://www.amazon.com/Deep-Learning-Coders-fastai-PyTorch/dp/1492045527:

    【Sylvain Gugger】 在 【huggingface 】的教程中教授了很多 https://huggingface.co/course/chapter1/1?fw=pt :

    這個耶誕、元旦假期的深度神經網路學習完全被這個 social network 支配了~

  • Wake Me up When September Ends

    一年前的九月三十號,某個文件被寫定(下圖下方紅框),某個人關掉了 ssh,之後再沒有人維護過這個 service。直到一年之後的八月底,它像個沒人要的孩子,滿身創傷,再也無法提供服務,也沒有人…… 九月一號,理清了服務器上的所有細節,一點點修復了代碼的所有問題,某個文件被寫定(下圖上方紅框),存盤。註定似的電台裡面響起了 Wake Me up When September Ends

  • exbert

    吹爆 exbert. 全世界再也没有第二个工具能这么直观和简单的来向其他人解释神经网络的 embedding 和 attention 了

    http://exbert.net/exBERT.html
    例子:I too will undertake travels in Liang and Song, expecting to gather the yao plant.(杜甫:亦有梁宋遊,方期拾瑤草。译文自 Stephen Owen)

  • 在 javascript 中显示未 encode 字符的原始状态

    var a = ‘aaaaa\r\nbbbbbb’;
    console.log(JSON.stringify(a));
    console.log(a);

    From: https://segmentfault.com/q/1010000011005586

  • change time zone in Debian

    dpkg-reconfigure tzdata