Category: computer science

  • Imghorce is online – Halloween

    Imghorce is online – Halloween

    一直想要邊學圖片生成相關技術一邊發表自己的圖片。可絕大多數圖片站或者不接受 AI 生成的圖片;或者對圖片上傳數量比較大的限制,對於邊學習邊發表記錄歷程的想法就很不友好。於是,自己做一個叭~ 它叫做 Imghorece. 來自 Image 和 Force.

    網站的架構是 Astro, 能容易地部署在 netlify 上. 就像 Astro 的宣言 The web framework for content-driven websites. 部署之後,雖然需要改一些代碼,但完成基本的網頁功能簡化和平面設計之後,接下來確實就可以安心專注內容了。至於圖片站 blog 裡面 md 格式,被我設計得有些複雜,並且設計還在修改中。這個 md 格式手寫起來有點麻煩,但在基本內容板塊設計穩定下來之後,用 python 寫一個 md 生成器就很方便了。

    圖片之前考慮過部署在 GitHub. 仔細考慮之後,還是放在自己在 Hostgator 的網站上,因為 Astro 這類非數據庫類型的平台很少有點擊數量追蹤功能。我還蠻希望在網站的運營過程中知道各圖片受歡迎的程度。而文件被訪問的記錄,透過 Hostgator 很輕鬆地可以知道。

    關於圖片生成,當前選型是 Flux.1 Schunell. 這個模型允許商用,所以網站分享出來之後,無論別人如何使用,還是我自己未來在網站上加廣告條也都少了很多麻煩。另一方面,如果未來如果運營得健康,買 Flux 的會員用 dev 或者 pro 生可商用的圖也是未來可能的方案。許可證選擇了比較寬鬆的:Creative Commons Attribution 4.0 International licence.

    這裡記錄了 Imghorce 圖片站的宗旨:https://imghorce.oopus.info/authors/img-oop/

    第一个 POST 是即將到來 Halloween 相關的圖片: https://imghorce.oopus.info/post-halloween-20241020/

    這裡也分享一張沒有上傳到圖片站上的圖片(這張圖用的模型是 Flux.1 Dev. 對於商用並沒有那麼自由)。它叫做 Greeky. 在 Morton, Lisa. 2012. Trick or Treat : A History of Halloween. London: Reaktion Books 中提到 Halloween 的起源:

    “Samhain was also an important day for administration, akin to the US Tax Day in modern times. A yearly gathering was held at Tara, the ancient seat of kings, where three days’ worth of feasting and sporting alternated with debt repayment and trials (those who were found guilty of particularly severe crimes were executed then as well).” Deepl 翻譯: Samhain 也是一個重要的行政日,類似於現代美國的納稅日。一年一度的聚會在古代國王的所在地塔拉 (Tara) 舉行,三天的宴會和體育活動與還債和審判交替進行(那些被判犯有特別嚴重罪行的人也會在這一天被處決)。

    於是生成的思路是對王權(國王)和財權(商人)之間在 Samhain 節相互博弈的想象。

  • 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