Thursday, April 3, 2014

RaspberryPi OwnCloud Setup

  1. Install Raspbian on the SD card
  2. Setup Raspbian as desired
  3. apt-get update
  4. apt-get upgrade
  5. apt-get install mysql-server
  6. ( link )
    wget http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_7.0/Release.key
  7. apt-key add - < Release.key
  8. echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_7.0/ /' >> /etc/apt/sources.list.d/owncloud.list
  9. apt-get update
  10. apt-get install owncloud
  11. http://127.0.0.1/owncloud

Thursday, March 13, 2014

Oracle Select from Provided Data

I needed a quick way to select distinct values from a list of items that I had.

SELECT distinct column_value ip FROM table(sys.dbms_debug_vc2coll('Some String Value', 'Some Other String Value', 'And Yet Something Else'))

Wednesday, March 5, 2014

Dynamic IP Web Hosting Setup

Lets say you have a computer at your house that you want to connect to the internet and serve up some files for people to see.

Your internet service provider (ISP) charges you a large amount of money for internet service on a monthly basis and they still give you a dynamic IP address.  I guess I could starve my family and pay for a static IP address, no, I'm too smart to throw them more money.

I could just find a dynamic DNS service that would give me some randomSubdomain.some_already_defined_catchy_domain_name.com.  Then I just have to remember that and give that out to who ever I want to share these files with.

Instead, I could use the domains that I want and point my DNS entries to my dynamic IP address. Oh crap, what if my ISP decides to give me a new IP address?  Argh, then I have to log into my Domain Registrar and update my DNS entries to the new IP address.

Thanks to free DNS services such as zoneedit.com or dnsever.com or plenty of others you can use their servers to maintain your DNS entries for "free". I know that zoneedit and dnsever both offer "free" DNS service for 1 or 2 domains.

So now comes the question about when my home's dynamic IP address changes.
These DNS services provide you a way in which you can update your DNS entries via simple scripts/web addresses that will update your entries for you.

----ZoneEdit----
wget -O - --http-user=<YourZoneEditUserName> --http-passwd=<YourZoneEditPassword> 'https://dynamic.zoneedit.com/auth/dynamic.html?host=<YourZoneEditHostName.com>&zones=<YourZoneEditZonesName.com>'
----DNSEver----
wget -O - --http-user=<YourDNSEverUserName> --http-passwd=<YourDNSEverPassword> 'http://dyna.dnsever.com/update.php?host[<YourDNSEverHostName.com>]&host[<AnyOtherOfYourDNSEverHostNames.com>]'
These two are for use in a system with wget installed, either Linux or Windows with Cygwin installed.  Then you just have to figure out when your dynamic IP address from your ISP changes and then issue these commands and they will updated the DNS entries to point to the new IP address that your service provider just gave you.

Now when you want to get back to your house you just use your own domain.

The other thing you can add to this is that when you verify that your IP address has changed that your system will email you the new IP address so that you can know before as soon as your ISP changes things up.

If you have any questions/comments please let me know.  This is post is more for a friend who is tired of paying for hosting!

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