Mastodon Politics, Power, and Science

Wednesday, September 27, 2023

Connecting from macbook to linux using samba.

 I was not able to connect to my linux machine from my macbook air using smb. I found the following string:

smb://WORKSPACE%5cUsername@Hostname/Username/

And putting this string into the Connect to Server box I connected right now. Weird that this didn't work in the gui.

That is %5c between the WORKSPACE and Username.


Now it is leaving little ._ files on the network drive when you load an image.  This is supposed to turn those little dot turd files off from the mac side.

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true


Then reboot.

Monday, September 25, 2023

Got an old arcade controller working.

 I had a now ancient arcade controller that hasn't work since sometime before the end of the last century.  It was basically just a big box of microswitches not hooked to anything.  I had been building an arcade cabinet at the time.


I bought a generic usb controller board from amazon based on lowest price.  It came with the wires to connect the board to the microswitches. It also had a longer wire with a usb connector on one end and a 4 pin board connector on the other end, along with a strain relief.  I searched for "Zero Delay Arcade USB Encoder" and came up with a huge list.  I could have gotten 2 of them for just a little more than I paid for one of them. 



I removed all the existing wires from everything but the joystick and put all the connections to the nearest open port on the board.  It doesn't really matter how you set it up, except for the 4 connections on one end adjusted the board settings. 

I left the wires attached to my joystick, but I had to switch two wires to get the common wire that went to every switch to the end.  The other wires are labelled with two letters, I'm sure you can figure that out.  Luckily the board connector on the joystick wires plugged right into the new board.  I ran the connector through the hole and forced the strain relief into an empty slot in the back.  

I plugged the board into my retropi machine that I just built and booted and was able to map the keys how I wanted. :D  I am now playing robotron with a game pad in my left hand and this arcade joystick in my right hand. :D 

I screwed the board into the bottom side of the top of the case.  I reused tiny screws I got from taking apart another project. :D  If not you may need to order some tiny screws from or just use a generous amount of hot glue. :D  I even had the bottom of the case I removed 20 years ago.  I fortified it with 4 felt pads to act as standoffs to keep the screw heads from scratching anything,  If I remember correctly the old case had little rubber standoffs held on by the case screws.  


Fin.

Upgraded the ssd in a 2017 intel mackbook air

Before starting this upgrade I made sure to upgrade my macbook to the latest version of the OS.  It seems that only the latest Montgomery OS has the internet restore option to load the OS onto the new drive. 

I did not back up the drive before I installed the OS, because I wanted a clean install without any older software versions left behind.  I did copy off everything I wanted to keep from my home directory. If you attempt a similar upgrade based on your research you may want to backup the drive before hand.  Be aware that your choice of drive formatting may affect if the backup and be restored to your computer.  Be sure that your exact model computer can be upgraded.  Be sure the drive you choose is useable by macbook.  I can't help you or recommend anything other than what worked for me. I just don't know.  I got lucky and everything worked for me.

Don't follow these directions.  This is merely an account of how I performed these operations to upgrade my solid state device.  These directions may not work for you and it could cause you to destroy your laptop or the new drive. Proceed entirely and solely at your own risk. Do your own research and create your own detailed step by step plan.   Your mileage may vary. Package contents may settle during shipping. Batteries not included. Seriously.  This worked for me, but it might not work for you.  I have no affiliation with any amazon seller whose products I linked to in this post.

The laptop came from the factory with an very small solid state drive that was 128GB in size.  This is barely big enough to hold a dozen big ai models.  I had a 250GB usb thumb drive attached to store my SD 1.5 automatic1111 setup.  I had managed to fill this up too with checkpoints and lora.  I was also worried about nuking the old ssd from overuse from swapping because it swaps almost constantly. After researching this I determined that 2017 and prior macbook air laptops do not have soldiered in solid state drives.  But they use a proprietary apple only drive.  There is an adapter to convert a standard drive to the correct format and length.  

https://www.amazon.com/gp/product/B07VVNKRYR/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&th=1

I then found a low cost ssd. I made sure it had good reviews.  I went with the 1TB disk, but the 2TB drive was only about $20 more. Again, if you are doing this, you might want to use a different drive.

https://www.amazon.com/gp/product/B08X4Z4R1Y/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&th=1

The little board goes on the end of the new drive.  It will click in once it is far enough. As always, don't force, it only goes on oneway, look at the key.

One problem I ran into was not having the correct pentalope screwdriver set to remove the bottom panel and take out the screw in the internal drive that holds it into place.  I have a thousand bits, along with hundreds of security bits, and not one of them would work on this. So I had to order a set and it took me another week to get this:

https://www.amazon.com/gp/product/B074QM29ZM/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1

Once it all came, I powered down the computer and removed the bottom of the case, being careful not to lose any of the screws, there were 8 small screws along the front and sides and 2 longer screws in the middle back near the hinge. I was careful not to strip any of them out when removing or installing the screws.  

I used the included little plastic wedge from the screw driver set to gently pry up on the back of the case near the hinge and it popped free easily.  Changed to the small hex screw driver in the screw driver set to remove the one screw holding in the existing ssd.  

Be very careful here. There are dire warnings about raising this drive up too high and destroying the connector on the board.  So I raised it up just high enough to wiggle free of the connector, less than a quarter inch.  

I sat aside the old drive in the packaging I got with the new drive and labelled it as such, incase I needed to put it back in.  I put the new drive also keeping it very low, just high enough to click into place.  I noticed that the board was a little longer than the lip on the screw hole by a fraction of an inch, so I carefully tightened down the screw as far as possible and without crushing the board. 

The bottom snapped back down into place. I carefully put the screws all back into place, the two longer ones in the middle back near the hinge. I was careful to not over-tighten and strip out the screws.  Once they were all in, I when back around and got a few of them a little bit tighter.  Again, I was careful to not strip them out and to not cross thread anything.

I made sure to have access to a high speed internet connection for the next step.  I held option command r down as I powered on the computer.  Once I saw a swirling circle and the restore application starting I  let up on the keys.  After a minute or two I was able to connect to a network and it loaded the app to format and install the os.   

I formatted the drive as APFS and used a guid partition table.  I researched which was best, and a web page I read said that APFS was optimized for modern solid state drives to install macos. 

Then I selected the install os option and chose the drive I just formatted.  It took about 3 hours to install.  At one point it claimed it was going to take 21 hours.  But that was fake news.  The machine rebooted a few times during this process.  Another website said that sometimes you have to try a few times to install if it fails because of the internet connection.  If this keeps happening try a different internet connection, the faster the better.

Once the machine came back up it was just like when I got the computer brand new.  It walked me through page after page of setup.  I read each page and did what I thought was best.  Once I got logged in I was surprised to have to set the wifi password in a second time.  It didn't keep this setting from the OS install.  

I then installed a lot of software to get the machine useable again, and copied over the 250GB thumb drive to get my Stable Diffusion 1.5 install set up on the much faster ssd now. 

I did setup time machine on this new drive.  All I had to do was connect a 2TB drive to the machine and erase it and the macbook popped up a "Do you want to setup time machine on this new external drive." Which I did.  Time machine is very cool.  I have setup an rsync based backup on Linux before and this is very similar. The first backup took a few hours to backup the OS, the apps, and the SD 1.5 folder. But after that it only took a few minutes once an hour to just do a diff and get the few changed files. 

So I now have a 2017 Intel Macbook Air with a 1TB drive that starts and runs a desktop much faster than before.



Wednesday, August 2, 2023

AI Is changing fast.

 Just the last couple weeks several huge open source releases of chat and image generation AI happened,  ARM IPO is blowing up based on their future role in AI, AMD chips that support AI were released,  and Nvidia announced the release of a ground breaking release of a new image generation technology called Perfusion.  

It is an exciting time to be alive.  It is almost a full time job to try to just skim the headlines. 

This week I finally wrote my own little neural net to recognize the hand written characters of the MNIST data set.  I followed a tutorial for python that only used the matrix library numpy and coded up a 2 layer neural net.  I watched a few other videos as well.  Planning on picking up a copy of Neural Nets from Scratch, it looks like a great book.  

My plan this week is to build a tiny c library to implement a neural net object.  Combined with a few other small c libraries that implement ai, and running all the different tasks cooperatively, at the same time, this kind of tech could be ground breaking.   If a small, inexpensive arm chip was created that had dedicated ai acceleration built in and a library like this supported that chip then that could be an amazing reference system that could change the world.

A small library that implemented general neural nets, generate stories, speak, can turn speech into text, and has a layer to manage all that could revolutionize drones, robotics, toys, security systems ( with a visual ai), and just about any technology we use today.  A door bell or answering machine could call screen for you.  Imagine a thermostat that actually was intelligent. 

I think Christmas in 2 years is going to see a toy that isn't powered by AI is going to be a toy that no kid wants.  There won't be an alarm clock, door bell, weather station, thermostat or other small consumer good that isn't intelligent.  

A year after that every medical device is going to be smart.  A blood pressure cuff that knows more about reading blood pressure than any human is a game changer.  

Monday, July 31, 2023

Fix the worlds electrical systems.

 

There are four main areas that need fixed. 

1. The main grid.

   The main grid needs to be beefed up to carry power from areas that have a surplus to areas that are lacking power.  We need to switch to super conductors in downtown metro areas for efficiency.

   There is also the fact that our electric grid is very vulnerable to emp and solar flares.  We need a method of disconnecting the wires of the main grid from the big transformers to protect them from these effects.  

    We also need backups of the big transformers in distributed warehouses ready to be deployed in hours to fix a burned out system.  Right now it would take years to build and deliver these transformers if they were damaged by a catastrophic event. 

2. Upgrade houses to be smart homes.

   Appliances should be smart and connect to the houses control unit.  This control unit should schedule when things run to reduce the demand that is being placed on the electrical grid.  So the fridge doesn't run at the same time as the ac unit.  The control unit should limit the draw of the entire house to no more than 20 amps.  Battery packs should be charged at night, or charged from the home grid in the day.  If electrical power is used to heat water, this should be done at night.  If done correctly this staging and running of appliances could reduce power needs of households in America by a factor of 5.

3. Switch to solar power, wind power, and water power.

    If your house needs more than 20 amp service, or when the main grid is out then you should be able to switch to batteries at your own home that are charged with locally produced solar, wind, and water power.  A 10KW solar panel on every's roof with a wind turbine for windy conditions would be enough to charge these batteries, come wind or shine.

    And here is where the beefed up grid from step one comes into play.  When the main grid senses a lack of power in one area it should signal other areas and they put power from their batteries or from their solar/wind/water power sources back onto the grid.  Imagine west coast helping out the east coast in the morning and then the east coast helping out the west coast later as the heat peaks in the west.

   The power system could keep track of home much power you add to the grid and how much you take from the grid and charge you for the power you used minus the power you added.  Plus a flat rate to maintain the power grid. 

4. Stop using carbon to heat water.  

    Heating water is 1/6 the energy use in every single home in America.  Switch to solar water heaters to heat water.  You could build tubing into the back of every solar panel and use that to both cool the panel and heat antifreeze. This warm antifreeze could then be put through a small bank of high temp vacuum tubes with reflectors to focus the heat on nickel coated copper tubes to get the temps up to nearly boiling.  Then run this heated antifreeze through tubes in a 500 gallon water tank to store the heat.  A small solar panel could run the pumps for this system, the intensity of the sun on the solar panel being all that is needed to regulate the speed of the liquid through the system.  Heavy bags of paraffine that each have a different melting point could be used to store heat in their phase change of switching between solid and liquid states. Like heat storing batteries. 

    If you need to use electrical power to heat the water, then would only be allowed to happen at night, when there is a surplus.  You could use your own electrical power anytime during the day, say after you reach full charge on the batteries.  Any wind power needs a   The houses controller could mange this to keep the water up to temp while using a minimum of grid power.

  This tank could be used for hot water for the sinks and shower. It could also be used to heat a loop of antifreeze that runs under the floors of the perimeter of the house and holds most of the cold at bay.  A loop of this heated water could be put under the floor in the bathroom for toasty warm floors all the time there. 


Tuesday, July 25, 2023

How to build a neural net from scratch in python.

 Found a very good video with sample code.  Very easy to understand how this works.  Only uses the numpy linear array library.  


https://www.youtube.com/watch?v=w8yWXqWQYmU

https://www.kaggle.com/code/wwsalmon/simple-mnist-nn-from-scratch-numpy-no-tf-keras/notebook


Here is a screen shot of one of the test runs and some code.




Weekly ai update


This week I upgraded to the uncensored 7b version of the newly released Llama 2 chatbot ai model.

https://huggingface.co/TheBloke/llama2_7b_chat_uncensored-GGML/tree/main

I run it with llama.cpp :

https://github.com/ggerganov/llama.cpp

I finished putting thumbnails on all my lora and, ti, and checkpoints. I actually found 2 hypernetworks and tried both of them out yesterday and today. gothicRPG_ArtStyle_v1 and IncaseStyle_AnythingV3, but I used it with Anything V5.

Tried out sd upscale but it didn't work for me. Downloaded and installed the Ultimate SD upscale to try it out.

I installed a couple of extensions to automatic1111 that control the aspect ration better. I found an extension that shows the images and and lets you look through everything you have generated easily called, "infinite image browsing."

Found the smallest ai program that uses modern techniques that can run fast on very small computers. I could see just about everyone releasing intelligent devices with $5 computers installed that can talk and listen and tell stories. Crazy how fast ai is moving to the slowest and cheapest computers. It is being called baby llama.

https://github.com/karpathy/llama2.c

The code that performs the magic is less than 500 lines. One of the really cool pieces of code that I had not seen before is the following code before a for loop:

#pragma omp parallel for

This is clever and elegant because if you don't give the flag and library at compile time, the compiler just ignores it, allowing your code to be really simple. But if you compile it with the flags -fopenmp -lomp then those for loops are magically multithreaded and run many times faster than they would otherwise. Planning on rebuilding a bunch of my old code and see how much faster I can make it.

Player Portal in Mega Mappers

Codex Engine: Player Portal, Auth, Rules-as-MCP & AI NPCs (Pure Node-Tree Edition) Defining game rulesets (D&D 5e, Pathfinder, Cyber...