garage sensor rpi

Written by klee on October 31st, 2020

I added a project to github for a “scare-a-tron”, which is what I call a simple device which basically uses typical garage door sensors to detect someone walking up to a porch, then plays an mp3 file. In my case, it plays a cougar roar sound at a loud volume.

The project can be found at https://github.com/kalee/garage_sensor_rpi

Happy Halloween!

 

More coding challenges

Written by klee on October 31st, 2020

https://emkc.org/contests has weekly contests that are fantastic. If you have an interest in learning a language, or having fun solving problems, give these weekly challenges a try. A new challenge starts each week at noon central time each Sunday. The contest lasts until Noon central time the following Wednesday.

There is an active discord group found at ​https://discord.gg/engineerman Take a look and see if it is a good fit if you are a developer.

 

Coding Challenges

Written by klee on July 22nd, 2020

There are two challenges that really stand out as my favorites right now. There is the https://www.adventofcode.com site. This challenge occurs once a year from Dec 1st – Dec 25th. There are two puzzles a day, except possibly only one on the last day as a reward. It depends on the year. These have been going on since 2015, and you can go back and solve previous years problems for practice.

The Advent of Code challenges tend to have a lot of searching and depending on the year, themes that are used for many of the problems. For example, in 2019, there was the them of the intcode computer to run software based on a predefined message that each user gets as a customer data input. There tends to be a lot of Breadth-First-Search and Depth-First-Search algorithms used in the problems. Brush up on those in whatever language you choose to use.

The second challenge I have really grown to like is https://www.projecteuler.net. If the name doesn’t give it away, these are more math oriented problems. These are really fun, and the first fifty or so problems are not too difficult. Most answers and hints for the first 100 problems can be found online, but it is well worth trying to work these out yourself. So far, I’ve spent three days on a really simple problem. I did look at a solution, but didn’t like it. I finally found the problem. I had to re-read the problem to find that I was not counting correctly. It is the little things that get you.

The language you pick really doesn’t matter. I’d pick one that you want to get better at that you will continue to use, but that is just me. These puzzles are great fun!

 

Simple Update to Mouse Move Program

Written by klee on December 9th, 2018

While one of my sons was visiting from college, I showed him the mouse move program. His question was why move the mouse pointer across the screen? Why not just move it one pixel… You wouldn’t even notice the change?

Sure enough, he was right. I made the update, and it is on the download page – KL.java.

 

Updated MouseMove Program

Written by klee on November 3rd, 2018

Don’t move the mouse if mouse has moved in last 60 seconds.

import java.awt.*;
import java.util.*;

public class KL {
	private int x=0;
	private int y=0;
	public static void main(String[] args) throws Exception {
		KL kl = new KL();
		kl.setXY();
		Robot hal = new Robot();
		Random random = new Random();
		while(true) {
			int storedX = kl.getX();
			int storedY = kl.getY();
			hal.delay(1000*60);
			kl.setXY();
			if ( (storedX==kl.getX()) && (storedY==kl.getY()) ) {
				int x = java.lang.Math.abs(random.nextInt() % 640);
				int y = java.lang.Math.abs(random.nextInt() % 480);
				System.out.println("(x,y) = " + x + " , " + y);
				hal.mouseMove(x,y);
				kl.setXY();
			} else {
				System.out.println("Mouse already moved, current position: (x,y) = " + kl.getX() + " , " + kl.getY());
			}	
		}
	}
	
	public void setXY() {
		PointerInfo a = MouseInfo.getPointerInfo();
		Point b = a.getLocation();
		int x = (int) b.getX();
		int y = (int) b.getY();
		setX(x);
		setY(y);
	}

	public void setX(int xval) {
		x = xval;
	}

	public void setY(int yval) {
		y = yval;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}
}
 

Breathing new life into an old blog

Written by klee on August 23rd, 2018

I finally got around to replacing a power supply in the old 386 computer that was running my blog. I exported the database, and backed up the files. I setup a new web server/database/wordpress blog on a Raspberry Pi. We’ll see how well this holds up and works. The older posts appear to be still available. I was surprised at how easy it was to complete. Now back to work…

 

AllowOverride None

Written by klee on September 10th, 2016

AllowOverride None is evil. It took several hours to figure out why permalinks were not working. Hidden, many layers deep, in an obscure Directory block was this command. Once I removed it, all of the permalinks worked. Glad that is over!

 

I’m back

Written by klee on August 6th, 2016

I was having issues with my ISP. Apparently, my family has been streaming Netflix, and the gateway can’t handle the load. I have upgraded the gateway, and now use an Ubiquiti EdgeRouter to handle the “load”. Sorry for the downtime.

 

Simple password generator

Written by klee on June 3rd, 2016
#!/usr/bin/perl
use strict;
use warnings;

use App::Genpass;

my $generator = App::Genpass->new(
                number    => 5,
                readable  => 0,
                special   => 1,
                specials  =>  [ '!', '#', '$' ],
                verify    => 1,
                length => 14,
);

my @list = $generator->generate();

foreach ( @list ) {
    print "$_\n";
}

Sample Results:
$ perl genpass.pl
QVTEZSe5Iz#wTB
OOKd#fahdwm35Q
UuoJkdxF8#sbD$
Yn!UBqwC0GkW4d
052Z9$NwUf1LCT

 

The Mouse Move Program

Written by klee on May 29th, 2016

I once wrote a piece of code to prove that you didn’t actually have to be at your computer for your IM to state that you are active. This has since gone on to be a frequently talked about piece of code. Here it is 🙂

import java.awt.*;
import java.util.*;

public class MouseMove {
  public static void main(String[] args) throws Exception{
    Robot mm = new Robot();
    Random random = new Random();
    while(true) {
      mm.delay(1000*60);
      int x = java.lang.Math.abs(random.nextInt() % 640);
      int y = java.lang.Math.abs(random.nextInt() % 480);
      mm.mouseMove(x,y);
    }
  }
}