Tag Archives: split

JavaScript: How to Explode a String into an Array Programming 13 FEB 2012

Coming from PHP, I’m well versed in using the handy explode function to force a string into an array, using a specified delimiter character to chop up the string into the little bits that are to be stored in the array.

Happily for me, plain old vanilla JavaScript also has this ability built into the language, choosing to call its version of this functionality “split”.

From the official definition: The split() method is used to split a string into an array of substrings, returning the new array containing the substrings.

It accepts two parameters, namely the separator and the limit, both of which are actually optional by the way. The separator parameter is where you specify the delimiter character (if you omit this, the entire string will be stuffed into a single element array ). The optional limit parameter if set will control the number of splits.

A few examples on using split:

var str="How are you doing today?";

//some split usage examples
document.write(str.split() + "<br />");
document.write(str.split(" ") + "<br />");
document.write(str.split("") + "<br />");
document.write(str.split(" ",3));

//the output (',' indicates array boundary)
//How are you doing today?
//H,o,w, ,a,r,e, ,y,o,u, ,d,o,i,n,g, ,t,o,d,a,y,?


Ubuntu Terminal: How to Join the Parts of a Split AVI Video File CodeUnit 09 MAY 2011

Sometimes you will encounter files that have been split into segments in order to make them more manageable for either download or fixed size media transfer purposes. For example, a common method for doing this on Windows is to make use of the excellent dinosaur (in other words, it appears to have been available on PCs since the dawn of the computing age) application, HJ Split, which neatly chops any files fed to it into nice little manageable chunks of bits.

But now the question arises: say you encounter a AVI video file that you have downloaded all the segments for, but now want to put everything together via your Ubuntu desktop in order to view the full video. How will we do it?

Well a remarkably simple way is to open up a standard terminal window and then concatenate all the pieces together with the bog-standard cat command:

cat video1.avi.001 video1.wmv.002 video1.avi.003 > video1.avi

This should result in a fully watchable, complete AVI video file.

However, this process can sometimes cause the video and audio to fall slightly out of synch. One way of dealing with this is to use the clever little mplayer/memcoder application bundle.

First, install with:

sudo apt-get install mencoder mplayer

Now, force a audio/video resynch with:

mencoder -forceidx -oac copy -ovc copy video1.avi  video1-fixed.avi

This should work on a couple of other formats as well, such as MPG or MPEG video files for example.


Splittig Gi’s Martial Arts | My Life 29 SEP 2010

Hey, I've even produced a comic on this topic before - told you it happens a fair bit to me! :P

I seem to be making a habit of this you know. Splitting gi’s (or dogis if you prefer) that is.

The latest ripped white training pants to add itself to my notorious list of shredded pants, joined the ranks at Monday night’s training session, where Gerhard and myself were going through the steps for Shisome, the newly renamed first kata under the Funakoshi International style, under the watchful eye of sensei Birgitt.

As I spun around from a nice and relaxed kamae stance into a more bowlegged back stance towards the end of the kata, there was the usual loud ripping noise I’ve become rather accustomed to, prompting an exclamation from sensei as to whose poor knees were giving out now. Shamefully I replied that for a change it wasn’t a body part disagreeing with the sudden movement, but rather my trusty old pants who had now had enough of the incessant abuse I dish out to it every Monday and Wednesday evening.

Come to think of it, it had tried to commit seppuku once before, but my mom jumped to the rescue with needle and thread. This time however there is no saving it, as it has now well and truly committed ritual suicide. (Though it will have to do for tonight’s training over a very white underpants until I can get to the shops on Saturday to try and find a replacement!)

Sigh, me and my ripped pants.

It’s becoming a signature thing I tell you! ;)

Split Large Files Into Smaller Pieces CodeUnit 02 APR 2010

It’s annoying when you pull down a really large file and then when you want to put it on your little flash drive you realize that the file is simply to large to fit.

So enter GSplit, a great little reliable, free file splitter application that can split large files like disk images, video files, zip archives into a whole lot of smaller chunks and then provide you with a handy little executable file to sew all those pieces back up again when you need to.

There are a number of splitting options available to you through the fairly slick interface and GSplit is quite capable when it comes to splitting files that are well over 4GB big! It works on most Windows versions (including Vista) and it integrates nicely into the Window shell, allowing you to split files directly from your system context menu. It gives you a great indication of time elapsed, time remaining during operations and also maintains split settings in profiles, meaning you can apply specific profiles to specific types of files.

There are a number of other cool features aimed at more power user level users, but the essence of it all is that this is a great little utility which is well worth the trouble and will make your life a breeze when it comes to porting around overly large files!


Related Link: http://www.gdgsoft.com/gsplit/

The House of C 009: Let Her Rip! The House of C 01 FEB 2010

This embarrassingly enough has happened to me before you know (not the g-string bit though). Just as class was about to get underway, still happily stretching in anticipation of a good bout of training, I squatted to loosen up my hears and was horrified to hear a loud ripping noise as I went down.

Needless to say, I had underestimated my dogi’s stretchiness and now had to contend with a rather large, gaping hole in my pants, underpants happily showing my bum cheek off to anyone who cared.

Still, the practice was good and I must say, it was certainly more airy training that way…

Schadenfreude: Splitting the Course Jokes & other Funny Stuff | Sport & Health 25 JAN 2010

Schadenfreude: pleasure derived from the misfortunes of others. It’s human nature really.

You can talk about staged wardrobe ‘malfunctions’ like Janet Jackson’s infamous Superbowl Stunt all day long if you want, but shame poor Scottish bobsledder Gillian Cooke has to take the cake for experiencing one of the most publically embarrassing (thanks YouTube!) wardrobe malfunctions for quite some time! :)

Team mate of British bobsledder Nicola Minichiello, this two-women bobsleigh team has already tasted success by taking gold at the FIBT World Championships 2009 in Lake Placid, New York. However, it is without a doubt that the cold fateful day on January 16th 2010 will be the day Gillian remembers most in her bobsledding career…

(Can’t help but wonder – amongst all that cold snow and ice, shouldn’t bobsledders be wearing slightly more… well thermal underwear? O.o)

Related Link: http://en.wikipedia.org/wiki/Gillian_Cooke

Doing the Splits My Life 24 APR 2008

Split PantsYup, yup, yup, yup. So, we haven’t quite joined up with the local gym here just yet, thanks in part to the rather financially tight month we’ve had with all those purchases we had to make for the house. However come payday and both of us will be rushing off in order to join up and get fit again! Of course, after Tuesday’s evenings rather in your face sign, I DO need to get my rear in gear ASAP!

So, Chantelle was on a late and I was busy passing the time by playing some PlayStation when it suddenly dawned upon me that I was in fact responsible for supper. No problem methinks, getting up and walking over to the TV cabinet to turn off the console.


Yup, as I squat down in front of the TV, there is this deafening ripping noise and lo and behold, my 10 year old favourite gym/jogging/DIY pants are no more.

Yup, yup, yup, yup. I NEED to get this rear in gear! :)