Learning to learn code the way that fits you.

I’m still a derp, but much less of a derp about programming that I was. While I started trying to learn things serially, filling out a firm grounding in each area before proceeding to the next in an order determined by the author of the book I was reading, I’ve taken to reading and trying out whatever I see that takes my fancy, occasionally backtracking to where I started, to build my knowledge along a branching-tree-like fashion.

While regex is largely unrelated to what I’m working on now I began reading up on how it works with C# and was immediately confused as to why an instance was being created for something that is going to do one simple task, after several hours of continued reading spaced out over a few weeks, I came across MSDN’s Best Practices for Regular Expressions which highlights that, as:

  1. Each time the regex engine is invoked, it goes through all the creation gubbins, converts the regular expression to binary that can be compared to the string you’re running it against.
  2. If you were to repeatedly evoke this, say,  in a loop, you would be wasting oh so much performance as it goes through this for each input string.

In short, something that seems to the user to be simple (Not that being able to count every sentence in a book in a few seconds is easy.) have a considerable overhead in comparison to their useful work.

Aaand then I learned of ways to make things much more efficient, broken down into Static Instance and Pre-compiled DLL.

As the regex needs to load itself into memory before working but it has no variables in it’s class, you can create a static instance and each time it is called, it will be as unchanged as when it was first created. This means that, after the first time the instance is called, it can be re-used without any of the initial overhead.

Secondarily, if you have a regex you know you will be using a lot, you can shift it’s creation to pre-compiled binary code in DLL form, so the overhead is no longer wasted each time the program runs, but has already been created and is loaded into memory in a form that is ready to run straight away.

So, while regex doesn’t relate to my project, it is a good example of when a static instance of a fuction is actually useful and opens me up to a small area of the possibilities of compiling functions as binary ahead of time, which wouldn’t make much sense for most instances. Most of all, I was engaged with what I learned.

Now all I have to do is study for a year, only to come back, read this, and have no idea what I was talking about. That’s the learning process, people.

Posted in: Uncategorized by Fred No Comments

Hauwei U8220: Adventures in Android.

As smartphone hardware is so similar from phone to phone, Android OS is so freely modifiable, and smartphone companies insist on loading their phones with useless bloat in a frantic attempt to differentiate an increasingly comoditiezed product, it is possible to take quite a cheap phone and turn it into something rather amazing. Made all the easier by the fact that others are willing to do all the complicated stuff and package it up for you.

A couple of months ago, my friend and neighbour Andrew, of 303s.com fame, gave me a Hauwei U8220 (More commonly re-branded as a T-Mobile Pulse, among other names.) on account of it being admittedly a bit on the slow side.

After about three months, a new microSD card and some extensive investigation into different firmware implementations, and I have an Android phone that runs light and smooth.

I’m not going to go in-depth with instructions, as most of the places you can download firmware will also provide the instructions for implementing them.

Major modifications include:

  • FTB-Mod firmware from the guys over at Modaco’s T-Mobile Pulse forum.
    • While not running the most up to date Android kernel, it is smooth and stable.
  • Class 10 (Actually 8.) 16GB microSD card.
    • Tested with H2TestW 1.4 and came out as being 8MB/s write with 15MB/s read.
      • As 6MB/s is the minimum, it works alight.
    • Pretty cheap from Ebay, can get an official Samsung 8GB class 10 for about the same.

Preparing the MicroSD card.

This is the first thing you’ll want to set up. You will have a 32MB Swap partition (To free up RAM.), a 256MB EXT3 partition (To store all your apps.)  and the rest in a FAT32 partition for all your usual pictures and music.
In order to make this happen, get an Ubuntu or Gparted disc (Or use YUMI to put the ISO on a flash drive.) and partition your card with GParted. A good practice is to put the swap partition at the far beginning or far end, so it doesn’t get in the way if you later want to move things around.

Downloading and installing firmware.

Once you have your SD card set up, plug it into your computer via an adapter or the phone itself and download the firmware file (Or do it directly from the phone, with the handy QR code on the right.). I am assuming you have already read one of the upteen rooting and installing Clockwork how-tos littered across the internet.

Warning: Once you have installed the firmware and set up swap and Apps2SD, never use the in-built USB mounting program as it will unmount all three partitions from the phone. Ways to get around this later.
Install the firmware using the instructions from the FTB thread.
I would also reccomend using “a2sd zipalign”. I’ve found “a2sd lowmem-ultimate” helps.
Congratulations, you now have a nice, minimal installation, on top of which you can install any number of applications as they all go the the SD card’s EXT3 partition.

App it up!

While I have gone through and installed apps by the dozen in the past, over time, and with re-installing your firmware and having to reinstall everything again, you’ll find what you like and what you don’t really use. Some U8220 specific apps I would reccomend, however, are:
  • Launcher Pro: The fastest, lightest home-screen replacement around. No useless 3D transition effects.
  • SetCPU*: The FTB mod kernel can be pushed up to 690MHz but also setting the CPU to 122-320MHz when the screen is off saves significant battery.
  • Adfree Android: Removes adverts by way of the hosts file.
  • SD Speed Increase: Increases the SD cache which helps things load faster and solves a problem I was having with the music player skipping.
  • Multi Mount SD Card*: Allows you to mount to SD card to your computer without preventing the phone from reading it. Speeds will be slower, but it’s safer.
  • VM Heap Tool: Setting VM Heap size to 32M seems to help.
  • Wifi Reassociate: Great little program that periodically pings your access point and reconnects if it can’t get through (Phone Wifi can be suspect at times.). Not so stable, thinking of trying a re-write.
With that done, go ahead and enjoy your android.
Posted in: Uncategorized by Fred No Comments

The Blimp project

For the longest time, bittorent has been largely the domain of geeks the internet over yet, despite it’s incredible usefulness of being able to send files without the need for expensive servers, it’s overly technical nature of torrent files, clients, upload ratios and abillity to hose a connection if not properly managed leave it’s best utilization out of the reach of most.

The Blimp’s aim is to take existing technology and make it far more accessible by taking care of problems, both in terms of utilization and management, making itself as invisible as something like Flash or HTTPS.

Currently looking at Webkit and Libtorrent for candidates to build from, but I’ve only got a bit of C# experience, so it’s going to be a while to re/learn, in which time, I thought I’d get some feedback on the idea. If someone wants to take this over, you’d be doing great work (And I got vidjagaems I’d rather be making.).

First Phase: Prototype/Proof-of-concept.

My first idea of a way to better utilize bittorent was by making a deamon, instead of a client, that any program on the computer could ask to fetch files. A good showcase for this would be by rendering the following code, consisting of HTML5 video tags and Magnet links (Expanded to make it more readable.).

<video width="1024" height="720" controls="controls">
  <source src="
magnet:?xt=urn:btih:54dec3e7b1169fad5587d5a9e30fafa92097eab7
&dn=Big+Buck+Bunny+%282008%29+BRRip+720p+x264+-MitZep
&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80
&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80
&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
" type="video/mp4" />
  Your browser does not support the video tag.
</video>

Side note: For those of you unfamiliar with Magnet Links if you click this version of the above Magnet URI, it will download the link through your torrent client of choice.

Without any complication on the part of the user, when the browser loads the page, it immediately sends the relavent info onto The Blimp which looks up peers ready for the video being clicked. If a click comes, it downloads the file, grabbing chunks in order, and passing them back to the browser to render.

As part of the prototype phase, making this work with with the audio tag and anchor tag (E.g. Clicking to download an Ubuntu ISO.) would be useful to give an example the final project’s uses. Though just having a video playing from no fixed source would be a great achievement.

Second Phase: Core features.

A feature I’ve nicknamed Fleeting, Blimp deamons on the same local network can be told to work as one. Either by having a single computer (E.g. A large desktop or server with CAT5 connection.) do all dealings with the internet at large or a redundant cluster of deamons which, when they realise one of their number has gone offline, will download and upload chunks on behalf of their counterparts, making it easier to utilise upload bandwidth at times of day not usually busy.

In addition to programs being able to ask for files, they can also place a temporary restriction on all deamons on the network, for instance when a Skype call comes in or you connect to a game server, downloads would be reduced to half and uploads could be temporarily stopped (Some of us only get 50kB/s up.) to make way for more latency crucial tasks.

Enough for now.

I’ll stop there before I run out of steam. A high quality user interface (Those bittorrent links are a pain to copy.) could be provided by some kind of extension and, though I’ll probably save it for another project, once storage has been separated from location, some use of authentication technology could be used to make entire websites distributable without any central location.

Posted in: Uncategorized by Fred No Comments

Network printing from Win7 to XP.

You’ve probably wound up on this site after tearing your hair out for a bare minimum of half an hour trying to get a printer, attached to a Windows XP computer, to print a document sent to it by a Windows 7 computer.

First of all, can you see the printer?

Specifically, can you go via, network places (My Computer –> Network), locate the computer the printer is connected to and open the computer’s shared folders and printers in order to have the printer icon with the little pipe under it appear on your screen?

A common problem for this is having different workgroup names:

  • In XP, right click My Computer and go to properties at the bottom of the right-click menu then over to the second panel (Who’s name I can’t remember, please post in the comments.) and look for it in the lower half.
  • In Windows 7, it’s in the System Properties window found by opening My Computer and clicking the “System Properties” link below the address bar.
  • If they don’t match, you can find the relative buttons pretty easily.

Once you get those matched up, you should be able to see each other, if not, post a comment and I’ll get back to you.

I am assuming you can now see the printer over the network, but trying to connect to it will give you a driver not found error no-matter what to try and do.

First USB, then network.

Before we continue: If you can extract the driver and have the installer manually find it, you will probably be better off that what I am about to outline as this method will break if you change the XP machine’s network name. Though this may break it either way.

First we’re going  to plug the printer in and have it automatically add the printer. It may handle this with the in-built drivers, or you may have to download and install them yourself. In your own time, plug in and install the printer to your Windows 7 computer as you would normally. You can print off a test page if you’d like.

Then, unplug it and plug it back into your XP computer.

Next, go to the “Devices and Printers” window (Find it in the start menu.) and find the printer, it should be greyed out. Right click on it and go to “Printer Properties” and head over to the “Ports” tab. This is where the magic happens.

You want to click “Add port” and then “Local Port” (Not “Standard TCP/IP Port”.) and then click the “New Port..” button.

What you want to ender in the text field is an address that will look like “\\computer-name\printer-name”.
For instance, “\\fred-desktop\CannonIP4500″, this is not case sensitive and you get the names as follows:

Start –> Computer and click Network in the sidebar. The computer name, as it appears here, is the target computer’s network name, the first part of your printer’s address. If your computer’s name has spaces in it, you can find the “%40″ or similar used to replace a space.

Open up the target computer by double clicking it, and find the printer’s name, as it appears there, is what you want for the second part of the address.

Clicking “OK” should give you a new port in the Ports tab of Printer Properties. If it isn’t selected, select it, and you should now have a networked printer, just print a test page to find out.

If you found this useful..

please leave a comment. If it didn’t work or, better still, you found a better solution, please leave a comment and I’ll look into improving this for guide for everyone to use.

Posted in: Uncategorized by Fred 1 Comment

Emedded Bittorent: The/A future of web video and more!

What if it were possible to embed a video, music or any kind of file, into any website, and have it load every time, without restrictions or technical limitations other than raw hardware capability.

Bittorrent has come a long way since it’s beginings as a replacement for older P2P networks like Limewire. Over the years, we’ve seen Mainline DHT become much more useful while consuming much less bandwidth, thus phasing out trackers as an absolute necessity and the addition of magnet links mean we no longer need to host torrent files anywhere.

In short, we are now at the point where being able to insert a file by URI is within our grasp. What does this mean in practical reality?

Files no longer need to exist in a set location, instead being stored by a swarm of it’s viewers but can be augmented by servers if you want. Each person who watches a video acts as a host for that video, meaning that you are no longer restricted by Youtube’s 10 minute limit, it’s resolution limit or it’s slowness on congested days. Files will stay up as long as people are interested in them (Servers can also be added via magnet link’s “as” locator parameter.), and no longer will half the videos from yesteryear 404.

Major problems faced:

  1. Building it in the first place: Some combination of Chrome/Chromium + MPlayer (Built in.) + LibTorrent should be enough for a proof-of-concept.
  2. Specifically for video: Not having people use insane codecs, encoding and subtitle formats.
    1. I’m not holding my breath for a single standard, hopefully WebM and H.264 will cover most video.
  3. Unsure whether having different video resolutions rolled into a single link (Entirely possible.) would be a good idea.
    1. Leaving the option in would work.
  4. Links you click on are no longer checked by anyone, so you have to trust the person linking you to/embedding a video.
    1. This is how most content on the net works, no big problem.

I hope this gives you something to think about. While you’re thinking, give the Wikiepdia article on the Magnet URI scheme a look, it’s quite fascinating.