Posted on

kscript – Having fun with Kotlin scripting

https://www.kotlinresources.com/library/kscript/

Enhanced scripting support for Kotlin on *nix-based systems.

Kotlin has some built-in support for scripting already but it is not yet feature-rich enough to be a viable alternative in the shell.

In particular this wrapper around kotlinc adds

  • Compiled script caching (using md5 checksums)
  • Dependency declarations using gradle-style resource locators and automatic dependency resolution with jcabi-aether
  • More options to provide scripts including interpreter mode, reading from stdin, local files or URLs
  • Embedded configuration for Kotlin runtime options
  • Support library to ease the writing of Kotlin scriptlets
  • Deploy scripts as stand-alone binaries

Taken all these features together, kscript provides an easy-to-use, very flexible, and almost zero-overhead solution to write self-contained mini-applications with Kotlin.

Posted on

Windows 10 Ubuntu App Shell

.bashrc

su : root -> .bashrc

.bash_profile -> ssh

.profile

When Bash is invoked as an interactive login shell, or as a 
 non-interactive shell with the --login option, it first reads 
 and executes commands from the file /etc/profile, if that file
 exists. After reading that file, it looks for ~/.bash_profile, 
 ~/.bash_login, and ~/.profile, in that order, and reads and executes
 commands from the first one that exists and is readable. The 
 --noprofile option may be used when the shell is started to inhibit
 this behavior.

.bashrc is a shell script that Bash runs whenever it is started interactively. It initializes an interactive shell session. You can put any command in that file that you could type at the command prompt.

There could be some messy implementation variations depending on the flavour of Unix, Ubuntu, macOS, etc.

Posted on

Dynamics Arises From Statics

When Equilibrium Is Not Established In Time.

The propagation takes time in nature due to the limited speed of light. The speed of light is thought to be the maximum speed limit that information can propagate.

Random events occur at all times randomly and equilibrium cannot be established instantly.

Enter the non-equilibrium non-linear dynamics

Uncertainty in our space-time causes random events. This is called uncertainty principle. The ultimate cause of all the mess in the Universe.

Living things lie. Non-living things also lie. Even our space and time lie. We All Lie.

Dynamics is here to handle all things that lie.

Classical Mechanics, Electrodynamics and Quantum Electrodynamics (QED) are well known a few good examples of dynamics.

There are countless not well-known dynamics. Some are discovered, and the rest are yet to be discovered.

Posted on

Web Workers and the DOM

Web workers do not have access to the following JavaScript objects:

  • The window object
  • The document object
  • The parent object

main.js runs in the main UI thread

var worker = new Worker("worker.js")
woker.onmessage = function(event) {
    document.getElementById("result").innerHTML = event.data
}
// Post message to the worker
worker.postMessage({"cmd": "start", "msg": "Hello"}) 

worker.js runs in a separate thread

self.onmessage = function(event) {
    var data = event.data
    self.postMessage(data.cmd + " " + data.msg)
}

Note: There are two ways to stop a worker: by calling worker.terminate() from the main UI thread or by calling self.close() inside of the worker thread.

Use Transferable objects to efficiently pass binary data between main and worker thread without copying the data. The usual FileBlobArrayBuffer, and JSON objects will be copied between main thread and worker thread, making them more resource expensive.

Posted on

AudioBuffer Timing Precision

It can anywhere between 100ms and 20 micro seconds.

It all depends on the browser.

AudioContext.currentTime returns a double representing an ever-increasing hardware timestamp in seconds with a certain precision that can be used for scheduling audio playback, visualizing timelines, etc.

AudioBuffer can be started at the particular time.

AudioBufferSourceNode.start([when][, offset][, duration])

For one example, a seamless two-buffer playback.

AudioBuffer0.start()
AudioBuffer1.start(AudioBuffer0.buffer.duration)

AudioBuffer1 will start when AudioBuffer0 is done. Hopfully, this will play continuously without hick-up between buffer0 to buffer1 transition. And when AudioBuffer0.onended event fires, queue another AudioBuffer0 with the start time set to the end time of AudioBuffer1. At AudioBuffer1.onended event, queue another AudioBuffer1 with start time of the end of AudioBuffer0. By switching between these two buffers, it should play smoothly and continuously as if it is one longer buffer.

Not sure if this really will work as expected. To be determined later by actually coding to this spec.

The real test result: there are audible hick-ups. It does not work. :-0

createScriptProcessor is last hope.

Posted on

Inflammatory Bowel Disease (IBD)

Ulcerative Colitis (UC) is an autoimmune disease. And Crohn’s Disease is not an autoimmune disease. Both UC and Crohn’s are IBD.

Autoimmune Disease: IBD medical condition has nothing to do with the foods you ate or did not eat. The foods will only affect the IBD symptoms that will go worse or better. Basically all foods will possibly cause some kind of symptoms, patient will take the foods depending on their tolerance to the individual food item. Since the patient must take some form of foods to supply necessary nutrients and energy to the body. Four known safe foods: white bread, cooked white rice, apple sauce, banana. Patients who are unable to tolerate the four known safe foods can go on a boost and ensure diet. Try to introduce one food item at a time for challenge-and-see-if-tolerated.

Some inflammatory bowel diseases are not autoimmune diseases such as Crohn’s, CMV Colitis that is caused by Cytomegalovirus (CMV), and C.diff Colitis that is caused by Clostridium difficile (aka C. difficile) bacteria. People with IBD from bacteria or Crohn’s may consider probiotics or fecal transplants to influence the gut floral to make them under balanced control. However, any probiotic or fecal transplant or herbal foods will not help those with the autoimmune IBD Ulcerative Colitis.

What is inflammation anyway?

What is human immune system doing?

Big Picture

Small Picture


Posted on

Reused Block Demo

Following blocks are reused from the ones in post title: Gutenberg Block in Kotlin

This can be reused many times anywhere in the site. It will keep in sync.

Hi there! I’m a grower by day, aspiring coder by night, and this is my website. I live in Vancouver, Canada, had a great dog named Paat and a great cat named Kuro, and I like hydroponics and mycelium. (And gettin’ caught in the rain.)

The ibinti.com was founded some years ago, and has been providing quality products and services to the public ever since. Located in Vancouver, Canada and does all kinds of awesome things for the Internet community.

Posted on

Gutenberg Block in Kotlin

It works!

This can be reused many times anywhere in the site. It will keep in sync.

Hi there! I’m a grower by day, aspiring coder by night, and this is my website. I live in Vancouver, Canada, had a great dog named Paat and a great cat named Kuro, and I like hydroponics and mycelium. (And gettin’ caught in the rain.)

The ibinti.com was founded some years ago, and has been providing quality products and services to the public ever since. Located in Vancouver, Canada and does all kinds of awesome things for the Internet community.