Thursday, June 29, 2023

超老舊軟體PhotoImpact X3走在Window 10 , 停止在 "正在初始化主要視窗及元件"階段 . 錯誤碼0xc0000005解決方法

一直在Window 10 (64bit) 上使用PhotoImpact X3 都好好的,今天突然開不到。
查了很多資料,最後發現是暫存檔的問題。

把以下位置中所有今天才生成的檔案移走,重開就行了。
C:\Users\YOUR_NAME\AppData\Roaming\Ulead Systems\Ulead PhotoImpact\13.0\Ulead.DAT\

從中學開始用了PhotoImpact 系列20年,升學及工作都多用Photoshop,但自用時還是更喜歡輕量易用的PhotoImpact 呢!~

Saturday, April 1, 2023

C# coding : Download Salesforce attachment to local disk using SOAP webservice Enterprise wsdl method (with SOQL selection)

Pre-requisite :

  • Select Target framework to 4.5.2 
  • Install DeveloperForce.Force 2.1.0 (via nuget if VS2015 is used)
  • Import Enterprise wsdl as WebReference (for easy Type Casting , partner wsdl also work but need more code lines.)
  • Update 2 ListViewRecordColumn[][] in Reference.cs to ListViewRecordColumn[].
    Otherwise, error  as below will be shown :
    Cannot convert type 'SaleForceBase.SaleForceRef.ListViewRecordColumn[]' ...

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Salesforce;
using System.IO;
using ConsoleApplication1.SfService;

namespace ConsoleApplication1

{
    class Program
    {
        static void Main(string[] args)
        {

            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3 | System.Net.SecurityProtocolType.Tls12;//Added to fix he request was aborted could not create ssl/tls secure channel.

            //Get Salesforce credentials
            var username = "your_salesforce_username";
            var password = "your_salesforce_password";
	   //var token = "your_salesforce_security_token";//uncomment this if you have enabled security token function. 

            var authEndpoint = "https://login.salesforce.com/services/Soap/u/50.0";

            // Login to Salesforce using SOAP API

            var binding = new SforceService();

            try {

            var loginResult = binding.login(username, password);
	    //var loginResult = binding.login(username, password + your_salesforce_security_token); //use this instead of above to login if you have enabled security token function. 
            binding.Url = loginResult.serverUrl;
            binding.SessionHeaderValue = new SessionHeader { sessionId = loginResult.sessionId };

            // Query for to get 5 attachments related to Account object

            var attachmentQuery = "SELECT Id, Name, ParentId FROM Attachment WHERE Parent.Type = 'Account' ORDER BY ParentId limit 5";
            var queryResult = binding.query(attachmentQuery);

            // Loop through the results and download each attachment

            foreach (var sObject in queryResult.records)

            {

                var attachment = (Attachment)sObject;//retrieve(string fieldList, string sObjectType, ID ids[]);
                var account = (Account)binding.retrieve("Name", "Account", new string[] { attachment.ParentId })[0];//returned as sObject[] , so need to get [0] 

                // Create a file name for the attachment

                var fileName = $"{account.Name} - {attachment.Name}";

                // Download the attachment

                var attachmentBody = (Attachment)binding.retrieve("Body" ,"Attachment",  new string[] { attachment.Id })[0];
                File.WriteAllBytes(fileName, attachmentBody.Body);
				
            }
            }
            catch(Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error : " + ex.InnerException);
                System.Diagnostics.Debug.WriteLine("Error2 : " + ex.StackTrace);
                System.Diagnostics.Debug.WriteLine("Error3 : " + ex.Message);
            }
        }
    }
}

 

Thursday, March 16, 2023

Colab : ImportError cannot import name 'rank_zero_only' from 'pytorch_lightning.utilities.distributed' (Stable Diffusion WebUI related) AI生成圖片Colab偵錯

When I am trying to use Colab for stable diffusion ,
I met error below today :

ImportError cannot import name 'rank_zero_only' from 'pytorch_lightning.utilities.distributed'


After searching , I got the answer finally from here.

Changed From : from pytorch_lightning.utilities.distributed import rank_zero_only 


To : from pytorch_lightning.utilities.rank_zero import rank_zero_only 


Before Run , remember to downgrade !pip install pydantic==1.10.11





So I updated the line 20 in file ddpm.py as indicated in debug log, and the issue is resolved. 




Friday, January 13, 2023

Salesforce concept : Limitation of Rollup Summary and Validation Rule

Question : Rollup summary CANNOT be used in formula field ?
Answer : No .
Rollup Summary can be used to group field values of child record .

Even thought it is formula type field , however ,
grouped field values CANNOT be cross-object formula field.


Question : How to validate the field values changed by Approval process ?
Answer : Validation is NOT a choice . Since field update fired by approval process will NOT initiate validation rule. (More explicit answer from google  , Validation Rules fire before workflow rules, so the record has to meet the validation rule criteria before the workflows get a chance to run. So, the validation rule will not work when you update the workflow field.)

Tigger can be used to validate the field values changed by approval process.

Monday, December 19, 2022

Lyrics about destiny , karma and sin .陳健安 On Chan - 《在錯誤的宇宙尋找愛》

意外聽到一首2019的歌,看了MV和歌詞,就喜歡上了。 
這種帶點宗教宿命色彩的詞總是很吸引我。
超脫得很浪漫。

詞: 黃偉文 曲: 馮穎琪

編/:謝國維 意識一早超脫 情愛這東西 越過了天地 並未眷戀螻蟻 沒有光陰跟遠近 我是叢電波 破天際 但你的召喚 讓我將功德放低 為你呱呱出世 回到這身體 自降四千等 為覓人類一吻 作謝禮 誰話愛戀 苦海濟世 會創造奇蹟 將蒼生撫慰 被你吸引 讓我當初失智慧 這宇宙 這種深情根本虛構 失了足 才會跌落你的地球 目光遠大如我 你有限維度裡 看春秋 很後悔 但愛死方會得救 為了找到真愛 尋遍每粒沙 住進你的家 就為明白這叫 錯誤嗎 求做對簡單的愛侶 與你歷其境 方知多可怕 沒法擺脫 俗套的分手戲碼 這宇宙 這種深情根本虛構 失了足 才會跌落你的地球 上天已難回去 我似被囚在你 那春秋 不恨你 恨我太晚參透 親手作孽 惡果他人怎可解救 貪怨癡 要葬在你的地球 為了擁抱你 換這雙手 一早已 被切去兩翼 禁飛走 這樣勇 試問你可能夠 自絕位列仙班 都不算太內疚 但愛到欠自我 我笑我下流 這宇宙 這種深情根本虛構 失了足 才會跌入你的溫柔 在你的結界 盪過韆鞦 我便無力 再看北斗 不恨你 恨我的反抗不夠 我的愛全被接收 必須再重頭禪修 練到清心寡愛 無懼色誘

Tuesday, December 6, 2022

MySQL database : Double type Numeric value out of range issue

 That was a really silly mistake I made due to not reading the manual ...


I want to save numeric value with 1 decimal point . i.e. : 2.0 , 1.5 , 1.0 , 0.5 and 0.0 .

The datatype was set as double (1,1) . After test, I found out that I never able to save value bigger than or equal to 1.0  . The maximum number I saved with options (2.0 , 1.5 , 1.0 , 0.5 , 0.0) is 0.5
instead of 2.0 .

I checked through the program codes and try to figure out the error in calculation related functions.


However the answer is about the database datatype. 

Double (1,1) in MySQL never able to save number bigger than or equal to 1. 

This setting doesn't mean 1number and 1 decimal point. It means the entire number has 1 digit ONLY.

Quoted from official document as below : 

DOUBLE[(M,D)]

Here, (M,D) means that values can be stored with up to M digits in total, of which 

D digits may be after the decimal point

Double (1,1) means totally ONE digit , and ONE digit follows decimal point. The only digit is assigned decimal part , so I never able to save value before decimal point.

After I set datatype to Double (2,1) , issue resolved. 


Just a diary to remind myself to read manual .




Quoted from official : 

As of MySQL 8.0.17, the nonstandard FLOAT(M,D) and DOUBLE(M,D) syntax is deprecated and you should expect support for it to be removed in a future version of MySQL.

Tuesday, November 29, 2022

The most romantic poem i have heard 偽十四行詩 葉青

 偽十四行詩

第一行不能出現「我愛你」否則接下來的十三行全都是廢話了

第二行是 你怎麼能這麼遠 而世界很近 世界對我是無可 對你是奈何

第三行應該轉折所以我不要愛你好了 這樣你將獲得平靜與安全

第四行用來交代原因 其實 我不知道這一切是怎麼變成這樣子的

第五行我總是正在想你 這個你 那個你 都在那些從前裡

第六行想到從前 痛了 所以沒有字

第七行剛好寫到一半了 我們之間 你卻什麼都不打算寫下

第八行你知道你有光嗎 每次你在我面前我很難好好直視 你的眼睛

第九行確實很久了啊 這些年來我喝的酒常常與你無關 現在不喝了 喝酒缺乏意義

第十行讓我抽兩根菸再寫 在你身邊抽過菸的結果是 一抽起菸 你像是就在這裡

第十一行寫起來有兩個一 我們 可不可以 是兩個一 什麼時候變成二 由你決定

第十二行我想放棄一切 或是放棄你 哪一個比較容易 你會允許什麼 當我懇求

第十三行留白 因為我想再多想你一遍 仔仔細細地想

第十四行我不打算結束你 你已經結束我 這最後的一行 是對於結束的 無效抵抗

第十五行 十四行詩 絕對不可以有第十五行 正如我絕對不能 愛你


-----------------------------------------------------------------------------------------------------

作者葉青的詩全都很浪漫優美,正如她所說,她的詩刪去贅詞只剩三個字:「我愛你」。

  

Migrating from Renpy to Godot

 Due to the limitation of renpy in rendering dynamic screen ,  due the the black border it gives in different UI scale resolution , finally ...