A little #Ruby gem I just published that allows you to create true abstract classes and methods in Ruby. Basically throws an error at instantiation / creation of an abstract class if abstract methods arent implemented.
While there are a few gems that allow you to create abstract classes and methods all of the ones i found just cause abstract methods to throw errors when called if not implemented. This solution actually throws an error when you attempt to create the class itself, so it is fail-fast and more in line with the spirit of an abstract method.
Repo: https://git.qoto.org/abstractify/abstractify/-/blob/master/spec/abstractify/abstract_spec.rb
Gem: https://rubygems.org/gems/abstractify
PS: Probably the first and only project I will ever write with a true 100% code coverage report :)
Ya know the more I reflect on the languages I know the more I realize that outside of functional languages none of them really handle immutability well.
Consider that you want most of your objects to be immutable most of the time. Thats all well and good till you realize you want to be able to edit the objects in such a way that it creates duplicates that have some data changed but are likewise immutable.
This tends to stop working, almost entierly, once you get into subclassing. If you parent class has a method that returns a copy of itself with some data modified, this will break in children classes, since you want children classes to return instances of itself, not its parent.
Its not that you cant fix that, but the code gets very ugly very quickly. Generally you are forced to let the code handling the classes do the copying and editing itself, but that is pretty ugly too.
I have had this pattern problem in almost every OO language i messed with, Java, Ruby, Python, etc.
Please #Share this to help others, thanks!
I offer free tutoring in most college level #STEM courses. Can be online, just random questions, video chat, or even in person.
If anyone needs help learning any STEM topic (even you arent in school), please reach out to me I am always happy to help. If I dont know the subject I can also maybe connect you with someone who does, but I am well versed on most of the basics like #Math, #Biology #statistics #BigData #programming #Chemistry #Medicine #ElectricalEngineering and #RF design.
I suspect docker removing the free tier is going to absolutely devistate them. All the open-source software, which is what dominated docker, is now scrambling to find alternatives.
Also since docker treates docker hub as first class for fetching images I suspect people will move off docker entierly.
It is going to be pretty crazy for the open source community too having all the images they depend on just disapear. Dev chains everywhere are going to break...
So despite being in charge and ultimately the guy who decided to get my entire company using JIRA I must admit... I hate it... As with many GUIs just way too much clicking and waiting and im too impatient.
Anyway, so I decided to install jira-cli ( https://github.com/ankitpokhrel/jira-cli ) and I cant tell you how much nicer this is, certainly improves my stress levels...
If anyone is curious this is what a full workflow from ticket creation to completion looks like for me. Keep in mind if you are on a JIRA instance that isnt customized you can probably get by with fewer steps.
> myjira issue create -pSYS -tTask -s"Configure jira cli w/ aliases" -b"Add to nixos config and create some helper scripts for commands" -yHigh
>
> myjira issue move SYS-125 Accept
>
> myjira sprint list -pSYS
>
> myjira sprint add 65 SYS-125 -pSYS
>
> myjira issue edit SYS-125 --custom story-points=2 --no-input
>
> myjira issue assign SYS-125 "jeff@scentech-medical.com"
> myjira issue move SYS-125 "Start Work"
>
> myjira issue worklog add SYS-125 2h --comment "Started reading up on the subject" --no-input
>
> myjira issue move SYS-125 "Ready for Review" --comment "Successfully printed from lab office's printer using shmuels computer"
>
> myjira issue move SYS-125 "Accepted" --comment "Shmuel confirmed it is working for him now"
#JIRA #Productivity #Programming #dev #Development #CS #ComputerScience
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.
#riddle #algorithm #computerscience #programming #algorithms #puzzle
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.
The PlsExplain programming language attaches a comment to every value that propagates with the value. Kinda cool.
Can I get some feedback on a static website im designing for my new company? Would love to get some feedback on asthetics.
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:
https://git.qoto.org/modjular/jupyter-all
or just get the docker container image directly: modjular/jupyter-all:latest
#Docker #Python #R #Ruby #julia #Haskell #Javascript #Rust #programming #foss #oss #coding #container #containers @Science
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 four other languages ( #Ruby #Julia #R #Haskell ). 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 ( #Python 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.
Stolen, lol.
#programming #computers #computerscience #math #maths #mathematics
## 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 #Math #Maths #Mathematics #Puzzle #Puzzles #logic #LogicPuzzles #Programming #algorithm #algorithms
For any ruby devs out there, wanted to share a neat little open-source
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
#this line can be ommited
@bar = 26
# if you add this line instead
load_defaults
#either work fine
end
end
Here is a link to the module:
https://git.qoto.org/aethyr/Aethyr/-/blob/master/lib/aethyr/core/util/defaults.rb
You can see a class that utilizes this new feature here:
https://git.qoto.org/aethyr/Aethyr/-/blob/master/lib/aethyr/core/objects/game_object.rb
#Ruby #RubyLang #Programming #Coding #software #ComputerScience @Science #code #source #sourcecode #opensource #oss #game #gaming #gamedev #QotoJournal
You can run a whole OSX sysem inside docker now, gui and all... I havent tried it out yet but looks legit.
Jeffrey Phillips Freeman
Innovator & Entrepreneur in Machine Learning, Evolutionary Computing & Big Data. Avid SCUBA diver, Open-source developer, HAM radio operator, astrophotographer, and anything nerdy.
Born and raised in Philadelphia, PA, USA, currently living in Utrecht, Netherlands, USA, and Thailand. Was also living in Israel, but left.
Pronouns: Sir / Mister
(Above pronouns are not intended to mock, i will respect any persons pronouns and only wish pronouns to show respect be used with me as well. These are called neopronouns, see an example of the word "frog" used as a neopronoun here: http://tinyurl.com/44hhej89 )
A proud member of the Penobscot Native American tribe, as well as a Mayflower passenger descendant. I sometimes post about my genealogical history.
My stance on various issues:
Education: Free to PhD, tax paid
Abortion: Protected, tax paid, limited time-frame
Welfare: Yes, no one should starve
UBI: No, use welfare
Racism: is real
Guns: Shall not be infringed
LGBT+/minorities: Support
Pronouns: Will respect
Trump: Moron, evil
Biden: Senile, racist
Police: ACAB
Drugs: Fully legal, no prescriptions needed
GPG/PGP Fingerprint: 8B23 64CD 2403 6DCB 7531 01D0 052D DA8E 0506 CBCE