Shop

My New Shop
MTS Creations

Subscribe to My YouTube Channel

Friday, September 13, 2013

Angry Birds Birthday Party!

I thought I would try to document a little bit of the build for the Angry Birds build that I did for my son's birthday.



The pigs are simple milk cartons that we spray painted green (florescent because the cartons were white), then we hot glued the googly eyes on and drew nostrils with a sharpie on the lids.
Milk Cartons - free from neighbors (thanks)
Googly Eyes - $1.50 Wallyworld
Sharpie - already had
Florescent Paint - $3.76 Big Box Store



The Giant Sling Shot was a design that I came up with just from wood that I had around.  I wanted something that wouldn't bend, warp, or flex when it was pulled on.  I knew it had to be mounted so I figured I would just dig a hole and plant it.
The wood is the pre-treated 4x4 posts from the big box stores then cut into three pieces.  The main post is cut at two 45 degree angles that come to a point in the middle at the top.  Then the two Y arms are each cut straight then mitered where they meet in the middle above the point of the main post.  This is so that they will always be in contact with each other at every point of intersection.
I then used two 90 degree L brackets on the outside where all three pieces meet.  I then used another 90 degree face bracket in between the Y to support the two Y arms.  I then put two 45 degree brackets where the main post meets each of the Y arms on the outside edges.

The sling was built from two bungee cords that had to be easy enough for the kids to pull.  I didn't want to permanently attach them to the Y arms so I just notched the Y arms with a groove on each corner of the posts to provide a track for the bungee cords.  I then wrapped the bungee around itself and zip tied it as a preventative measure in case it got pulled too strongly.

The other end of the bungees are then looped through and zip tied to the 4 tarp clips which are then attached to the shop towel.

Everything came from the big box store
4x4 posts - 14.75
90 degree L plates - $4.20 x 2
Bungee cords - $3.48
Tarp clips - $4.99
Shop Towel - already had
Zip ties - already had



The boxes are just left over boxes from everything we have bought online or a new dishwasher.

Laptop startup script for a Home Hosted Domain

I run a server at my house, setup with a Dynamic IP address.  I access this server all the time and I hated when I was home that my "hosts" file was not right and I would have to update it when I was at home and then change it when I was at work.
I'm sure there is an easier way to solve this problem but I couldn't figure it out.

To solve this problem I created a windows startup script that will change out my hosts file depending on my IP address (home versus work).

<code>
@echo off
:start
IPCONFIG |FIND "IPv4" > c:\TEMPIP.txt
FOR /F "tokens=2 delims=:" %%a in (c:\TEMPIP.txt) do (
    if defined IP (
        echo IP is defined %%a
        call :process %%a
    ) else (
        echo Setting IP to %%a
        set IP=%%a
        call :process %%a
    )
)

:process
del c:\TEMPIP.txt
set IP=%~1
echo Your Internal IP Address should be %IP%
IF not x%IP:10.0.3.=%==x%IP% (
    call :home
    GOTO :EOF
) ELSE (
    call :work
    GOTO :EOF
)
pause
GOTO :EOF;

:work
IF exist "C:\Windows\System32\drivers\etc\hosts_work" (
    XCOPY /Y "C:\Windows\System32\drivers\etc\_work" "C:\Windows\System32\drivers\etc\hosts"
    echo "You are at WORK %IP%"
    move "C:\Windows\System32\drivers\etc\hosts_work" "C:\Windows\System32\drivers\etc\hosts_home"
) ELSE (
    echo "Sorry, you're still at WORK!"
)
GOTO :EOF;

:home
IF exist "C:\Windows\System32\drivers\etc\hosts_home" (
    XCOPY /Y "C:\Windows\System32\drivers\etc\_home" "C:\Windows\System32\drivers\etc\hosts"
    echo "You are at HOME %IP%"
    move "C:\Windows\System32\drivers\etc\hosts_home" "C:\Windows\System32\drivers\etc\hosts_work"
) ELSE (
    echo "WOW! Did you stay home?"
)
GOTO :EOF;

:EOF
set /p recheck=Recheck Connection (y/n)?:
if /i %recheck%==y goto start
if /i %recheck%==n goto goaway

:goaway
net stop ssh_tunnel
net start ssh_tunnel
echo "See you next time!"
pause
exit
</code>

This requires you to have two files inside of your "C:\Windows\System32\drivers\etc\" called "_home" and "_work".

_home contains something like this:
<code>
## - HOME HOSTS FILE
10.0.3.10    www.domain.com domain.com
</code>

_work would contain something like this: (note the line is commented out. Also this would be if you had some other IP address you needed it set to if your nameserver isn't working.)
<code>
## - WORK HOSTS FILE
#123.123.123.123    www.domain.com domain.com
</code>

There is a third file that I use to decide if I need to copy the file over or not and it just changes every time (hosts_work to hosts_home and vice versa)

The last thing you will notice in the script under the :goaway section is  the following lines:
<code>
:goaway
net stop ssh_tunnel
net start ssh_tunnel
</code>

This will start and stop a ssh_tunnel that I have configured to use plink to forward specific local ports to the server so that I can stream my music to my laptop.  (all of this is due to a very strict VPN that is so strict that they block almost every port.

Monday, June 10, 2013

MySQL InnoDB corruption

http://chepri.com/mysql-innodb-corruption-and-recovery/

A query for finding all of your InnoDB tables.

SELECT table_schema, table_name
FROM INFORMATION_SCHEMA.TABLES
WHERE engine = 'innodb';

Steps to get it back up.

1. Stop mysqld.
2. Backup /var/lib/mysql/ib*
3. Add the following line into /etc/my.cnf

innodb_force_recovery = 4

4. Restart mysqld.
5. Dump all tables:# mysqldump -A > dump.sql
6. Drop all databases which need recovery.
7. Stop mysqld.
8. Remove /var/lib/mysql/ib*
9. Comment out innodb_force_recovery in /etc/my.cnf
10. Restart mysqld. Look at mysql error log. By default it should be /var/lib/mysql/server/hostname.com.err to see how it creates new ib* files.
11. Restore databases from the dump:mysql < dump.sql


Wednesday, May 29, 2013

Dynamic Hosts File for Work/Home

I run a server at my house and needed a better way to switch my hosts file for when I'm at home or when I'm anywhere else with my laptop (mainly work).

So I pieced this script together from multiple other scripts that I found online.
First, it checks my IPCONFIG for IPv4 and then grabs the first one and checks it against my home IP schema. Depending on what it finds it XCOPYs the corresponding _work/_home hosts file to the hosts file.

In the hosts file I just simply have the host names for my domains listed to my home servers internal IP address.

I add this script to my "Startup" folder so it runs every time that I start my laptop.

@echo off
IPCONFIG |FIND "IPv4" > c:\TEMPIP.txt
FOR /F "tokens=2 delims=:" %%a in (c:\TEMPIP.txt) do (
    if defined IP (
        echo "IP is defined %%a"
        exit /b 9993
    ) else (
        set IP=%%a
        call :process "%%a"
    )
)

:process
del c:\TEMPIP.txt
set IP=%IP:~1%
echo Your Internal IP Address should be "%IP%"
IF not x%IP:10.0.25.=%==x%IP% (
    call :home
    GOTO :EOF
) ELSE (
    call :work
    GOTO :EOF
)
pause
GOTO :EOF;

:work
IF exist "C:\Windows\System32\drivers\etc\hosts_work" (
    XCOPY /Y "C:\Windows\System32\drivers\etc\_work" "C:\Windows\System32\drivers\etc\hosts"
    echo "You are at WORK %IP%"
    move "C:\Windows\System32\drivers\etc\hosts_work" "C:\Windows\System32\drivers\etc\hosts_home"
) ELSE (
    echo "Sorry, you're still at WORK!"
)
pause
GOTO :EOF;

:home
IF exist "C:\Windows\System32\drivers\etc\hosts_home" (
    XCOPY /Y "C:\Windows\System32\drivers\etc\_home" "C:\Windows\System32\drivers\etc\hosts"
    echo "You are at HOME %IP%"
    move "C:\Windows\System32\drivers\etc\hosts_home" "C:\Windows\System32\drivers\etc\hosts_work"
) ELSE (
    echo "WOW! Did you stay home?"
)
pause
GOTO :EOF;

:EOF

Monday, January 21, 2013

Linux Busybox prompt after restart

If you find yourself with a possible missing "/".

Solution:

1. Boot from an Ubuntu Live CD

2. Open Terminal

3. Type: sudo fdisk -l then press ENTER
Make note of the "Boot" indicator "*" for the correct device.

Device Boot Start End Blocks Id System
/dev/sda1 * 1 30238 242886703+ 83 Linux
/dev/sda2 30239 30401 1309297+ 5 Extended
/dev/sda5 30239 30401 1309266 82 Linux swap / Solaris


4. Type: sudo fsck /dev/sda1 then press ENTER

5. Restart the system and boot normally.