## First design for 3d printer

My first design for 3d printing!

You can find it on a thigverse: https://www.thingiverse.com/thing:3560965

So that is why it might be a bit over engineered, bu hey, it is fun so who cares 😉

I had some hex type key for automatic yard gate engine disabling and it that plastic handle that got broken over time. So I figured out that this fix could be a good practice to learn Fusion and make my own handle design.

Some design decisions and conclusions if they have worked out or not:

• Hex key should be fixed to the handle by tightening nut and bolt. That worked out pretty well.
• I decided that I will split handle horizontally for two reasons: a) it is super easy to print both parts from flat surface without any supports and b) I can select different infill: 100% for bottom part that holds hex key and has to be strong enough and I can select something like 10% for top part that is basically a decorative part.
• I will use two pins to join top and bottom part. That did not work very well: pins got broken on assembly ( I forgot to make them 100% infill ) and instead of just drilling them out, I just glued top and bottom parts together.

## 8086 disassembler using 64 bit assembly language

8086 disassembly application. Project done during computer architecture course.

Project is done using nasm(yasm) 64 bit assembly and some c functions to handle input/output.

I have chosen such technologies because I was curious about few topics:

• Learning about asm 64 bit programming
• Compiling assembly executable for windows 64 platform. During the comp architecture course we were doing assembly programming for a ms dos using dosbox. I was interested in making some executable code on a windows 64 platform.
• Linking assembly code to some higher lever programming language library. During the comp architecture course we were using dos api (int) to handle input, output and some other manipulations. For modern platform you could use windows api function calls or libraries from higher level programming languages. I have chosen to use c and use some basic c input output functions.
• Understanding assembly procedure calls on 64 platform and differences between win 64 calls and unix/posix 64 calls.
• Disassembling some simple c applications and exploriing how assembly code is constructed using c compile. To understand how some c function calls are made I have used some super simple c programs that I decompiled using gdb.

This project can be found in github.

## Ubuntu install Clojure

sudo apt install default-jre
sudo apt install leiningen

lein repl

//Install IntelliJ IDEA
snap install intellij-idea-community –classic –edge
intellij-idea-communituy

## Program to find GCD of two polynomials

The objective is to write a program that finds greatest common divisor of two polynomials g(x) and h(x).

The task does not define what form we get those two polynomials, so let’s say we will get them in a form of a String, something like that:

$2x^3+5x^2+8x+3$

Let’s start splitting our problem into chunks and gather some information about the steps we would need to implement.

First, what is the greatest common divisor? In math, GCD of two or more integers, which are not all zero, is the largest positive integer that divides each of the integers (1).

How do we find it? One way is to use the Euclidean algorithm. The intuition behind this algorithm is such: we have A and B numbers. We divide A by B and get C. If C is 0 – then B is our GCD. If it is not 0, then we set A to B and B to the reminder and continue operation until we get 0.

$gcd(a,0)=a$ $gcd(a,b)=gcd( b,a\,mod\,b )$

Let’s say we have 12 and 9. 12 mod 9 is 3. 9 mod 3 is 0. So our GCD is 3.

Ok, now we know about GCD and Euclidian algorithm. Next topic – Polynomials.

Polynomial is an expression consisting of variables (x,y,z etc) and coefficients, that involves only operations of addition, subtraction, and non-negative exponents of variables.

Example of a polynomial with single indeterminate ( variable ) x is

$x^2-4x+7$

An example in three variables is

$x^3-2xyz^2-yz+7$

Our objective states to find GCD of g(x) and h(x) polynomials, so we assume objective is to find GCD of single variable polynomials.

Also, for the sake of simplicity, we could say that polynomial consists of a list of monomials with the same variable. Each monomial is made of an optional coefficient, optional variable with optional non-negative integer exponent.

So in $x^2-4x+7$ we have list of monomials $x^2$, $-4x$ and $7$.

Now we have defined GCD and polynomials. But can we apply the Euclidean algorithm to find GCD for Polynomials? And the short answer is yes.

We will supose that  deg(g(x)) <= deg(h(x)).

Then we find two polynomials q(x) and r(x) that satisfy:

$g(x) = q_0(x)h(x)+r_0(x)$ $deg(r_0(x)) < deg(h(x))$

Where q is quotient and r is reminder.

Then we set $g_1(x)=h(x)$ and $h_1(x)=r_0(x)$.

And we repeat polynomial long division to get now polynomials $q_1(x)$ $r_1(x)$ $g_1(x)$ $h_1(x)$ and so on until we reach point when we get $h_n(x)=0$.

$gcd(g,h)=gcd(g_1,h_1)=\cdots=gcd(g_n,0)=g_n$

Lets conclude what we knwo at this point: we know what is GCD, we know abut Euclidean algorithm to find GCD, we know about polynomials and monomials and we know that we can apply Euclidean algorithm  to find GCD for polynomials.

There are some things to find out though. When applying the Euclidean algorithm to polynomials we use Polynomial long division for dividing a polynomial by a polynomial of the same or lower degree.

We will have to implement this either to get our quotient and remainder of the polynomial division.

1. divide the first term of the dividend by the highest term of the divisor
2. multiply the divisor by the result just obtained
3. subtract the product just obtained from the appropriate terms of original  dividend
4. repeat the previouss three steps except this time use the two terms that have just been written as the dividend.

Example:

Divide $\frac{5-2x^2+3x^3}{x^2-1}$

Step 1. Make sure polynomial is written in descending order. If any term missing, use a zero to fill in the missing term. In this case we should get:

$x^2+0x-1\overline {)3x^3-2x^2+0x+5}$

Step 2. Divide the term with the highest power inside the division symbol by the term with the highest power outside the division symbol. It his case, we have $3x^2$ divided by $x^2$ which is $3x$.

$x^2+0x-1\overline {)3x^3-2x^2+0x+5} \quad 3x$

Step 3. Multiply the answer obtained in the previous step by the polynomial in front of the division symbol. In this case we need to multiply 3x and x^2 – 1.

Step 4: Subtract and bring down the next term.

Step 5: Divide the term with the highest power inside the division symbol by the term with the highest power outside the division symbol. In this case, we have –2x2 divided by x2 which is –2.

Step 6: Multiply (or distribute) the answer obtained in the previous step by the polynomial in front of the division symbol. In this case, we need to multiply –2 and x2 – 1.

Step 7: Subtract and notice there are no more terms to bring down.

The polynomial above the bar is the quotient q(x), and the number left over (3x+4) is the remainder r(x).

If A = BQ + R then

$5-2x^2+3x^3 = (x^2-1)(3x-2) + (3x+4)$

Step 8: Write the final answer. The term remaining after the last subtract step is the remainder and must be written as a fraction in the final answer.

i.e. $\frac{A}{B}= Q+\frac{R}{B}$

(Example is taken from here )

Looking at those steps we can see that we will need to implement those primitive steps in our application:

• Polynomial sort by exponents.
• Polynomial missing term expansion.
• Monomial division.
• Monomial multiplication.
• Monomial subtraction.

So now: we know what is GCD, we know about Euclidean algorithm to find GCD, we know about polynomials and monomials and we know that we can apply Euclidean algorithm  to find GCD for polynomials and then we know how to perform long division on polynomials.

At this point we have enough information and can start writing some code.

Recently received two ThinkPad T42 laptops ( some company decided to upgrade its IT and were giving away them almost for free ). After turning them on got an 271 error and later was prompted to enter password.

It seems battery was dead on both of those laptops and when its dead, real time clock goes bananas and you are asked for supervisor password to set the clock again ( if supervisor password was set ).

Offcourse nobody knew anything about what password it was. So had to figure it out myself how to solve this situation.

On ThinkPad T42 SVP password is stored on EEPROM chip 24RF08. One thing that sometimes work and was reported by many T42 users is to short pins 3 and 4 of 24RF08, procedure:

• Short pins 3 and 4 of 24RF08, keep them short
• Press F1 to go to BIOS
• Release shorted pins
• Enter new password, save and reboot.

Then go to BIOS again and disable SVP password by entering the password you just saved.

Like they say – “it worked on my two t42 machines” 😉

## ZX Spectrim 128 +3 composite video output and drive belt replacement

Did some work on ZX Spectrum 128 +3 I have. One thing was I wanted to make it work with small “TFT Color monitor” (for a car rear view). This monitor has a composite video input.

First I tried using CSYNK and GND signals for a composite video input. You get the video but it was terrible quality. It seems that “The 128 ZX Spectrums including the +3 (and +2A, +2B) have audio sound modulated onto the video, which reduces the clarity of the composite signal that is available at the modulator input.”(1).

Then I found this document – “Video fixes and video cables
for all ZX Spectrum 128K models”. There is a chapter on Creating composite video-out on a +2A / +2B / +3:

“Although the ZX Spectrum 128K heat sink model and the grey ZX Spectrum +2 have a composite video-out signal on pin 1 of the RGB connector, the ZX Spectrum +2A, +2B and +3 are missing this feature.
Instead of the composite video signal they have a dangerous 12V on pin 1 that will seriously damage your TV or monitor!
But you can add the composite video signal yourself, with the same fairly simple circuit as that is integrated on the heat sink model and +2.
The steps:
1. First remove the 12V from pin 1 by removing resistor R44 (should be the same for +2A, +2B and +3, and very close to the RGB connector).

And here is the result:

## The Shallows: What the Internet Is Doing to Our Brains

Recently have finished this book. From the times of Plato and Aristotle our brain and way of thinking is changing and adapting to our way of living. Every tool we use becomes a part of us, but also we become a part of a tool we use. Clock, written word, computers, world wide web. Everything we use changes us, changes how we think, changes how we remember things.

Its a good read that raises a lot of interesting topics.