Tuesday, June 24, 2025

Something about Renpy For loop error : expected statement.

 It takes me over hour to debug.
The simple fact is that under label, we cannot use For loop.
One while is valid to be used under label.
To use For loop, must go with python:

Another Finding is about call screen and show screen.
In past, it seems the second one is more appropriate for my case .
With Screen A and button A, to open Screen B.



Thursday, May 8, 2025

Colab naifu , AI read model error

Change 
 File "/content/naifu/hydra_node/models.py", line 215, in __init__

from ckpt=torch.load(self.config.vae_path, map_location="cpu")

to ckpt=torch.load(self.config.vae_path, map_location="cpu" , weights_only=False)


Saturday, April 26, 2025

The JWK file specification , something about the public exponent : AQAB 

I need to configure Salesforce JWT (JSON Web Token) user verification recently.

And there is a file JWK (JSON Web Key) required .The sample document from Salesforce shown as below : 
Salesforce Reference


{
    "kid":"123456",
    "alg":"RS256",
    "use":"sig",
    "kty":"RSA",
    "x5c":["<Your public certificate>"],
    "y":"y",
    "n":"<Base64-encoded modulus>",
    "e":"<Base64-encoded public exponent>",
    "crv":"crv",
    "d":"d",
    "k":"k"
}

In order to know more about the values , I do another search online do know more about each parameters.
Detail RFC specification 
And to know more about the Salesforce sample document, I get a search about the Salesforce specific file format as well. 
Medium Reference

The public exponent now become a fix value "AQAB".

{
"kid": "{A unique value that identifies the end user}",
"alg": "RS256",
"use": "sig",
"kty": "RSA",
"x5c": [
"{Paste the public certificate value here}"
],
"y": "y",
"n": "{modulus of the public key in Base64 format}",
"e": "AQAB",
"crv": "crv",
"d": "d",
"k": "k"
}

Isn't it a variable, why it can be fixed ?


The answer is related to the kty (Key Type) parameter.

When "RSA" is used as key type, then the public exponent of it is 65537.


Convert 65537 to hexadecimal , we got 0x01000. Then we encode the 0x01000 to Base64 , we got "AQAB". 


In short, the base64 format public exponent of RSA is "AQAB".  
And this value is came from conversion of public exponent of RSA key type.

Quoted from Wiki

"65537 is commonly used as a public exponent in the RSA cryptosystem".


Sunday, January 26, 2025

Salesforce Tricks : Add line break to Tool tips or field-level help in Lightning Experience.

 A tool tip of a field can be difficult to read when there is no line break.

In formula , we can use "BR()" , but in tool tip, there is no formal method
The idea is still in Idea Exchange .

And a user posted a workaround here , using the "Japanese full width space" (\u3000).

Copy this :   [          ]

And put above bracket into the Help text where you need the line break. 


For example:
My line 1 
[          ] My line 2


Magic is done.


Wednesday, January 15, 2025

Great free tools for System Integration : Inspecting the HTTP-based request for API testing 免費好用的API測試工具

In order to setup a  HTTP-based API successfully, it is necessary to check request and response.

Postman is a great tool to check the response, how about the request ?

It can be trouble that if we cannot access a 3rd party system's request log while we have to send request to them . How can we verify the request we made is valid ? If the request will be altered by some middleware we may not able to touch ?

Here is one of the solution , make a mock server to capture the final request to the endpoint.
In past , it may takes time to setup a mock server , now , it becomes super easy. 

The great tool here is beeceptor !!! No registration needed , no installation needed.
Just need one browser tab ~

Steps as simple as below :

  1. Create an endpoint at https://beeceptor.com/ and leave this browser tab open.
    The endpoint will be like : 
    https://{your_input_name}.free.beeceptor.com 



  2. Change the endpoint used in code to the endpoint you just created .
  3. Execute the request in code from your IDE or other place , just execute your callout code.
  4. Refresh your https://beeceptor.com/ browser tab .
  5. Now you can check the request and header you just send, and you may create any response in the mock server .


Is is simple and easy , recommended by many platform like Salesforce.
Reference : 
https://help.salesforce.com/s/articleView?id=000384720&type=1

Thanks for reading.





Tuesday, October 15, 2024

Salesforce flow or Process deployment : Setting of active and test flow coverage

When deploy a new flow, it is default to be inactive.

But there is a setting to make it active in PROD org called "Process Automation Settings". 


We need to ensure coverage of the automation . It can be check by SOQL to FlowTestCoverage:

To calculate your flow test coverage, determine the number of all active flow versions with or without test coverage.
Single SOQL with + symbol.

SELECT count_distinct(Id) 
FROM Flow 
WHERE Status = 'Active' AND Id NOT IN ( 
SELECT FlowVersionId 
FROM FlowTestCoverage 
)
+
SELECT count_distinct(FlowVersionId) 
FROM FlowTestCoverage

 

Ref :https://help.salesforce.com/articleView?id=sf.flow_distribute_deploy_active.htm&type=5

Sunday, July 7, 2024

Python Error (Renpy) : TypeError: 'str' object is not callable

Met an error in renpy when writing the action function of an image button like below :
 action Function( '\u2192', pygame.K_RIGHT)

Error shown as below : 
File "renpy/common/00action_other.rpy", line 583, in __call__

    rv = self.callable(*self.args, **self.kwargs)

TypeError: 'str' object is not callable

Forgot to add the function name 
Corrected the syntax to below (also added the parameter name to before value):
action Function(simulate_keypress, unicode_key='\u2192', pygame_key=pygame.K_RIGHT)


Something about Renpy For loop error : expected statement.

 It takes me over hour to debug. The simple fact is that under label, we cannot use For loop. One while is valid to be used under label. To ...