Skip to main content

Posts

Showing posts from March, 2021

Creating callable variants of functions by currying in Ruby - code snippet showing how to avoid scope problems

While coding a project in Ruby, I was creating some variants of a function by currying. Initially, I simply created the curried variants as variables, but quickly ran into scope problems where I couldn't then call any of the variants from within other functions. This was because the scope of the variant was the same as the scope of a local variable of that name.  So I created a code snippet as a demo for myself of what I should have done instead, which is to define the curried variant as another function. This new function then has the same scope as any function I would create and not the (more limited) scope of a local variable. Of course, in certain situations defining it as a local variable is more desirable - for example if I was instead planning to use the variant as a variable that could be passed around. This is as opposed to using it solely as a callable function, which is what I ultimately desired. def myfun(stuff, num1, num2)   if stuff == true then     num1 + num2   else

Why Solar Geoengineering is a Bad Idea: 3 reasons understandable to both the general and scientific communities

Solar geoengineering is the idea of limiting the amount of sunlight that reaches the earth, with the aim of limiting global warming. Here I will show 3 reasons why it's a really bad idea: 1. Photosynthesis requires sunlight, don't limit it - it's one of the few things pulling carbon dioxide out of the atmosphere Photosynthesis is one of the very few ways we have to remove carbon dioxide from the atmosphere. As an added bonus it's done automatically by plants, requiring no effort on our part. It requires light in order to work. To do it, plants take in sunlight, carbon dioxide and water, and they produce oxygen. These plants are literally removing carbon dioxide from our atmosphere, but they require light for it to work.  We should not do anything that could possibly limit the amount of photosynthesis occurring; limiting the amount of light hitting the planet is likely to decrease photosynthesis.  2. We should not be limiting the generation of solar power Solar electri

Ruby - 'reduce' or 'inject' applying a string function, a quick code snippet example

I was getting my head around the reduce method (also known as inject ) in Ruby for some code I am writing. I suspected that this would be what I really wanted to use with my array instead of the more generic each which first sprang to mind. So I was eager to try out the concept with reduce and ready to code a quick separate sketch of the outline for my particular use case. However, most examples of reduce out there are mathematical in nature and this makes it harder to mentally translate to string use examples.  In my case, I'm using the string to stand in for a more complex data structure, so I didn't want to have to mentally translate from numbers to strings to higher order structures. The Ruby documentation for reduce/inject was thorough but I struggled to wrap my head around their terminology, especially the word "memo". I finally realized that "memo" simply means the changing result. That seemed to do the trick mentally.  Since most of the functio

Life using the Linux operating system exclusively for the last few years

Above: my Linux desktop layout. Back in 2017, I switched my operating system entirely to Linux. In case anyone is wondering, here is what I experienced over the last few years. Others I interact with have no idea I'm on Linux. For example, if someone emails me an MS Word document that I need to complete, I simply open it with LibreOffice (an open-source word processing program that is pre-installed on most Linux systems), edit the document as needed - which is very easy since the same sorts of functionalities are available in LibreOffice - and then I can save it in MS Word format and email it back. Likewise, if I'm on a Zoom call, everything works just the way it does on PC and Mac. Zoom makes their application available for Linux too, I downloaded it and let it self-install, and it works exactly the same way as it does on other operating systems. I can point-and-click my way to whatever I need to do on Linux; no special knowledge required. If you want to dig deeper into script

Conspiracy theories are so unbelievable that you can easily make up a more believable one yourself. Here's how.

Disclosure: This is a thought experiment for the purposes of showing how easy it is to make up a conspiracy theory. I do not advocate the dissemination of conspiracy theories and other baseless speculations. Do some of the conspiracy theories out there seem so far-fetched that you are ROTFL when you hear of them? Yet some people actually do seem to believe them. Many conspiracy theories are made up. In other words they are fiction. At best, they are theories and not fact, otherwise that particular conspiracy theory wouldn't be a conspiracy theory, it would be fact. At worse, they are the deliberate peddling of lies. So I decided to demonstrate that creating a conspiracy theory is so easy that anyone can do it. There are no special skills, talents, or level of intelligence required. There is nothing special about making up a conspiracy theory. Let's have a go. Step 1: Identify the least believable conspiracy theory you have heard of This step is easy and should take you less th

About Me

My photo
Vera
I'm a wife and mother. I don't have any formal computer science qualifications, or any religious qualifications. I have a PhD in biochemistry. This photo is of me, but is confusing for AI.