More Project Euler code – also Github

Hi everyone! Haven’t had a chance to update lately but I wanted to share this

I’ve been working more on Project Euler, and I published my code on Github to simplify the update process. If you want to follow my progress or just see what I’m up to you can always have an up-to-date record there! I’ll of course still be blogging here about things that interest me. I may also be switching content providers soon to avoid ads on my site ruining your experience and give me some extra flexibility.

Anyway, here’s the URL for my github repo

When I have more free time I’ll update you on my media server setup, coming soon!

Advertisements

More Project Euler madness

Finished problem 3 of Project Euler (woo!)

My solution in python is up here

The problem is here

Notable about this problem was how it required me to approach the problem, and realizing that the answer ties into the concept of Big O notation. If my prime number generator or checker were not correct (which they very much were at first), then all of a sudden you’re creating 40GB of lists and your OS shuts the thread down before your computer overheats, or shits itself.

I like how you can create a custom function to find exactly what you’re looking for, if you parse the options correctly.

Programming sometimes can be sloppy, but other times you need to be elegant and precise to achieve the results you want, all of course depending on the complexity of the problem you’re tackling.

Crossing off the list of things that didn’t work:

  • using the filter list method and xrange to iterate over another xrange list of factors and pull only the prime ones
  • checking each number in sequence to see if it was a prime factor (good lord no)
  • wailing and gnashing of teeth
  • trying to do everything myself and not learning from resources available to me.
  • banging my head against the desk

Working on THIS ONE next if you’re interested in following along with me! And as always, leave any comments or questions below!

btrfs update

I was planning to finish this project a few days ago, but as things go, I got distracted, life called, etc.

So here I am. I finally got things working, and quite admirably I think.

I’m using the same rsync command I used in the previous post to copy my content back over to my media drive.

I ran into a small snag which the kind folks at the Arch Forums were nice enough to help me with.

I ended up having to edit my permissions to allow me to edit the drive, which was by default owned by root. Once I added it to the wheel group and ran a chown command I was able to make directories and make files.

So mainly this is to report that all’s well that ends well. I’m transferring my content back over now!

Btrfs and rsync

Minor update for you all

My desktop rig has a 2tb hdd in it that I use for media storage to serve to my network. The issue I am running into more and more is the NTFS file system installed on it by Windows (back when I still used that). Now that I’ve switched to Linux there are some neat alternatives out there, like btrfs.

So I’m giving it a shot.

Since I’m running Arch Linux, and even if you don’t, the Arch wiki is incredibly helpful. Seriously, go check it out. I’ll wait.

Pretty cool, yeah?

I’m currently running this backup job with rsync to clone my directory structure into an ext4 file system, for increased reliability and speed. This is backing up to a portable 1tb external drive I have laying around. After that’s done I’m going to wipe my NTFS drive and start from scratch with either ZFS or btrfs depending on support and availability, I’m still exploring my options there. Then I’ll copy the data back over and enjoy better reliability and speed, while also having protection from bit rot!

The process to do that was actually dead simple. First I used this guide to refresh myself on some of the rsync commands.

I had to make a mount point for my backup drive.

    $ sudo mkdir -p /dev/backupdrive

Then format the drive to ext4

    $ sudo mkfs.ext4 /dev/sdg

And Mounted it and made sure it stays mounted by adding it to my /etc/fstab file.

    $ sudo mount -t ext4 /dev/sdg /media/backupdrive

Then I ran this command:

    $ sudo rsync -r -z –complete –dryrun /media/hdd1/ /media/backupdrive/ > testrun.txt

$ less testrun.txt

to get a sense for the output of the command I’m about to run. With a backup job like this it’s important to do a dry run first so you don’t accidentally overlook something very important and render your data unreadable.

Then I removed the –dryrun option and let it go.

totally legit downloads, guys

Here it is copying the files over. Of note is the -z option which compresses the files before sending them. Since the data is all being transferred locally I probably could have skipped this, but I am moving a lot of large files and wanted to ensure they copy as fast as possible over the USB 2.0 interface. And given this machine has the processing power to do it, it’s definitely not hurting anything. Even though a lot of them are already compressed movie files and ISO files,

Running it this way also acts as a checksum method, if the integrity of the archived file is damaged in transit, it won’t unpack to become the same file and rsync can then correct the error.

More updates to come! Stay tuned! Next time I’ll be showing you the process of putting everything back!

Raspberry Pi

I picked up a Raspberry Pi at the internet’s collective suggestion, and I’ve been hacking away on it happily.

Currently setting up my desktop machine to serve as a seedbox (with OpenVPN on Arch and TransmissionBT) and content server for the Pi.

It’s worth mentioning at this point that I don’t think any of this would be nearly as simple if I hadn’t started with Arch Linux, the wiki alone is an amazing resource but more importantly the system itself is as stripped down as you can realistically get. So if I want something done, I have to do it, it hasn’t been done (god-knows-how) by someone else. That may sound like a drag but on a server system it’s very beneficial to know exactly what parts are going into your setup, as using mismatched versions of software can introduce bugs that can be extremely hard to replicate and find.

The Pi itself is running a slimmed down and modified distribution of what appears to be Debian-testing, called Xbian. It’s fast, lightweight, stable, and fluid. No real complaints there, not much to write home about either. It’s debian with XBMC layered on it. The logitech keyboard I got had some issues with default media hotkeys but I worked them out with sharpies and some googling.

Until I get my media served up the right way I’m relying on Plex to actually serve the content to the Pi, but hoping to switch to an NFS setup for faster streaming and more flexibility. I don’t want to pay for a Plex Pass when I know I can do all those features myself, and learn a lot in the process 🙂

Another project in the pipeline I’ve been slowly working my way towards has been a full LED glow jacket/suit. I want to create a matched set of LED suits to take to Burning Man. I want them all wireless, currently planning to do that with a Particle board, and use an RPi and battery in a backpack to manage the network. Hopefully, I’ll be able to use all the available suits to create a seamless video network and then play visualizer effects over the top of them. All goes well I may even put them into production for sale.

Stay tuned for more updates folks

Troy

Fixing OSX Error “Cannot verify installer”

Found this article which helped me with a side project I’m working on, needed to reinstall OSX on a white 2009 Macbook and ran into this error which would not go away. Even reimaged the install media on a different flash drive and replaced the RAM before turning to the internet for help. Turns out the answer was as simple as setting the date. D’oh!

http://osxdaily.com/2015/01/19/fix-os-x-install-errors-cant-be-verified-error-occurred-preparing-mac/

S-Expressions and Lisp

I’ve been reading this document about Lisp programming and S-Expressions. It goes over the fundamentals of S-Expressions which is essential reading for any programmer. Take a look: http://www-formal.stanford.edu/jmc/recursive.pdf

Railsbricks Setup

Today I found out about railsbricks. It’s a ruby gem that does the complicated task of setting up trivial functionality for your site like user logins, database configuration, admin pages, and other things like that. Extremely helpful in that endeavor was this blog post, which helped me parse some of the options I was presented with.

I did run into one problem that was not covered in his post, however. It seems the team that makes Postgresql keep moving around their psql.conf file and that causes your application to flip out without some extra configuration. As this was a test application, I went with SQLite3 for my database for simplicity’s sake.

Overall, though, railsbricks is another extremely helpful tool in creating rails apps quickly and conveniently.

Fiverr

I’ve launched a page on the platform Fiverr offering virus removal services. Here’s a link to my page:

https://www.fiverr.com/troyleak

Please recommend me if any of your friends or family have virus or spyware needs.

Also new today, I tied this blog to the domain troyleak.com, which should be a little more professional. So update your bookmarks, all 3 of you that read this.