64Zbit.com
Tech is way, WAY interesting

Ping network monitor

The ping command is a built in linux and macOS command that shows the performance of the network connection to a remote server. It can be used to log network performance issues over time. The default ping command displays the results to standard output (the shell window). Used with the following options it routes the output to a file that you can look at later.

The ping command will ping the remote server every second until you manually kill the process. This will create 86,400 pings per day in the output file. It's not something you want to forget about and let it run forever. It could create a very large file that fills up your drive space and crashes your system. I run my ping network monitor on a Raspberry Pi 4 so that it will run 24 hours per day in low power and uninterupted environment.

Ping directed to a file

You would normally just run the ping command interactivly and then stop it when you are done. But, that's not what we are doing today. We are looking for an intermident bug that may happen anytime in the future. For this we need to run the command for weeks at a time and be able to look at the results after a network error has been detected.

Here is the ping command, running in the background, with the output directed to a file called "network.log".
Copy and paste this text to your command line.

ping google.com 2>&1 | while read pong; do date "+%c: $pong"; done >network.log &

Here are the details of what this command does

  • ping // the ping command to run
  • google.com // name of the remote server
  • 2>&1 // routes stderr to stdout
  • | while read pong; do date "+%c: $pong"; done // pipe the ping results and add the current date and time
  • >network.log // routes output to file network.log
  • & // at end means to run in background

The pipe command, represented by the vertical bar | takes the output of the first command and routes it into the second command. In this case it takes the output of the ping command and routes it into a command that prepends the current date and then uses the > command to route everthing to a file instead of standard out (stdout).

The & at the end of the line makes this command run in the background. This frees up your terminal so you can run other commands. It will continue running even when you exit your terminal and logout. The commands below show you how to find the background command later and control it.

Jobs and Processes

The jobs command only works for jobs you have started in the current shell. If you exit the shell and open a new one then this command will not display your jobs. You will need to use the other commands listed below to work with system level processes.

Fun fact: jobs are started by a user, processes are started and managed by the system. A users job is also a system process.

Process Id

Every command running on the computer is assigned a unique process id (PID). You can use this PID to interact with background processes.

The terms Command, Job, and Process are basically the same thing. They are programs running on your computer.

Type top into your shell to see a list of the top processes running on your current computer. Notice the PID column listed on the far left. Type q to exit this view. For a fun day of reading type man top to read all the details of the top command.

Use the jobs command to see running background jobs, -l shows the process id (PID). (That’s a lowercase L)

jobs -l 

Viewing your ping log

Use the cat command to view contents of the output file, use the | more option to show a page at a time. This could take awhile, you are getting 86,400 lines per day and paging through them a few lines at a time will get tedious.

cat network.log 
or
cat network.log | more

Look at the output

If all goes well you should see a time= value at the end of each line. This tells you the ping completed successfully and you have a good connection to the server.

When the connection goes down you will receive error messages. These will be helpful in determining what went wrong.

Example showing a request timout error

Use grep to find interesting data

The grep command will help you find interesting data in your output file.

cat network.log | grep -v time

The -v option tells grep to "invert match", so any line that does not contain the "time" string.

This command will search the network.log for any line that does not contain the string "time". So for any ping command that returns anything other than a normal ping time will be displayed. This includes any error messages that you should look at.

Example showing an unreachable server
Example showing an unreachable server

Find your running ping command

Use the pgrep command to find running ping jobs and return the process id (PID). Pgrep is included in many Linux distributions.

pgrep ping 

Example showing pgrep ping output

pgrep returns the process id (PID) where the string matches. In this case the PID = 24895. Warning: Don't use this PID, use the PID you find on your own system.

Stopping the ping command

Use the kill command to stop a running job. Be careful, you can kill the wrong job and crash your system. Make sure you enter the correct process id (PID) you found above.

kill PID 

Here's nother command to find the running ping processes. Use ps if your distribution doesn’t include the pgrep command. The ps command displays the current process status for all running processes. It's a long list and you can use grep to show you just what you want.

ps -aux | grep ping 

Example showing ps -aux output

The process id on this distribution is in the second column from the left. In this case the PID = 24895.

Removing the network.log

When you are done with your analysis you can remove the network.log file with the rm command. Becareful not to remove the wrong file, this can crash your system.

rm network.log

References

More info about the Jobs Command
https://www.computerhope.com/unix/ujobs.htm

Date logic from
https://stackoverflow.com/questions/10679807/how-do-i-timestamp-every-ping-result

Use the linux manual pages to learn more about each command.
man kill
man ps
man grep
man pgrep
man ping
man cat
man more
man jobs
man date
man top
man rm

You can search for the linux pipe command too.


Save Text Snippets to DayOne using Better Touch Tool

For a long time I've wanted a quick way to save text snippets in a timestamped, quickly searchabe form. Today I created a Better Touch Tool keyboad shortcut to save text snippets to a specific DayOne journal.

Here are the details on github so that you too can enjoy this amazing automation feature.

dougpark/dayone

Better Touch Tool create a DayOne journal entry. Contribute to dougpark/dayone development by creating an account on GitHub.

dougparkGitHub


How-build-computer-controlled-robot

Read the full article at www.amazon.com

The book that started it all for me. Sometime around 1979 #kim1 #6502 #robot #diy #developer


Raspberry Pi USB boot

How to install Ubuntu Desktop on Raspberry Pi 4 | Ubuntu

Ubuntu is an open source software operating system that runs from the desktop, to the cloud, to all your internet connected things.

Install Ubuntu Desktop on Raspberry Pi 4

Covers the basics of updating your Pi 4 to USB boot.


Pluto Attacks

Html5, Phaser 2, Action packed arcade game

Pluto Attacks was previously hosted at povingames.com

Play Now

"The Plutonians are not happy with us calling their home a 'dwarf' planet. So when they discovered a trick in the space time continuum they sent an infinite number of drones to attack Earth. We created an energy weapon that can siphon off the energy from the drones weapons. This powers the Earths vessel and creates a powerful energy shield. Remember, don't let even one alien escape!"

Poving Games released this intense shooter based on the classic Phaser Invaders example and then taken it into complete overdrive! You don't have to shoot, that is done automatically. You just move left and right and blast away the plutonains. It all starts quite calmly and you'll no doubt do a perfect clearance of the first few levels.

Read More at phaser.io

Read More at html5games.net

How To Play

You can start at Normal level 1 if you want to see how it all began. Typical space game with normal dodge and shoot action. You can even level up to the 20’s and still play a dodge and shoot game. However, it will drive you crazy and you will get bored.

The fun begins at about Fun level 20. Everything is faster and you quickly realize there is more to the game then just dodge and shoot. In fact dodging is no longer possible. There are explosions, lots and lots of explosions.

Plutonians are not happy with the reclassification of their home world to Dwarf Planet. So when they discovered a trick in the space time continuum they send an infinite number of drones to attack Earth. Earth learned just enough about their technology to use it to their own advantage. We created an energy weapon that can siphon off the energy from the drones weapons. This powers the Earth vessel and creates a powerful energy shield.

For desktop just press the space bar to start and then left and right arrows to move. That’s it.

For mobile just tap to start and then use your finger to move back and forth. It’s actually easier and more fun on mobile.

Levels go by pretty quickly. Hey, it’s a game with only two buttons and you can master it in 60 seconds. By level 20 it’s moving right along and by level 30 it’s actually pretty good. Have Fun!

Tip: Don’t let any aliens escape!

Pluto Attacks


Future Projects

I've been doing this for decades and now I want to be an HTML5 game devloper. I'm starting with a server! Well, I have very little experience with game development, graphics, animation, sound, so it's going to be a fun journey.

Stories in the pipeline:

  • VSCode Remote
  • Installing Docker, Docker-Compose
  • Nodejs with socket.io
  • Nodemon sounds like Pokemon, yep!
  • SSL and Letsencrypt certificates
  • Working with Apache, MySQL and PHP
  • Hosting your own VPS backend with Linode for $5 a month
  • HTML5 games and AJAX are best buds
  • HTML5 games and socket.io are even better buds

macOS - BitBar - Get Wi-Fi SSID with shell script

So, Jason Snell got me hooked on BitBar (BitBar (by Mat Ryer - @matryer) lets you put the output from any script/program in your Mac OS X Menu Bar.) and I've been working on a plugin ever since. Here's a quick way to get your current Wi-Fi SSID.

function display-ssid {
    echo "---"
ssid=$(/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I  | awk -F' SSID: '  '/ SSID: / {print $2}') 
    echo "Wi-Fi: $ssid | terminal=false bash='$0' param1=copy param2=$ssid"

}

Get wireless SSID through shell script on Mac OS X

Is there any way to get the SSID of the current wireless network through a shell script on Mac OS X?

Mark SzymanskiStack Overflow

SSID with shell script


How to answer questions in a helpful way

We all work together. I always try to assume the other person is asking a serious question. Depending on how tired I am I may not answer in the best way. Here are some tips to stay on track.

How to answer questions in a helpful way

Answer Questions Well by Julia Evans


How to think like a programmer — lessons in problem solving

How to think like a programmer — lessons in problem solving

by Richard Reis How to think like a programmer — lessons in problem solvingBy Richard Reis [https://twitter.com/richardreeze]If you’re interested inprogramming, you may well have seen this quote before: > “Everyone in this country should learn to program a computer, because it teachesyou to thi…

How to think like a programmer


The Gateless Gate

"This classic Zen Buddhist collection of 49 koans with commentary by Mumon was originally published in 1934, and later included in Paul Reps and Nyogen Senzaki's popular anthology Zen Flesh, Zen Bones. Due to non-renewal it is currently in the public domain in the US (although other parts of Zen Flesh, Zen Bones are not)." source link

I was playing with CSS and Html and made a nice little web app.

Check out my project and read all 49 koans


Hyperlegible Typeface

I love this and will need it sooner than I expect.

"Atkinson Hyperlegible font is named after Braille Institute founder, Robert J. Atkinson.  What makes it different from traditional typography design is that it focuses on letterform distinction to increase character recognition, ultimately improving readability."

https://www.brailleinstitute.org/freefont

A Free Hyperlegible Typeface from the Braille Institute

Atkinson Hyperlegible is a free typeface developed by the Braille Institute and Applied Design Works that makes text more readab

Jason Kottkekottke.org

Hyperlegible Typeface


Get the most from Siri music

I'm terrible a playing music, this helps.

Hey Siri, Play Some Music: All the Music Commands (and more …)

How to play Music by Activity and Mood

Apple Music has a couple of not so obvious activities and moods, which you can use to specify what to play:

  • *Hey Siri play (some) music for *
  • *Hey Siri play music*

Here is a list of some *moods* we have tested, we’ve added the station they will trigger:

  • *Peaceful / Meditation / Meditate / Bedtime / Sleeping* -> station Meditation
  • *Happy / Cheerful / Whimsical* -> station Happy Music
  • *Wild / Party / Fun* -> station Partying
  • *Stimulating / Exciting / Motivate(d) / Waking Up / Upbeat* -> station Motivated Music
  • *Angry* -> station Angry music
  • *Calm / Sad / Blue / Somber* -> station sad music
  • *Intimate / Erotic / Baby Making* -> station Getting it on
  • *Mellow / Chill / Soothing* -> station chill music
  • *Love / Passion / Tender / Romance / Romantic* -> station Romantic and Love Music

Here we go with some *activities*, which we’ve tested (musically =):

  • *Seperate / Split(ing) / Break(ing) Up* -> station Breaking Up
  • *Exercise / Cardio / Work(ing) Out* -> station Working Out
  • *Dinner Party / Cooking / Entertaining* -> station Entertaining
  • *Dance / Dancing* -> station Dance
  • *Focus(ing) / Study(ing) / Concentrate / Concentration* -> station Focusing
  • *Family Time / Safe for Kids* -> station Family Time
  • *Family / Kids* -> station Disney

Nodemon for Docker

I just installed Nodemon in my development Docker container. Here are the details.

Game developers need a quick and easy server solution. Docker, nodejs, mysql, sqlite, socket.io are working great for me. This is part of my upcoming series on how to make it all work. Its way, WAY easier than you might think.


Use Prism for Syntax Highlighting in Ghost

Configure Ghost and Prism to provide code syntax highlighting for all popular formats including javascript, php, html, css, markdown and more.

Ghost is a great CMS and it's easy to add a code syntax highlighter such as Prism.

Versions

Ghost version 3.3
Prism version 1.21

Prism

There are two ways to use Prism: 1) download and serve from your website or 2) serve from a Content Delivery network (CDN). The CDN option is actually easier and better for your viewers. There is a chance that many sites use Prism and once your browser has it in its local cache it won't need to download it again, which makes it faster and uses less bandwidth. So, that's what you will learn about today.

Step 1 - Go to the Prism website and learn a little about it. Look at the Theme bubbles down the right-side of the page. Find a theme that you like and want to use on your Ghost powered blog. I use the "Okaidia" theme on this website. Also, notice that there are many, many language features supported. If you will always just use a few languages then you can hard code them into your setting and only use them. However, if like me there is no telling which language you will post about next then you should use the autoloader feature.

Take note of the latest Prism version. As of this writting I'm using version 1.21.0. You will want to use the most current version.

CDN

Step 2 - Find a CDN that hosts Prism. I chose cdnjs.com to serve the Prism files. It's free, easy to use and fast. I recommend you go to cdnjs.com and search for Prism. You will see that there are a lot of options. You don't need all of those, just the ones you are interested in.

Step 3 - There are 3 main parts of Prism you need to make this work. The first part is the CSS. To load this from cdnjs.com looks like this.

Part 1: Choose your theme:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.21.0/themes/prism-okaidia.min.css">

Link to Prism okaidia theme

Notice this version contains the word okaidia which means it has the color scheme for the Theme I like. You should search for the Theme that you chose in step 1.

Part 2: Find the core js file:

<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.21.0/components/prism-core.min.js"></script>

Link to Prism core library

It contains the core of the Prism library.

Part 3: Find the language modules you want to use, or find the autoloader version.

<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.21.0/plugins/autoloader/prism-autoloader.min.js"></script>

Link to Prism autoloader

These are the 3 minimum components needed to use Prism with Ghost.

Now that you have identified the 3 main components and their links to the CDN, it's time to put them into your Ghost blog.

Code Injection

Ghost makes this very easy to do with the Code injection feature on their admin page.

Step 4 - Go to your ghost admin page, it is defaulted to site.tld/ghost, and login with your admin account.

Click on the Code injection menu option on the left. You should see two main sections "Site Header" and "Site Footer".

Part 1 - Place the CSS link in the Site Header section. It should look something like this:

Site Header portion of Code injection

That's all there is, just copy and paste the above CSS link into the Site Header section.

Part 2 - The Site Footer works the same, just copy and paste the core link and the autoloader link. If you decided to go with language specific options this is where you would load them instead of the autoloader link.

Remember these links are loaded on every page of your blog even if you don't use them on that page, so keep it simple, small and fast.

Site Footer portion of Code injection

Configuration Complete

That's all there is to configuring Ghost to use Prism. The next portion will show you how to use them on your blog.

Step 1 - Create a new post in Ghost and press the + icon to add a new section to your page, and then immediately type ``` that's 3 back-tick special characters under the ~ symbol on the top left of your keyboard. They are not single quotes ' or double quotes ".

This puts Ghost into the code entry mode. You can copy and paste your code in here.

Step 2 - Notice on the right hand side of the code entry box there is a place for language. This is where you type in the language for this code snippet. Ghost has done some of the work for you. You don't have to prepend the language type with language- or lang- as talked about in the Prism documentation, just put in what you are working with. Such as: js, javascript, html, php, json, css, etc..

Sample html script with language type shown in top-right corner

That's it! You code snippets will now be syntax highlighted with Prism.

Further Reading

For more examples and tips on how to add line numbers and a copy-to-clipboard button check out this Ghost tutorial.

Examples

Here are a few examples to look at.

function createBoard(team) {

    let out = "";
    out += "<div class='text-center'>";
    for (col = 1; col <= 10; col++) {
        for (row = 1; row <= 10; row++) {
            let calcId = team + "-" + zeroPad(row, 2) + zeroPad(col, 2);
            let link = ` '${team}', ${row}, ${col}, '${calcId}'`;
            out += `  <a class='m-0 p-1 btn btn-dark' href="javascript:fire(${link});" role='button'>`
            out += "   <span class='title'>";
            out += "    <span id='" + calcId + "' class='badge badge-dark oi' data-glyph='target'>" + " " + "</span>";
            out += "   </span>";
            out += "  </a>";
        }
        out += " <br> ";
    }
    out += "</div>";

    $('#board-' + team).html(out);

}

Sample Javascript code

@import "ios.css";
/* @import "darkMode.css"; */
@import "toggleSwitch.css";

@font-face {
    font-family: Revamped;
    src: url("../font/Revamped.ttf") format('truetype');
}

/* get screen width based on device */
:root {
    /* desktop vars */
    --screen-w1: 500px;
    --screen-w2: 495px;
}

@media screen and (max-width: 500px) {
    :root {
        /* mobile vars */
        --screen-w1: 97vw;
        --screen-w2: 94vw;
    }
}

Sample CSS code

public function getGame($userName, $roomName, $gameToken)
    {

        //load game
        $this->game = $this->loadGame($gameToken);

        return $this->game;
    }

Sample PHP code

<!-- Main Nav Bar -->
        <div class="w3-top hide main">
            <div class="w3-bar w3-round-large z-nav-background z-width" xstyle="max-width:500px">
                <span class="">
                    <a onclick="showPanel('lobby')" class="w3-bar-item w3-round-large z-nav-text">Lobby</a>
                </span>

                <button onclick="showPanel('E-Space')" class="w3-button z-nav-text w3-border w3-border-blue w3-hover-black w3-small">E-Space</button>
                <button onclick="showPanel('F-Space')" class="w3-button z-nav-text w3-border w3-border-blue w3-hover-black w3-small">F-Space</button>

            </div>
        </div>

Sample HTML code

ALTER TABLE `activeUserTable`
  ADD PRIMARY KEY (`id`),
  ADD KEY `time_index` (`time`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `activeUserTable`
--
ALTER TABLE `activeUserTable`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
COMMIT;

Sample SQL code


Studio Ghibli 50 free stills

Studio Ghibli just announced they’ll be uploading 50 free stills from each of their movies: “feel free to use them as you wish, within the bounds of common sense”

Link to the original article


Discover Phaser - The Book

@photonstorm Thanks to @thomaspalef for this excellent resource. . Worth every penny.

Link to the original article


iOS is Boring

I’m a big Apple fan and I have lots of Apple products and the real problem is that iOS is boring. Tim Cook is known for efficiency and Jonathan Ive loves his basic looks, however, when combined they are boring! iOS used to have lots of little details that were exciting to find, but now they are hard to find, hard to discover, and boring when found. They need to let their developers have a little fun, stay in their human guidelines of course, but still have a little fun. Hardware optimization makes sense, but don’t over optimize the software. It can provide a path to fun.


The Anatomy of the Underwater Fiber Optic Cables That Connect the Internet

The Anatomy of the Underwater Fiber Optic Cables That Connect the Internet

Link to the original article


An Explanation for Why People Don’t Often See ‘B’ Batteries

An Explanation for Why People Don’t Often See ‘B’ Batteries

Link to the original article


The Internet of Things - Nuts & Volts Magazine - For The Electronics Hobbyist

Everything starts somewhere...

The Internet of Things - Nuts & Volts Magazine - For The Electronics Hobbyist

NUTS & VOLTS MAGAZINE (NOVEMBER2014)

NewImage

THE INTERNET OF THINGS By Bryan Bergeron    View Digital Edition  

» Skip to the Extras Since the birth of the Internet, there has been talk of total connectivity — between people, people and their possessions, and things to things. Up until recently, the reality has been that such ecosystems existed only in academic and corporate research centers. Today, the Internet of Things (IoT) is a practical reality in many settings.

Read the original artical at: The Internet of Things - Nuts & Volts Magazine - For The Electronics Hobbyist


The Joy of Tech comic... A gathering of robots!

The Joy of Tech comic... A gathering of robots!

NewImage

More info at: The Joy of Tech comic... A gathering of robots!


AI, Apple and Google — Benedict Evans

AI, Apple and Google — Benedict Evans

There are really two things going on here - you’re using voice to fill in a dialogue box for a query, and that dialogue box can run queries that might not have been possible before. Both of these are enabled by machine learning, but they’re built quite separately, and indeed the most interesting part is not the voice but the query. In fact, the important structural change behind being able to ask for ‘Pictures with dogs at the beach’ is not that the computer can find it but that the computer has worked out, itself, how to find it. You give it a million pictures labelled ‘this has a dog in it’ and a million labelled ‘this doesn’t have a dog’ and it works out how to work out what a dog looks like. Now, try that with ‘customers in this data set who were about to churn’, or ‘this network had a security breach’, or ‘stories that people read and shared a lot’. Then try it without labels ('unsupervised' rather than 'supervised' learning). 

Today you would spend hours or weeks in data analysis tools looking for the right criteria to find these, and you’d need people doing that work - sorting and resorting that Excel table and eyeballing for the weird result, metaphorically speaking, but with a million rows and a thousand columns.  Machine learning offers the promise that a lot of very large and very boring analyses of data can be automated - not just running the search, but working out what the search should be to find the result you want. 

More info at: AI, Apple and Google — Benedict Evans


‘We Hardly Understand Anything’: Rodney Brooks On Artificial Intelligence | Radio Boston

‘We Hardly Understand Anything’: Rodney Brooks On Artificial Intelligence | Radio Boston

If you’re going to talk about robots, there’s no better person to talk with than Rodney Brooks. He’s the former director of MIT’s Computer Science and Artificial Intelligence Laboratory. He’s also co-founder of two companies: iRobot, maker of the Roomba, and now Rethink Robotics.

He’s spent his entire life thinking about robots and artificial intelligence. He sat down with us to talk how he built his first machine, what technology we have yet to tackle and why Stephen Hawking and Elon Musk are wrong to fear the future of robots.

More info at: ‘We Hardly Understand Anything’: Rodney Brooks On Artificial Intelligence | Radio Boston


Robot Surgeons Are Taking Over the Operating Room - IEEE Spectrum

Robot Surgeons Are Taking Over the Operating Room - IEEE Spectrum

Advanced surgical robots are already helping doctors perform operations with previously unimaginable precision. But fairly soon, doctors may be able to hand the scalpel over entirely—at least for simple, repetitive procedures—freeing up human surgeons’ valuable time for more complex work.

Some of the latest surgical robots can already plan and execute simple surgical tasks entirely on their own, select optimal approaches and tools, and even use deep learning to observe and replicate new procedures. So we’ve rounded up a few of the coolest robo-surgeons just for you.

More info at: Robot Surgeons Are Taking Over the Operating Room - IEEE Spectrum


Researchers want robots to feel pain | The Verge

Researchers want robots to feel pain | The Verge

Researchers in Germany are developing a way for robots to feel pain, in the hopes that doing so will enable them to better protect humans. The researchers, from Leibniz University of Hannover, are working on an "artificial robot nervous system to teach robots how to feel pain," IEEE Spectrum reports, and presented their project at a robotics and automation conference in Sweden last week. Under the system, robots would identify pain and quickly respond to avoid further damage to their parts.

More info at: Researchers want robots to feel pain | The Verge