You have found your next IT professional

Month: January 2023

Dismantle The Whole Laptop

Replacing a single failed key on a laptop can be a hassle, especially when you have to take the whole thing apart just to get to the keyboard.

Taking It Apart

The laptop fully disassembled.

I recently had to go through this process myself, and it was not an easy task. From gathering the necessary tools to carefully disassembling the MacBook Pro and replacing the keyboard, it was a time-consuming and meticulous process. The keyboard itself has 51 miniature screws holding it in place. There are very few parts of the laptop that are not removed for this. Fortunately the screen is one of them.

Laptop logic board
A1278 Logic Board

The logic board was completely disconnected and removed. Obviously a good time for a clean up but I stopped short of going at it with a toothbrush and isopropyl alchohol fearing that I was more likely do more harm than good.

The keyboard is exposed
Only the keyboard seal left, however this contains more components

Once everything has been removed and there is only the keyboard seal left you have to carefully remove this without damaging it or the lightboard inside which provides the backlighting for all the keys.

The keyboard itself
That’s a lot of screws

Finally we reach the keyboard itself and start on the 50+ tiny screws that need to removed and not lose.

Screw this!

Now Put It All Back Together

The new keyboard is in place

With the new keyboard in place we now have the task of putting it all back together correctly. Most of it is common sense but it is strongly advised to take as many photos as you can as you disassemble. Knowing which screws go where is the main challenge. They are all fairly similar.

Replacing the keyboard connector tab was nearly impossible
Not easy!

The hardest part of the reassembly was reconnecting the keyboard itself to the logic board. It’s just a thin ribbon of a tab with very little to get hold of to push into the socket. It took many attempts and it’s easy to damage it.

The laptop is fixed.
The finished article

But it’s all worth it when the we have a fully functional laptop once again.

Creating Sockets In Python

Python is a powerful and versatile programming language that is well-suited to many different tasks, including network programming. In this post, we’ll show you how to use Python to create a socket connection between a server and a client.

Before we do anything I would like to point out that it is recommended to try this on a single machine which acts as both the server and the client. Telusko does this in his tutorial https://www.youtube.com/watch?v=u4kr7EFxAKk and it makes life much simpler as you are not having to fight firewalls and more if you try and connect to a VM in the cloud for example.

With that said, let’s take a look at the server-side code. Here is an example of a simple Python server that listens on a specific port and returns a message to any client that connects to it:

import socket

# Create a socket object
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Bind the socket to a specific address and port
s.bind(("localhost", 12345))

# Listen for incoming connections
s.listen(5)

while True:
    # Establish a connection with the client
    c, addr = s.accept()
    print("Got connection from", addr)

    # Send a message to the client
    c.send(b"Thank you for connecting")

    # Close the connection
    c.close()

In this example, we first import the socket module, which provides all the necessary functions for working with sockets in Python. Next, we create a new socket object using socket.socket() and specify the address family (AF_INET) and socket type (SOCK_STREAM). These specify IPv4 and TCP respectively. (You can in fact leave these out as they are the default settings.)

We then use the bind() method to bind the socket to a specific address and port. In this case, we’re binding to “localhost” (which refers to the local machine) and port 12345. Don’t use a port in the 1-1000 range as it will probably be busy.

Next, we use the listen() method to start listening for incoming connections. The argument to this method specifies the maximum number of queued connections.

The while loop is used to accept incoming connections, using the accept() method. This method returns a new socket object representing the connection, as well as the address of the client. We use the send() method to send a message to the client, and then close the connection using the close() method.

Now let’s take a look at the client-side code. Here is an example of a Python client that connects to the server and sends a message:

import socket

# Create a socket object
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Connect to the server
client_socket.connect(('localhost', 1234))

# Receive data from the server
data = client_socket.recv(1024)
print(f"Received data: {data}")

# Close the client socket
client_socket.close()

This client code is similar to the server code, but with some important differences. First, instead of calling bind() and listen(), we call connect() to connect to the server. We then use the send() method to send a message to the server, and the recv() method to receive data from the server. Finally, we close the connection using the close() method.

© 2025 timnott-it

Theme by Anders NorénUp ↑