Show more

I wanna do a project in haskell soooo bad.. i just cant justify a full stack project with it for various technical and social reasons... but its so much fun!

I want people to share with me any and all cool productivity tools you use for software development including brainstorming, diagraming, project management, and of course coding... Go!

Here is a algorithms/riddle i just solved that was kind of fun. So heres the setup. You have a circular table that spins with four evenly spaces opaque boxes on it around the outside. In each box is a coin that is either heads or tails. You get a maximum of 5 rounds, between each round you are blindfolded and the table ia spun randomly. During each round you can pick a box to open, look, the pick a second box to open and look. You can then flip none, any, or all, of the coins with open boxes. Then the boxes are closed before the next round. If at any point all four coins are the same then you win the game.

You must come up with a strategy that **guarantees** in 5 rounds or less that all 4 coins will be the same.

Tommorow i will take a picture of the flow chart i came up with the answer. In the meantime please give hints, answer, or thoughts in the comments but be sure to CW them. I will reply tomorrow with a picture of the answer and CW that as well. Good luck!

PS for a slightly harder version all the same rules apply except you need to pick both boxes to open simultaneously rather than one after thr other. With this harder version it is still possible in 5 rounds or less.

I really hope Wikijs gets a bit more momentum. It is a great project, and its features and usability is already more than enough for me to commit to it. But man there are so many features yet to be implemented I'd like to see and the development seems to have slowed lately.

Interesting thing about boolean in most languages is that it is often a trinary/tri-state variable, not a dual state true or false variable, reason being you often have nil/null you can set a boolean too as well and in many languages, particularly those where all variables are by reference, you cant change this.

Ruby is particularly interesting because it makes a distinct separation between a variable being not-set and null/nil. Therefore a boolean in Ruby is a quad-state variable that can be either not-set, nil/nill, true, or false.

NOTE: My comment about Ruby is actually misleading since its a dynamic language. If you have a variable intending to act like a boolean, strictly speaking, before you set it with a boolean variable it doesnt have a boolean type. So the boolean **type** is not quad-value. Its just any variable that the variable you intend to use exclusively for boolean can have any of 4 states, and likely does in most implementations.

@Science

The PlsExplain programming language attaches a comment to every value that propagates with the value. Kinda cool.

github.com/langjam/jam0001/tre

Can I get some feedback on a static website im designing for my new company? Would love to get some feedback on asthetics.

CleverThis.com

It doesnt have much for content (what is there is mostly just to take up space. But would love an opinion on the logo and the look and feel. Also check out the article "our new home" to get a sense for all the layout features it has so far.

WOOT! Our GitLab instance just got approval for another year of free ultimate license (normally costs 100$ per person, per month).

So the Jupyter Labs container I shared with everyone yesterday has undergone some improvements I wanted to share, namely, it now supports 7 different languages rather than just 4: Python3, ruby, julia, Rust, R, Haskell, and Javascript.

In case you are unfamiliar Jupyter Labs is a way to write notebooks (formated text with inline code that runs and displays elements like graphs or text). These notebooks are often used in science settings and as such I have integrated all the science tools python has to offer more or less. It is a great place to write up technical documents with working code side by side with the data it produces, but its also a great environment to play around with various programming languages and try out snippets without needing a full project environment. Thanks to the support of many different languages it is a great way to learn and try a language without needing to set anything up, since it all runs from a container.

In short just run a single command to bring up the container (the image is pulled from docker hub) and in a few minutes you will have a running web server you can point your browser to and start coing in any of the 7 languages supported. I use it to share snippet ideas. It is backed by anaconda so you can easily upload a notebook to their servers and then share a static version of it with people by sharing a link to the notebook, which can be viewed directly without needing any apps, not even Jupyter Labs installed.

Check it out here:

git.qoto.org/modjular/jupyter-

or just get the docker container image directly: modjular/jupyter-all:latest

@Science
QT: qoto.org/@freemo/1059695686681

🎓 Dr. Freemo :jpf: 🇳🇱  
Earlier I posted about a #Docker image I wrote that includes Jupyter Labs with every science library and tool unde the sun as well as support for f...

Earlier I posted about a image I wrote that includes Jupyter Labs with every science library and tool unde the sun as well as support for four other languages ( ). I moved the files over to an open source repo (linked below) and the image now has a new identifier: modjular/jupyter-all

Basically just copy the docker-compose out of that repo then bring it up on your local computer and after a few moments youll have a jupyter labs instance running on 8888, point your browser there and you can code notebooks in any of the 5 supported languages ( is obviously supported by default ). It is based off the standard science notebooks too, so if your familiar with those this is just that and more.

git.qoto.org/modjular/jupyter-

100 Pots Puzzle

About a year and a half ago I presented the 100-pots puzzle, which is by far my favorite programming/logic/math problem I have ever come across. It took me a while to solve it the first time I heard it (most of the work day which is where I heard it). I also was at an advantage because the solution comes from a field of math I have particular expertise in, so most people will probably have a harder time solving it.

I don’t think anyone was able to solve it last time I presented it, and had to give the official answer, I could be wrong, I need to dig up the thread. @Absinthe however did write a simulation for it in python after I had posted the answer.

Anyway here is the problem for anyone who wants to take a stab.

All answers or hints must be CW’ed

No tricks

First off some background. The problem is not a trick question, as much as it may seem like one. There is no play on words, no hidden exception. Everything in this problem is exactly how it is presented and the answer doesn’t rely on any slight of hand. Take this puzzle at face value.

The Puzzle

There is a room with 100 jars with lids on them all in a row. There is also a stack of papers, 100 papers each labeled 1 to 100. The papers are shuffled and one paper placed into each pot randomly.

You and your assistant are in an a joining room. Your assistant is allowed to enter the room, look in all 100 pots, and if they wish they can pick any 2 pots and switch the paper in them. They can only do this one time, they do not have to do this they can choose to also do nothing. At this point they leave the room, without talking to you.

Next, someone tells you a random number from 1 to 100. Your goal is to enter the room and open a pot that has that number in it. You are allowed to open, at most, 50 of the pots.

Whatever process you use to open those pots must guarantee that by the time you open the 50th pot that the number you were given will be found. Obviously your assistant didn’t know what the number is at any point.

What rules do you give your assistant, and what rules do you follow, to ensure you are successful?

@math

For any ruby :ruby: devs out there, wanted to share a neat little open-source :opensource: module I wrote to solve a common problem. Keep in mind ruby is not my main language so if there is a batter approach here I'm all ears.

Basically right now I have a game (text based mud) and in normal and expected fashion objects in the game are created when their objects get initialized, such as a new player being created. The system then periodically saves the universe by marshalling all the object into some serialized format and saves it to a file from time to time. As tends to be the case with serialization, however, when an object is restored, such as a previous player logging out and back in, then the class is created directly without the initialize method getting called , its class and instance variables are simply populated directly.

This is where problems can arise if you change the system and add new features (such as a new variable to an object). New objects that are created will populate the new variable correctly through the initialize method however already existing players will not have that variable set at all (it won't be nil, it simply wont be set, which is a distinctly different state). This is the problem I solved.

What I did was created a mix-in module that lets you set default values for variables, once a class is reinstated from storage it checked if any variables that have defaults are unset (nil variables are considered set) and then applies the default value to them. In this way legacy objects will be able to update to new code changes automatically when it loads. To prevent duplicating code you can even intentionally leave it out of the initialize method and rely on the defaults when it is appropriate to do so.

Moreover the defaults do not have to be static values but can be determined based on the existing state of the object, which makes them dynamic and flexible... a class that uses the mixin could look like this:

require 'defaults'

class Foo
include Defaults

# @bar defaults to @baz*2
default(:bar) { |this| this.baz * 2 }
# @faaboo defaults to 178
default(:faaboo) { 178 }

def initialize
@baz = 13

line can be ommited
@bar = 26
# if you add this line instead
load_defaults
work fine
end
end

Here is a link to the module:

git.qoto.org/aethyr/Aethyr/-/b

You can see a class that utilizes this new feature here:

git.qoto.org/aethyr/Aethyr/-/b

@Science

So in my sparetime I have been writing this open-source game, a mmorpg called a MUD (no graphics in the typical sense, all ncurses based).

Anyway, I never would have thought the most complicated part of writing the game engine would have possibly been the handling of pronouns! The number of variations you have to consider is astounding when you really try to catalog all the different types.

I think I finally got them all covered though.

So took me much longer to port my stock trading algorithm over to a proper automated system then I hoped...

I knew I had something impressive because I had backtested a rudementary version of my algorithm and the ROI was astronomical. Problem was the platform I was using was very basic, it couldnt autotrade for me and was almost impossible to code anything too advanced anyway. But it did provide back testing. For some time after that i used the algorithm to trade manually, checking when it told me to buy or sell and doing it. while that proved out the ROI was real it didnt really reach its full potential as I would often trade sometime after the algorithm alerted me.

Now I have everything **finally** automated took two solid months but its working. I have thrown every stock I could find at it and after backing for a year, random years every time, different stock, not **once** has the algorithm lost me a penny at the end of any year. Some stocks it never traded on because the volume was too low and apparently it knows well enough to not go in on those stocks (not entirely sure how honestly even though i wrote the damn thing), for those stocks the ROI is 0 of course. But for every other stock I am coming in multiple times over buy&hold, even when the stock goes negative overall and crashes (it knows when to short)!!!!

I am so excited how well this is working out.

In case anyone wants to check it out, this is my dev computer. I work on massively parallel algorithms a lot of the time so I need some really heavy duty GPUs for GPGPU (those are 4 watercooled Radeon Vega Frontier Edition GPUs) and a 32 core Ryzen 3.7 Ghz threadRipper CPU, and 64 gigs of the fastest ram around. this baby is a **beast**

inb4 why the Radeon GPUs and not NVIDIA or an Intel chip... simple, they are better for many/most applications but not all. The CPU and motherboard supports the full number of channels to maximize throughput into and out of the GPUs. So while they have fewer cores compared to a Tesla the cores dont tend to be the bottleneck, the I/O is, so i sacrificed cores to max out the I/O channels where the bottleneck tends to be. AMD and Ryzen ThreadRipper CPU were the only ones doing that.

@Science

Math Tip for Coders:

Remember when averaging percentages, unlike plain values,no matter if its a simple mean, a moving average, or a exponential moving average, you always want to use the repeated operator on percentages compared to the one you would use on plain values. I know thats confusing and really only makes sense with an example.

So each of the following operators is the repeated form of the prior: +, *,^ (exponent)

Similarly the following: -, / , roots (like square root)

So for a simple mean with plain values you would average three values by doing:

(a + b + c)/3

However if your doing that for percentages that formula doesnt work instead you do:

(a * b * c) ^ (1/3)

Remember taking something to the power of 1/3 is the same as taking the third root.

Also keep in mind the variables here must be percentages such that they are anywhere from 0 to infinity. If you invested in something and you made no money and lost no money it would be 1, for 100%, if you lost all your money its 0, if you lost half its 0.5 (50%), if you doubled your money its 2.0 (200%) and so on

So if you inveted in three different things, and each time you doubled your money, and you wanted to know what your average percentage of return on investment was you would do: (2 * 2 * 2) ^ (1/3) and that would give you your mean, 2.. If you treated it like normal values and added then divided while it would work in this case it would give you significantly incorrect values in other cases.

As I stated this holds true for more complex types of averages too, take exponential moving average as an example. For plain values with EMA you apply each new value to just the previous EMA (and dont need to worry about combining all the values at once).. So if you flipped a coin 100 times and and took the EMA of the first 99 and now want to know know the EMA after the 100th flip (1 being heads and 0 being tails) you do:

(last_value * (1 - alpha) + current_value * alpha)

that gives you your current EMA where alpha is any number from 0 to 1… now to apply that to percentages again you take each operator and make it the next one up so for percentages it is actually:

(last_percentage^(1-alpha) * current_percentage^alpha)

The app is now officially 100% multithreaded with very little thread contention.. Man that wall of 100% CPUs (32 of them) is a beautiful sight.


QT: qoto.org/@freemo/1055848043840

🎓 Dr. Freemo :jpf: 🇳🇱  
So my app is running only across 32 cores so only 32 threads in action (well its python so multiprocessing)... yet it has 3,201 lock objects total ...
Show more
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.