tag:blogger.com,1999:blog-57188182733281718872023-11-16T14:13:15.166+00:00ohforfuckssakeAn attempt to collate the lessons learned when trying to get linux to work. And other stuff.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.comBlogger153125tag:blogger.com,1999:blog-5718818273328171887.post-68599031287924732962014-09-11T19:30:00.002+01:002014-09-11T19:30:36.043+01:00Deshoogling Shoogled VideoI have previously posted some advice about how to use VirtualDub and deshaker to get rid of the shaky video that is a feature of the Sanyo HD2000 that I use. In the intervening years, lots of other cheap HD cameras have hit the market that are even shakier. I am thinking of the GO Pros and the iPhones.<br />
<br />
SO it is time to revisit my post - which could not get audio working.<br />
<br />
Here is my fresh solution.<br />
<br />
We open the file through a <a href="http://en.wikipedia.org/wiki/FFmpeg">ffmpeg</a> <a href="http://www.virtualdub.org/">virtualdub</a> input plugin, apply the <a href="http://www.guthspot.se/video/deshaker.htm">deshaker</a> filter once, then <a href="http://en.wikipedia.org/wiki/Frameserver">frameserve</a> the second pass through <a href="http://en.wikipedia.org/wiki/AviSynth">avisynth</a> proxy, to <a href="http://fixounet.free.fr/avidemux/">avidemux</a> to apply final filters and compression settings.<br />
<br />
So lets get started. To actually open the file we need VirtualDub. You don't want the portable version, so get the full fat version here:<br />
<br />
<a href="http://virtualdub.sourceforge.net/">http://virtualdub.sourceforge.net/</a><br />
<br />
I have been using version 1.10.4, so anything later than that should be fine.<br />
<br />
You simply unzip the VirtualDub-1.10.4.zip file to wherever you want, and then go into the folder. You will find a file in there called "auxsetup.exe". Run that. You want to choose the option to "Install Handler". This is going to let you frameserve out of VirtualDub. This is why you can't use the portable version, because it needs to make system changes.<br />
<br />
Next you need to be able to open the file. I am dealing with mp4 files containing x264 and AAC streams. If ffmpeg can't decode your file, it's officially weird. There is a very useful plugin for virtualdub which lets you open any file that ffmpeg can access. You can download it here:<br />
<br />
<a href="http://sourceforge.net/projects/virtualdubffmpeginputplugin/">http://sourceforge.net/projects/virtualdubffmpeginputplugin/</a><br />
<br />
Again, you just need to unzip the VirtualdubFFMpegPlugin_0817.zip that results. You end up with two folders and a readme. Copy the contents of the plugins32 folder into the plugins32 folder in your virtualdub installation folder. You need to include the "ffdlls" sub-folder.<br />
<br />
So far, so good. You can now test your system by running virtualdub, and trying to open your mp4 file. Hopefully that should work. You can further test the system by choosing the file menu, and "Start Frame server...". In the dialogue box that follows, just choose "Start". You will not be running multiple frameservers, but if you are here is where you would give them individual names. In the next window, you need to name your placeholder file. This is the signpost that avisynth is going to open to access the frameserved data. I name my file "frameserver.vdr" and stick it in a temp folder. It's tiny. Once you save this, virtualdub shrinks down to a frameserver info window, with the only option to "Stop Frameserving".<br />
<br />
Next, open a new instance of virtualdub, and try to open the frameserver.vdr file. This should work, and should give you access to the data. You should be able to see the counters change on the info window as you browse through the file.<br />
<br />
You might be able to open this .vdr file directly in avidemux, or any other encoder of your choice. If so, best of luck you you. I couldn't. Even when I renamed it to "frameserver.avs", which is the avisynth file type.<br />
<br />
Tune in next time for more hilarious adventure of how to deshoogle!<br />
<br />
smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-48430273201192859312012-05-26T14:13:00.000+01:002012-05-26T14:13:07.463+01:00Digital Photo FramesDigital Photos are great. No really, fantastic. But they are utterly worthless if no one gets to see them. You have couple of options. First, stick them all on Facebook. Alternatively, if you do not want to share your personal family life with the entire planet, carry them around with you on a phone (the twenty first century version of the photo in the wallet). Lastly, stick them in a digital photo frame, and stick it somewhere visible.<br />
<br />
This post is about getting digital photos the right size and dimensions to display on a digital photo frame. Modern camera's take photographs at a resolution massively higher than modern digital photo frames can handle. So to compensate we have to reduce the size of the images so they display properly.<br />
<br />
First of all dump all the images you are working with into one folder. Open a terminal and navigate to the folder where the images are. Secondly, spaces in the filenames will break this, so we have to replace them with underscores using this very handy command which I did not write because it uses SED!:<br />
<br />
<pre class="postCode">find . -name '* *' | while read file;
do
target=`echo "$file" | sed 's/ /_/g'`;
echo "Renaming '$file' to '$target'";
mv "$file" "$target";
done;
</pre><br />
Anyway, if your frame has a resolution of 800x480 (common for small cheap frames at the time of writing) you can scale all of the images using:<br />
<br />
<pre class="postCode">for file in *.{jpg,JPG}; do echo $file && convert -resize 800x480 -quality 80 $file small_$file; done
</pre><br />
The really handy thing with the [resize] command is that it doesn't change the aspect ratio, so it either fits the image to 800 wide, or 480 high, and then puts black lines in at the sides to fit the image in.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com1tag:blogger.com,1999:blog-5718818273328171887.post-2223000593498829172012-01-27T11:59:00.000+00:002012-01-27T11:59:00.248+00:00SkyrimFor a change, it is a new year after all, I present my comments on levelling a character in <a href="http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0CE0QFjAC&url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FThe_Elder_Scrolls_V%3A_Skyrim&ei=5SwgT7PIBMWcOrf6jbIO&usg=AFQjCNEAumWwaGQ-RATLq2ro0q9_qnmzgw&sig2=ppLQYtYLlSaPVkrjAgfVeQ">Skyrim</a>.<br />
<br />
Skyrim is the latest installment of the Elder Scrolls series, which has been running for nigh on twenty years. I missed <a href="http://en.wikipedia.org/wiki/The_Elder_Scrolls:_Arena">Arena</a>, the first one, but thoroughly enjoyed <a href="http://en.wikipedia.org/wiki/The_Elder_Scrolls_II:_Daggerfall">Daggerfall</a> the sequel. I tried <a href="http://en.wikipedia.org/wiki/The_Elder_Scrolls_III:_Morrowind">Morrowind</a>, and didn't like it. Too weird, dark and depressing. <a href="http://en.wikipedia.org/wiki/The_Elder_Scrolls_IV:_Oblivion">Oblivion</a> was awesome but quirky, and Skyrim is Oblivion with all the stuff I didn't like taken out.<br />
<br />
These games are openworld roleplaying games. They are more like toys than games, because you can fiddle around to your hearts content. In the same was as any self respecting role playing game, you can level your character, meaning improving their statistics and skills as you gain in experience.<br />
<br />
The Elder Scolls series operates a world levelling system, which I really didn't like in Oblivion. Basically as you get harder, so does the whole world. The result is that you feel you are running on a treadmill, constantly expending effort just to stay still. Skyrim seems to do this much more subtly, so that certain environments are inherently easier/harder no matter what your level. This is good and means you can still feel like a god like mage in some places.<br />
<br />
So, how to build character efficiently? Why efficiently? Well every skill increase you get goes towards your overall level. You don't nominate the skills that affect your level like in Oblivion. A simple exploit in Oblivion was to nominate crap like <a href="http://www.uesp.net/wiki/Oblivion:Speechcraft">speechcraft</a> and <a href="http://www.uesp.net/wiki/Oblivion:Acrobatics">acrobatics</a>, which take ages to increase through normal use. You would then "dabble" in the real stuff. That meant you could max out all the schools of magic and still be level 2. The world treated you like a level 2 character, meaning you could destroy everything you encountered with one or two spells.<br />
<br />
Skyrim doesn't do this. Any skill counts towards level, so you want to make sure you only level skills you are going to use in your final character. That's efficient levelling.<br />
<br />
OK, so the game starts, and you pick your character. If I am going magey, I do like a <a href="http://www.uesp.net/wiki/Skyrim:Altmer">high elf</a> <a href="http://www.uesp.net/wiki/Skyrim:Magicka">magicka</a> bonus. The dragon attacks just in the nick of time, and you are up and running. My advice is to follow <a href="http://www.uesp.net/wiki/Skyrim:Ralof">this guy</a>, not the guard. Shortly thereafter you find yourself in a room with the NPC asking you to grab a key from a corpse to open a door. Now is the time to level your <a href="http://www.uesp.net/wiki/Skyrim:Sneak">sneak</a> skills - if you want to. Crouch behind the NPC, sneak, and hit him with a dagger. He is flagged as unkillable by the game, and will never turn on you. This will very quickly level up your sneaking. So quickly you may be over level 10 before you get around to unlocking the door. This, children, is what we call an exploit. It is not a realistic sequence of events. Normal people don't let you stab them in the back several hundred times. This will not work with the guard, so if you want to level sneak, follow Ralof.<br />
<br />
You can take the tedium out of stabbing the NPC in the back by blasting him with flames to level your <a href="http://www.uesp.net/wiki/Skyrim:Destruction">destruction</a> skill. This takes a bit longer because when he hits zero health the skill stops levelling. You only get skill increases when you are actually causing damage.<br />
<br />
What next? Well, that depends on your goal. My goal is to create a hard as nails spell caster assassin type. The main early choice you have to make in this role is whether to <a href="http://www.uesp.net/wiki/Skyrim:Sneak">sneak</a> or go <a href="http://www.uesp.net/wiki/Skyrim:Invisibility">invisible</a>. You can go invisible by levelling <a href="http://www.uesp.net/wiki/Skyrim:Illusion">illusion</a> to 75 and casting the requisite spell, or by levelling <a href="http://www.uesp.net/wiki/Skyrim:Alchemy">alchemy</a> to produce invisibility potions. Sneaking requires the sneak skill obviously. I have yet to decide which is the better option. You are going to end up levelling alchemy anyway - see below for more information - but I tend to spend a long time invisible so would need to carry a lot of potions. To level efficiently, you really should choose between sneak and illusion.<br />
<br />
Every time you level up you get to choose to increase one of <a href="http://www.uesp.net/wiki/Skyrim:Health">health</a>, <a href="http://www.uesp.net/wiki/Skyrim:Magicka">magicka</a> or <a href="http://www.uesp.net/wiki/Skyrim:Stamina">stamina</a>. Health gives you your hit points, magicka your spell casting reservoir, and stamina your sprint time/carrying capacity. In the beginning put it all in magicka. You are going to need a decent capacity. However, don't go overboard. As you'll see below, we are going to be crafting a 100% lower casting cost suit. This means that ultimately spell costs in one discipline will be nil. As in do not require magicka. You're going to look pretty stupid with your 500 sized magicka reservoir and nothing to spend it on.<br />
<br />
Also, because the world still levels, when you reach late thirties in level, there are <a href="http://www.uesp.net/wiki/Skyrim:Bandit">bandit archers</a> around who can one shot kill a mage with only 100 health. That's just embarrassing. I have yet to work out what the right balance is, but it will have to take into account whether you go illusion or sneak. The other spells you are likely to be casting are soul trap, and healing, which don't use a massive amount of magicka.<br />
<br />
Money, money, money.<br />
<br />
Just like real life, you are not going to get anything done until you have got some serious wonga behind you. To get serious wonga you need to be able to run a profitable business. In various forum posts and hints and tips columns about the game, a typical wonga obtaining strategy is "<a href="http://www.uesp.net/wiki/Skyrim:Enchanting">enchant</a> <a href="http://www.uesp.net/wiki/Skyrim:Banish">banish</a> on <a href="http://www.uesp.net/wiki/Skyrim:Iron_Dagger#Iron_Dagger">iron daggers</a>, sell for £££'s". This is completely correct and completely useless at the same time. Y'see you need to learn the banish enchantment before you can enchant it onto any dagger, iron or otherwise. Weapons that come with this enchantment are levelled items, so do not appear at the start of the game. I didn't start seeing them being offered for sale until level 33.<br />
<br />
So, something else to start then. At the beginning of the game making and selling enchanted weapons is an easy way to spend money instead of making it. Your profit margins are just too narrow to make it worthwhile. Instead, I heartily recommend the potion run. Here's how it works. First get some seed capital. You pop out of the tutorial near <a href="http://www.uesp.net/wiki/Skyrim:Riverwood">Riverwood</a>, so nip in there. Sell all your loot from the tutorial dungeon. You now have two options. If you like scenery, it's time to go on a grand tour of all the major cities. Walk to <a href="http://www.uesp.net/wiki/Skyrim:Riften">Riften</a>, <a href="http://www.uesp.net/wiki/Skyrim:Windhelm">Windhelm</a>, <a href="http://www.uesp.net/wiki/Skyrim:Winterhold">Winterhold</a>, <a href="http://www.uesp.net/wiki/Skyrim:Dawnstar">Dawnstar</a>, <a href="http://www.uesp.net/wiki/Skyrim:Morthal">Morthal</a>, <a href="http://www.uesp.net/wiki/Skyrim:Solitude">Solitude</a>, <a href="http://www.uesp.net/wiki/Skyrim:Markarth">Markarth</a>, <a href="http://www.uesp.net/wiki/Skyrim:Falkreath">Falkreath</a> and <a href="http://www.uesp.net/wiki/Skyrim:Whiterun">Whiterun</a> in that order. Kill any animals/bandits and pick any flowers/mushrooms you come across. In Winterhold, join the <a href="http://www.uesp.net/wiki/Skyrim:College_of_Winterhold_(faction)">college</a> to get a room with wardrobes that you can permanently store stuff in. Go to the first guild quest to get a free <a href="http://www.uesp.net/wiki/Skyrim:Ward">shield spell</a>, and to get access to trainers. Do not go on to the second quest yet. The second option is identical to the first, but you need a bit more seed capital. Just walk up to Whiterun, and take the wagon from there to all the other locations to cut down on exploring time. Keep any ingredients you find. Sell any weapons and armour, unless they have enchantments you don't know. Take any skins to a blacksmith and convert them to <a href="http://www.uesp.net/wiki/Skyrim:Leather_Strips#Leather_Strips">leather strips</a>. Store these in your room in the college if you get too many. <br />
<br />
You are now ready to start the alchemy grand tour. Using fast travel visit every <a href="http://www.uesp.net/wiki/Skyrim:Merchants">alchemist</a> in every city (apart from Winterhold) and buy as many of their ingredients as you can afford. Just empty their inventories, apart from <a href="http://www.uesp.net/wiki/Skyrim:Void_Salts">Void Salts</a> which are more expensive than any potion you can make from them. Now, go to this website http://www.endoftheweb.se/skyrim/index.php and type in the ingredients you have, and search for the most valuable potions you can find. Make them, and use them to fund the next round of ingredient purchasing. Rinse this, and repeat. In particular, watch out for <a href="http://www.uesp.net/wiki/Skyrim:Giant%27s_Toe">Giant's toes</a> and <a href="http://www.uesp.net/wiki/Skyrim:Wheat">wheat</a>. Combined they make a potion worth over 500 gold pieces. Wheat is easy to find, at any of the farms around Whiterun. Giant's toes are harder to part from their owners, so grab them from alchemists whenever you see them.<br />
<br />
If you do not want to use a thinks for you website like that, then to make good cash from Alchemy, you want to make the following four potions: Invisibility, Paralysis, Damage Magicka Regen, or Slow.<br />
<br />
For invisibility, you want to hoover up Chaurus Eggs, Ice Wraith Teeth, Luna Moth Wing, Nirnroot, Vampire Dust. Mix any two together and you'll have an invisibility potion worth a few hundred gold. You can add a third ingredient to 'power' up the potion. Nordic Barnacle and Namiras Rot work well.<br />
<br />
For Paralysis, make sure you buy Briar Heart, Canis Root, Imp Stool, and Swamp Fungal Pod. Again, any two mixed together will get you a health profit. Snowberries or Slaughterfish Eggs and Scales make a good catalyst.<br />
<br />
There are many more key ingredients for Damage Magicka Regen. You can collect Bear Claws, Blue Butterfly Wing, Blue Mountain Flower, Chickens Egg, Glow Dust, Hanging Moss, Nightshade, Spider Egg, and Spriggan Sap. Lavendar is the catalyst you want for this potion, although it won't work for every combination.<br />
<br />
Lastly, for Slow potions, you want Deathbell, Large Antlers, River Betty, and Salt Pile. Creep Cluster and Scaly Pholiota make good friends with this potion.<br />
<br />
When your <a href="http://www.uesp.net/wiki/Skyrim:Speech">speech</a> skill hits 25, stop by the <a href="http://www.uesp.net/wiki/Skyrim:Black-Briar_Meadery">Black-Briar Meadery</a> in Riften, and ask the chap behind the counter about the place. You get an option to persuade him, which exercises your speech. (You can actually start this earlier if you have the money to bribe him up to speech 25). You can now hit enter repeatedly to level up your speech skill to whatever value you want. I would recommend taking it to 50. This lets you get the <a href="http://www.uesp.net/wiki/Skyrim:Speech#Skill_Perks">Merchant</a> perk, which lets you sell anything to any shopkeeper. So you do not have to trail from alchemist to smith, to general store. A prerequisite for this is the <a href="http://www.uesp.net/wiki/Skyrim:Speech#Skill_Perks">Alure</a> perk, which gets you better prices from the opposite sex. Most alchemists are women and most blacksmiths are men, so there is no "right" sex to be.<br />
<br />
You now have a decent money making trade which will serve you well. It is time to start thinking about weapons and armour. As you are going around your grand tour, start visiting every <a href="http://www.uesp.net/wiki/Skyrim:Merchants">smith</a>. Buy <a href="http://www.uesp.net/wiki/Skyrim:Iron_Ore">Iron Ore</a>. Don't buy the <a href="http://www.uesp.net/wiki/Skyrim:Iron_Ingot">ingots</a>, just the ore. The <a href="http://www.uesp.net/wiki/Skyrim:Iron-Breaker_Mine">Ironbreaker mine</a> in Dawnstar is a decent place to get a dozen or so lumps of ore, just grab a pick axe from inside the mine. For some reason that's not theft. Then visit a smelter which you can find in Windhelm, Whiterun, and outside said mine. You don't get them in every smith's. Smelt the ore into ingots. Then grab your leather strips, go to the forge and start spamming iron daggers. They need one ingot and strip per dagger. Make between five and six hundred of these and you should hit 100% smithing without spending a penny. Why not do this to make money? Well, you could, but it takes ages to gather the ore. There are maybe only one or two lumps available from a typical smith. Also the daggers sell for less than the ore and strips combined, so if you want cash, you should just sell the raw materials. You can speed up this process by buying the raw materials direct from the smiths. This is expensive, but works out find as long as you pay with potions. Get the merchant perk, buy all the materials you need, then sell the smith some potions to get your cash back.<br />
<br />
You then want to start enchanting your daggers. Why? Well a standard iron dagger sells for, say, 5 gold pieces. An iron dagger enchanted with <a href="http://www.uesp.net/wiki/Skyrim:Damage_Magicka">damage magicka</a> sells for 250 gold pieces. To enchant you need to know the enchantment, have an item to enchant, and a filled <a href="http://www.uesp.net/wiki/Skyrim:Soul_Gem">soul gem</a>. You can buy soul gems from most trading wizards in the College, from most court wizards, and from most <a href="http://www.uesp.net/wiki/Skyrim:Merchants">general stores</a>. For our purposes a petty soul gem is as good as a grand soul gem. Why? You can buy a filled petty soul gem for under 100gp. Your dagger should not have cost you anything if you harvested the resources yourself, but at most has a construction cost of 10-20gp. With a petty soul gem you can increase its value to 250gp. That's double your investment, which is a very healthy return. Common soul gems can easily cost 200gp-300gp, but only get you a small bump in the value of the dagger, to maybe 275gp. So, you end up breaking even at best. With a grand soul gem you still only get a dagger worth maybe 300gp, and you've spent over 1000gp on it. Petty = better.<br />
<br />
If you are running low on leather strips and you are going hunting anyway, you can buy the <a href="http://www.uesp.net/wiki/Skyrim:Soul_Trap">Soul Trap</a> spell from <a href="http://www.uesp.net/wiki/Skyrim:Phinis_Gestor">Phinis Gestor</a> at the college. Load up with empty petty soul gems, then do a wild animal run - I suggest doing laps around the mountain Whiterun is built on - casting soul trap on the animals before you kill them. You'll get skins and souls in one go. If you do this, it can make financial sense to buy some empty lesser or common soul gems. The cost per unit is low enough, and it means you don't have to do too much shopping around for pettys before you get down to some serious hunting. If your potion crafting job is netting you enough cash, you may just want to buy the soul gems filled. If you do a grand tour, including the college, of all general traders, you should get a couple of dozen filled pettys/lesser per lap.<br />
<br />
The best starting enchantment is <a href="http://www.uesp.net/wiki/Skyrim:Damage_Magicka">damage magicka</a>. This is better than any of the elemental damage enchantments. If you are staying out of dungeons at this point, get into the habit of checking the weapons that smiths have for sale as you tour around. Grab the cheapest magicka damage weapon you can find, and remember to pay in potions. Then disenchant it at an arcane enchanter, and bingo. Start enchanting those daggers, and hey presto you have a new source of income. As you level enchanting, every 10 points increases the power of the enchantment, so the daggers should increase in value.<br />
<br />
The next best enchantments are <a href="http://www.uesp.net/wiki/Skyrim:Damage_Stamina">damage stamina</a> or <a href="http://www.uesp.net/wiki/Skyrim:Absorb_Health">absorb health</a>. These should boost your dagger value from 250gp to 500gp or thereabouts. Filled common soul gems now also make financial sense, although still not as much sense as pettys. I am not sure what level weapons with these enchantments become available for purchase, because I wasn't paying enough attention. Grab them as soon as you see them. I was level 33 when I saw my first <a href="http://www.uesp.net/wiki/Skyrim:Banish">Banish</a> enchanted weapon for sale. This really kicks things into top gear. A banish dagger has a value of 1750gp.<br />
<br />
Once you can start to make banishing daggers, your financial woes are at an end. One grand tour for filled soul gems, followed by some smithing and enchanting in Windhelms marketplace, will net you 20,000 to 40,000 worth of daggers. It's now time to start spending that cash.<br />
<br />
Get your smithing up to one hundred by just buying the necessary ore/ingots/strips and paying in daggers of banishing. Then enchant your way up to 100 as well. While you are levelling enchanting, and alchemy come to think of it, make sure you get the 5/5 quality perks at the very base of the tree as they increase the sale cost of your items. We now need to consider combat, which isn't something that has been important to date - other than wild animals. Go and see <a href="http://www.uesp.net/wiki/Skyrim:Faralda">Faralda</a> in the College, and get some destruction training. She can take you all the way to 90. Make sure to take plenty of daggers along to pay with. From 85-90 is going to cost 20,000 - 25,000, so you are looking at 25-30 daggers of banishing to pay for it all. It is probably best to buy training in destruction as you are levelling smithing alchemy and enchanting. Why? You only get 5 training boost per level. If you are mid thirties in level and you boost destruction from 80-85 that's enough to increase your level anyway, at which point you can go straight from 85-90. However, you you are mid-thirties and you go from 30-35 in destruction, that's hardly a blip on your overall level, and you will have to level your crafting skills to gain a level before you can go 35-40.<br />
<br />
Pick a form of destruction damage, I like shock, and grab the perks to specialise in it. You can also get the perks to make novice/adept spells cheaper to cast, which can make the game easier if you have to do dungeon runs before hitting 100 smithing/enchanting. Once you get to those levels though, buy some armour with fortify destruction and resist magic. Disenchant the armour to learn those enchantments. Then buy or make some plain light armour. With 100 in enchanting you can make four items, chest, helm, necklace, ring, with over 25% reduction cost for destruction. That means you can cast any destruction spell for free. So you can dual cast Thunderbolt for over 200 shock damage per hit. For free. Bye bye giants and dragons, and pretty much anything else that crosses your path. At 100 enchanting you want to grab the dual effect perk, which lets you add another ability to the armour. Resist magic is very useful, but can only go on the ring and necklace for a total, at 100 skill, of just over 50%. On your helm and chest, you probably want either another magic school such as restoration for cheap wards and healing, or some miscellaneous stuff like extra magicka, waterbreathing, lockpicking, or fortify light armour to boost your armour rating.<br />
<br />
Your greaves and boots can't take the magic enchantments, but both can take carry weight, which helps you haul loot out of dungeons. The greaves will also take fortify light armour, and the boots will take muffle, or fortify sneaking, which cancels out the noise of light armour making you much harder to detect when invisible or sneaking. I ended up with:<br />
<br />
Helm: Fortify Destruction and <a href="http://www.uesp.net/wiki/Skyrim:Fortify_Magicka">Magicka</a><br />
Chest: Fortify Destruction and <a href="http://www.uesp.net/wiki/Skyrim:Fortify_Light_Armor">Light Armour</a><br />
Arms: Fortify <a href="http://www.uesp.net/wiki/Skyrim:Fortify_Carry_Weight">Carry Weight</a> and <a href="http://www.uesp.net/wiki/Skyrim:Fortify_Light_Armor">Light Armour</a><br />
Feet: Fortify <a href="http://www.uesp.net/wiki/Skyrim:Fortify_Carry_Weight">Carry Weight</a> and <a href="http://www.uesp.net/wiki/Skyrim:Fortify_Sneak">Sneak</a><br />
Neck: Fortify Destruction and <a href="http://www.uesp.net/wiki/Skyrim:Resist_Magic">Resist Magic</a><br />
Finger: Fortify Destruction and <a href="http://www.uesp.net/wiki/Skyrim:Resist_Magic">Resist Magic</a><br />
<br />
To finish off your armour, give it a bit of a boost. Grab the arcane blacksmith perk to be able to work on magic items, then grab the elven (or whatever kind of armour you have) perk. Both require steel to get there, so just grab it. Now you'll need <a href="http://www.uesp.net/wiki/Skyrim:Moonstone_Ingot#Refined_Moonstone">moonstone</a> and <a href="http://www.uesp.net/wiki/Skyrim:Quicksilver_Ingot">quicksilver</a> (if you have the <a href="http://www.uesp.net/wiki/Skyrim:Elven_Gilded_Armor#Elven_Gilded_Armor">gilded elven chest plate</a>, which you should) ingots. These let you improve the armour ratings of each item at a workbench, adding a significant amount to the armour rating. You probably also want to level light armour along with destruction to get the most out of your armour, picking up the extra ratings perks when they are available.<br />
<br />
You are now ready to start some serious dungeon delving. One of the very first quests you get offered is at the Riverwood traders. You need to <a href="http://www.uesp.net/wiki/Skyrim:The_Golden_Claw">grab a claw from a dungeon</a>. Don't do this one until you are ready to rock and roll. The problem is that in the dungeon you find a heavy (25) <a href="http://www.uesp.net/wiki/Skyrim:Dragonstone">stone</a> which is part of a quest given by the <a href="http://www.uesp.net/wiki/Skyrim:Farengar_Secret-Fire">Whiterun mage</a>. You cannot drop the stone as it is a quest item. It weights 25. Is you hand it over it all but triggers the first dragon battle, which triggers random dragon attacks all over the place, which really interrupt the grand tour earning strategy.<br />
<br />
If facing one big baddie, constantly thunderbolt him in the face. If facing more than one, chain lightning the whole group. Dual cast the buggers as well, because with your suit of armour, you can benefit from the increased damage per second, and ignore the disproportionate magicka cost increase. At this point, with this build, you should be about level 38, with 5 perks available. You could pump them into speech to get better prices, but a <a href="http://www.uesp.net/wiki/Skyrim:Fortify_Barter">suitable amulet</a> does that job much more efficiently. You also need to make a final decision about sneak/illusion, which is where your next big levelling boost is going to come from. The game is pretty advanced at this stage. You'll have bears and sabre toothed tigers prowling around. Just remember though, thunderbolt to the face. Apart from storm atronachs, that just tickles them.<br />
<br />
Once you start offing dragons, gather up their scales and start forging Dragon Scale armour which is very, very, tasty and comes in light and heavy varieties.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-92016358721419747712011-12-23T13:37:00.000+00:002011-12-23T13:37:50.605+00:00Formatting Video for iPadThis, I have to say, has been one of the most gratifying things to work out in my entire experience of working stuff out. The iPad is an excellent device for consuming media, especially video. The problem is getting video in a format suitable for the iPad without forking over dosh to Apple.<br />
<br />
The best I have been able to come up with to date is Handbrake, which has built in modes for the iPad. What it doesn't do is batch convert a whole directory to iPad format.<br />
<br />
So joy of joys, I present the Ubuntu commands necessary for this (assuming you have installed the requisite packages all of which are listed in my how to build a custom Live CD posts).<br />
<br />
<pre class="postCode">target_resolution="1024x576" &&
target_bitrate="2.5M" &&
minimum_bitrate="0k" &&
maximum_bitrate="3.5M" &&
audio_bitrate="256k" &&
audio_sample_rate="48000" &&
audio_channels="2" &&
input_extension="mkv" &&
number_of_threads="8" &&
for file in *.$input_extension; do \
ffmpeg -y -i "$file" \
-pass 1 -f mp4 \
-s $target_resolution -vcodec libx264 -threads $number_of_threads -b $target_bitrate \
-bt 100k -maxrate $maximum_bitrate -minrate $minimum_bitrate -bufsize 2M \
-flags2 +mixed_refs -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 2 -refs 2 -coder 0 -me_method umh -me_range 90 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 \
-rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -g 90 -an /dev/null && \
ffmpeg -y -i "$file" \
-pass 2 -f mp4 \
-acodec libfaac -ar $audio_sample_rate -ab $audio_bitrate -ac $audio_channels \
-s $target_resolution -vcodec libx264 -threads 8 -async 2205 -b $target_bitrate \
-bt 100k -maxrate $maximum_bitrate -minrate $minimum_bitrate -bufsize 2M \
-flags2 +mixed_refs -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 2 -refs 2 -coder 0 -me_method umh -me_range 90 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 \
-rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -g 90 \
"${file%.$input_extension}.mp4" \
; done
</pre><br />
You fill in the details between the quotes at the beginning, copy and paste the code into a command line in a directory containing video files of type .input_extension and it will convert all the files to .mp4 suitable for playing on an iPad. All files will have exactly the same resolution and bitrate, which may not be desirable, so check in advance by examining your files.<br />
<br />
You can change the target bitrate to whatever you like, within reason, and the iPad will still play the files. You will want to carefully check the aspect ratio of the files going in to make sure that these settings work. If they start in 16:9 this will spit them out in 16:9 at 1024x576. 4:3 files will need the target_resolution changed to "1024x768" for instance.<br />
<br />
Don't make the mistake I made of running several instances of this command at the same time - because they will overwrite each others variables.<br />
<br />
As a bonus, here are the commands necessary to extract audio from a clip in an iPod/iPhone friendly format:<br />
<br />
<pre class="postCode">audio_bitrate="128k" &&
audio_sample_rate="48000" &&
audio_channels="2" &&
input_extension="flv" &&
for file in *.$input_extension; do \
ffmpeg -y -i "$file" -vn \
-acodec libfaac -ar $audio_sample_rate -ab $audio_bitrate -ac $audio_channels \
"${file%.$input_extension}.m4a" \
; done
</pre><br />
Same rules apply.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-39200451642135111602011-11-11T11:59:00.001+00:002011-11-21T20:23:05.776+00:00Fixing a fucked Grub2I have recently encountered a fucked Grub2. This is the latest version of Grub that comes with, amongst other things, Ubuntu Natty. You can't fix it the way I described in the past. That's for Grub1 only.<br /><br />Why did I end up with a fucked grub? I was stupid. It was entirely my fault. You see, I BELIEVED that this time, when I upgraded my Ubuntu installation from Natty to Oneiric, I wouldn't end up with an unresponsive pile of crap as the result. More fool me.<br /><br />Because I am not a total buffoon, I made a drive image before attempting the upgrade. I thought I would give True Image Home 2011 another go at being an actual backup program rather than a pointless waste of time. Surprisingly it actually worked. Just about. It had a funny check box thing with some nonsensical question about hard drive ID or some such other thing. I didn't check it. In my experience checking boxes when you do not know what they do is a bad thing.<br /><br />I now know what this box was asking. It was asking "do you want me not to fuck up your grub when I restore this image?". Oh dear.<br /><br />So, I was left with a non-working grub. Helpfully I managed to sort it all out, by running these commands from a terminal window on a LiveUSB system.<br /><br />First of all I mounted the recalcitrant drive into the LiveUSB environment. That's sounds scary. In practice, it means I clicked on the "Places" menu and selected the anonymous drive that was the same size as my Ubuntu, rather than Home, partition on the disk in question.<br /><br />I then got my terminal window open, and found out where this partition had been mounted by running <br /><br /><pre class="postCode">mount | tail -1</pre><br /><br />This command prints the last line [tail -1] of the output of the command to tell you about all [mount]ed partitions. The partition we are interested in should be the last one, because we only just mounted it.<br /><br />The output I got was along these lines:<br /><br /><pre class="postCode">/dev/[sdxy] on /media/[string of letters and numbers] type ext4 (rw,nosuid,nodev,uhelper=devkit)</pre><br /><br />That told me the name of the partition [/dev/[sdxy]] and where it was mounted [/media/[string of letters and numbers]]. That's all I need to know. The next job was to double check that this was the right partition. To do that I just [l]i[s]ted the contents of the [boot] folder on that partition as follows:<br /><br /><pre class="postCode">ls /media/[string of letters and numbers]/boot</pre><br /><br />This properly displayed the contents of the boot folder, so I knew I was on the right track. The last step was to run the command to fix everything. This was:<br /><br /><pre class="postCode">sudo grub-install --boot-directory=/media/[string of letters and numbers]/boot /dev/[sdx]</pre><br /><br />Please note that I was installing the grub to /dev/[sdx] and NOT /dev/[sdxy], for whatever x and y I got.<br /><br />And then, surprisingly, it worked fine.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com1tag:blogger.com,1999:blog-5718818273328171887.post-32370104982287999542011-11-04T11:59:00.000+00:002011-11-04T11:59:00.401+00:00More Ubuntu Wifi JoyMy neighbours are flooding my house with super strength wifi signals. or so it seems. I can't get a reliable signal in the upstairs room where the desktop machine is located. My routers is already set on the "I hate my neighbours, make my signal as loud as possible", setting and that is no longer doing the business.<br /><br />The obvious solution is to change the channel on which the router is broadcasting. The router I use has an auto setting for this, which I presume means is scans around to find a clear channel and then uses that.<br /><br />This would be an excellent solution if solving IT problems was completely unlike playing fucking Jenga. Yes, this setting change has fixed the reception problem upstairs, but now the netbook refuses to detect the wifi at all. Fucking spiffing.<br /><br />This is a driver and software problem. I know this because I can boot to a USB Key, and it works find. I can dual boot to my LFS installation (see posts passim) and that works fine as well. It's just the installed ubuntu that doesn't fucking work. All I did was change the wifi channel for fucks sake. No amount of cursing and swearing appeared to fix this. <br /><br />I eventually decided to manually install the same network drivers as I have running on the LFS installation. This worked fine. Until the next time I rebooted, when they were overwritten by later drivers, which don't fucking work. I have tried to uninstall the newer drivers, but it's as hard to get rid of the fuckers as it is Michael Meyers. Every time I reboot, the bastards pop into existence once more. Pain in the arse.<br /><br />(Incidentally the fucking useless drivers, on whatever channel my router is now using because they worked find on the old one, are the broadcom hybrid sta drivers 5.100.something.something. The drivers that actually fucking work are version 5.60.48.36)<br /><br />All of this explains why I now have a script on my desktop called "get_my_fucking_network_working.sh" which contains the following commands:<br /><br /><pre class="postCode">cd /tmp<br />cp '/home/[user]/Dropbox/Essential Drivers/Wireless Drivers/hybrid-portsrc-x86_32-v5.60.48.36.tar.gz' .<br />mkdir hybrid_wl <br />cd hybrid_wl <br />tar -xzvf ../hybrid-portsrc-x86_32-v5.60.48.36.tar.gz<br />unzip '/home/[user]/Dropbox/Essential Drivers/Wireless Drivers/sta_5.60.48.36_2.6.33_kernel_patch.zip'<br />patch -p0 < patch<br />unzip '/home/[user]/Dropbox/Essential Drivers/Wireless Drivers/sta_5.60.48.36_2.6.34_multicast_kernel_patch.zip'<br />patch -p0 < patch_hybrid_multicast<br />make clean<br />make<br />sudo rmmod b43 <br />sudo rmmod b44 <br />sudo rmmod b43legacy<br />sudo rmmod wl<br />sudo rmmod ssb <br />sudo rmmod ndiswrapper <br />sudo rmmod lib80211_crypt_tkip<br />sudo rmmod lib80211<br />sudo modprobe lib80211<br />sudo insmod wl</pre><br /><br />I have to run this script every time I boot. Joy of all joys.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-65902501411885478972011-10-14T16:46:00.000+01:002011-10-14T16:46:00.547+01:00EvolutionUnable to retrieve message
Lost connection to Evolution Exchange backend process
Absolute fucking bastard. I hate evolution and the way it connects, or rather doesn't connect, to exchange server, with the passion of a thousand, whatever it is's that makes gamma-ray bursts.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-49764004280813513162011-09-16T16:30:00.001+01:002011-09-16T16:31:01.473+01:00Recently<br />
Recently, and surprisingly, not much has been pissing me off IT wise. The main current niggle is that neither OSX or Windows 7 seem keen to boot from an eSata caddie, whereas Ubuntu just laps it up.<br />
<br />
I do have a bit of a grumble, and warning to those less wary, though. Having purchased an SSD I became something of an evangelist for them. I convinced the boss at work to buy 14 64Gb SSD drives, and I proceeded to replace the whole office's HDD's with them.<br />
<br />
Sadly not a week after delivery we got an email from Kingston, the manufacturer, to advice that there was a teensie problem with the firmware, which has a tiny chance of bricking the drive. So we update all the firmware as suggested.<br />
<br />
Yesterday I sent the third and fourth drives (out of 14) back to Kingston for warranty replacement. They are SV100S2/64G drives, is anyone is interested. When they brick, they really do brick. No detection by the bios, no nothing.<br />
<br />
On the plus side, Kingston's RMA system is very good, and we got the replacements for the first drives through quickly. It's just a shame we have to use it at all.<br />
smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-42905310094828419892011-08-26T13:54:00.001+01:002011-08-26T13:54:00.328+01:00Installing OSXHaving failed to install OSX from the completely genuine (not really) disk image that I had obtained, I opted to shell out a few quid for a completely genuine (yes, actually) install disk. I ebayed a box set with iWork '09 and iLife '11 which came with all sorts of goodies like word processors, video editors and so on. All for £69. Microsoft, are you listening?
<br />
<br />I then had a whole new problem when I tried to boot the system. I got a kernel error. This just froze up the whole machine when I tried to boot. I took out the PCI-E Soundblaster card, and hey presto no more kernel errors. This did not bode well though, as I did want sound eventually. Anyway, ploughing on.
<br />
<br />I then had exactly the same bloody problem as with the previous attempt. It would freeze when starting up the installer. What to do?
<br />
<br />The solution was actually very simple, but hideously complicated at the same time. What I had to do was to change the boot parameters for the OSX Install disk. This is like adding [nomodeset] when booting a Live Ubuntu Image with dodgy video drivers installed.
<br />
<br />The command that I needed to add on were:
<br />
<br /><pre class="postCode">PCIRootUID=1</pre>
<br />Once I did that the system was prepared to boot. However the wifi was not working. This is a pain, because part of the installation procedure allows you to set up you itunes account, and it needs a network connection for this. It WOULD get an internet connection if I booted the installer in safe mode (by adding [-x] as a boot parameter). Which is just a joy.
<br />
<br />The next problem is getting the system to boot without using the iBoot disk. To do so I needed to use the <a href="http://tonymacx86.blogspot.com/2010/04/iboot-multibeast-install-mac-os-x-on.html">multibeast</a> program to install whatever magical stuff it needed to install to get the system to boot from the hard disk. The two essential parts of multibeast are EasyBeast and the System Tools. Apart from that I just selected packages to get my wireless card working. Happily once I rebooted, I got wifi working just fine. My video card was not detected though, and I put this down to getting an install disk that pre-dated (10.6.3) my video card (6850 Ati). So I then upgraded to OSX version 10.6.8. And hurrah! The video started working properly! And the wireless card was fucked.
<br />
<br />Brilliant. I rebooted in safe mode [-x], and the kernel messages flying past tended to suggest the wireless card was detected and working, but that was all academic because the video was now fucked and showing a grey screen only.
<br />
<br />Fantastic. It was at this point, after much searching on the internet, that I <a href="http://tonymacx86.com/viewtopic.php?f=19&t=19098">discovered</a> that I needed to use the further boot parameters:
<br />
<br /><pre class="postCode">max_valid_dma_addr=1024</pre>
<br />to get the wireless card to work with the latest version of OSX. Apparently this has something to do with how much memory your system has. All I needed to do was to pop those parameters into the /Extra/Library/Preferences/SystemConfiguration/com.apple.Boot.plist file:
<br />
<br /><pre class="postCode"><key>Kernel Flags</key>
<br /><string>arch=i386 max_valid_dma_addr=1024</string></pre>
<br />
<br />Having stuck those settings in I now have a machine happily booting OSX 10.6.8, with fully working video up to 1080p resolutions, and with fully working wifi. Sound, no so much. The Soundblaster card I have is working after a fashion, but it is unusably crackly. I need to try a variety of the VoodooHDA drivers to find the best one. Alternatively, I need to try it without the card to see if it will output sound over the HDMI cable from the Graphics card. At one point it had detected that as a possible audio out option, but I couldn't connect it up to a receiver at the time to find out if it was actually working.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-22768529781136945692011-07-29T11:59:00.003+01:002011-08-01T10:50:27.905+01:00Installing Latex and PGFI smugly advised in my last post that you should simply look at my post to identify how to install Latex with PGF Tikz support. Turns out my previous post was as deficient as a very deficient thing on a day of particular deficiency.<br />
<br />
Ahem.<br />
<br />
What you need to do is to grab two files off t'internet. These are the TexLive Latex distribution (this is a biggie) and the PGF add on.<br />
<br />
The TexLive distribution is best downloaded as a single file if you are going to be pissing about trying to repeatedly install it to get the fucker working. It is 2Gb though, so set aside some time for the download. You can find various download options, including torrents, at <a href="http://www.tug.org/texlive/acquire-iso.html">this</a> page. My nearest CTAN mirror is in the UK, so my command to download the DVD Image is:<br />
<br />
<pre class="postCode">cd ~
wget http://mirror.ox.ac.uk/sites/ctan.org/systems/texlive/Images/texlive2011.iso</pre><br />
You can then grab the PGF file by running these commands:<br />
<br />
<pre class="postCode">wget http://sourceforge.net/projects/pgf/files/pgf/version%202.10/pgf_2.10.tds.zip/download
mv download pgf_2.10.tds.zip</pre><br />
However, if it is regularly updated, you would probably just want to go to <a href="http://sourceforge.net/projects/pgf/files/">this</a> page and download the latest version manually.<br />
<br />
To install the software first you need to mount the DVD image. You can do that as follows:<br />
<br />
<pre class="postCode">mkdir ~/texlivedvd
sudo mount -o loop ~/texlive2011.iso ~/texlivedvd</pre><br />
You can then run the graphical installer from TexLive. It requires the perl-tk package, which you can install as follows if you do not already have it:<br />
<br />
<pre class="postCode">sudo apt-get install perl-tk</pre><br />
To then run the installer, you use this command:<br />
<br />
<pre class="postCode">sudo ~/texlivedvd/install-tl -gui perltk</pre><br />
You want to install as comprehensive a system as possible, but you can omit language packs you are not going to use to save some time and space.<br />
<br />
The best idea I have found to avoid permissions bullshit is to install to your home directory, so you would choose an install path like [~/texlive].<br />
<br />
Once installed, you want to tell your system where to find the nice new files, which you can do as follows:<br />
<br />
<pre class="postCode">cat >> ~/.bashrc << "EOF"
PATH=~/texlive/2011/bin/i386-linux:$PATH
export PATH
MANPATH=~/texlive/2011/texmf/doc/man:$MANPATH
INFOPATH=~/texlive/2011/texmf/doc/info:$INFOPATH
export MANPATH
export INFOPATH
EOF
source ~/.bashrc</pre>What that command does is add those lines to your [.bashrc] file. They add the folders containing the TexLive install to your path so that other programs (like ktikz) can find them. The last command just processes the file to prevent you from having to reboot. I am not entirely sure, but I think this may only affect programs run from the command line, because I have been having problems with ktikz if I run it from the desktop icon. Installing PGF is much easier. Just change into the correct TexLive directory, and unpack the archive: <br />
<pre class="postCode">cd ~/texlive/2010/texmf/
sudo unzip ~/pgf_2.10.tds.zip
sudo texhash</pre>The [texhash] command just (I think) lets the rest of TexLive know that this extra stuff has been installed. That's it for PGF. To install ktikz you are going to need a few packages. Install them as follows: <br />
<pre class="postCode">sudo apt-get install build-essential cmake libqt4-dev qt4-dev-tools libpoppler-qt4-dev kdelibs5 kdelibs5-dev khelpcenter4</pre>Basically what you are doing here is installing software that supports KDE applications. If you happen to be running KDE anyway you should have most of this stuff. Once installed, you can grab the ktikz source code, compile and install it using these commands: <br />
<pre class="postCode">cd ~
wget http://www.hackenberger.at/ktikz/ktikz_0.10.tar.gz
tar -xzvf ktikz_0.10.tar.gz
cd ktikz
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ..
make -j2
sudo make install</pre>That should be that. Remember that ktikz needs to load up the PGF packages you want to use. Common ones for me are loaded as follows: <br />
<pre class="postCode">\usetikzlibrary{calc,through, intersections,decorations.text, decorations.pathreplacing}</pre>smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com2tag:blogger.com,1999:blog-5718818273328171887.post-44769096736252224542011-07-22T11:59:00.001+01:002011-07-22T11:59:00.413+01:00Detailed Tikz AnimationsI set out my workflow to create animations using the Tikz graphical language in a previous post. What follows is, as promised, the individual Ubuntu commands needed to actually implement that workflow:<br />
<br />
First of all we need to create a decent image in ktikz. This code works well for this purpose:<br />
<br />
<pre class="postCode">\usetikzlibrary{calc,through, intersections,decorations.text}
\begin{tikzpicture} [scale=3]
\def\myangle{117};
\clip (-1.5,-1.5) rectangle (1.5,1.5);
\coordinate (A) at (0,0);
\coordinate (B) at (1,0);
\node [blue, name path=blue_circle,draw,circle through=(B)] at (A) {};
\draw [black, fill] (A) circle (1pt) node [below] {\tiny centre};
\draw [red, dashed] (A) -- (B);
\path [name path=radius, rotate=\myangle] (A) -- ++(1.5,0);
\draw [red, ->] ($(A)+(0.5,0)$) arc (0:\myangle:0.5cm);
\path [decorate,decoration={raise=-5pt, text along path, text={|\tiny|angle ||}, text align=center, text color=red, reverse path}](0.5,0) arc (0:\myangle:0.5cm);
\draw [name intersections={of=blue_circle and radius, by=C}] [orange, ->] (A) -- (C) node [pos=0.7, sloped, above] {\tiny radius};
\end{tikzpicture}</pre><br />
What does all that do anyway? Well not is not the time for a full PGF/Tikz tutorial, but some illustration may be of use:<br />
<br />
<pre class="postCode">\usetikzlibrary{calc,through, intersections,decorations.text}</pre>That line tells the Tikz software that it is going to need the extra routines mentioned in the squiggly brackets to draw the picture. The libraries mentioned are calc, to enable mathematical routines to be used on co-ordinates (like start here and move two times the number you first thought of to the left), through, to draw objects through other objects, intersections, to let us calculate the point where two lines cross, and decorations.text, which lets us draw text along squiggly lines.<br />
<br />
<pre class="postCode">\begin{tikzpicture} [scale=3]</pre>This [begin]s the code to draw the [tikz] [picture]. The whole picture is at [scale] [3] (where 1 would be normal) so everything is nice and big and clear. <br />
<br />
<pre class="postCode">\def\myangle{117}</pre>This is the key to our whole animation. We are setting a variable which we can then change using sed (aaaargh).<br />
<br />
<pre class="postCode">\clip (-1.5,-1.5) rectangle (-1.5,-1.5);</pre>We tell the system we are only interested in the [rectangle] shaped region designated by the two corners [(-1.5,-1.5)] and [(-1.5,-1.5)], so it doesn't need to draw anything that falls outside that region.<br />
<br />
<pre class="postCode">\coordinate (A) at (0,0);
\coordinate (B) at (1,0);</pre>These commands do the same thing for two different points. We are basically just giving a name to to points [(0,0)] and [(1,0)]. This means that in the future when we want to refer to the points we can just use the letters [A] and [B] instead of remembering the exact positions.<br />
<br />
<pre class="postCode">\node [blue, name path=blue_circle,draw,circle through=(B)] at (A) {};</pre>That is the first really scary command. All it does is draw a circle. Why is it not in the form [draw] a [circle]? Well, we are using the [through] library here, which only works with nodes. So we have to stick a node down [at (A)] with [{}] no text attached to it. This is just a hypothetical point. However, we then [draw] around the node a [circle], coloured [blue], [name]d [blue_circle] which passes [through] the point called [B].<br />
<br />
<pre class="postCode">\draw [black, fill] (A) circle (1pt) node [below] {\tiny centre};</pre>This command DOES just [draw] a [circle]. The circle is coloured [black] and is [fill]ed in, so it looks like a dot. It is centred at point [A], and has a radius of [1pt], which is a tenth of a unit long. We also attach a [node] to the circle (instead of the other way round like last time). This node is positioned [below] point A. The node has the text [centre] attached to it in a [tiny] font size.<br />
<br />
<pre class="postCode">\draw [red, dashed] (A) -- (B);</pre>This is perhaps the least scary command we have seen so far. This [draw]s a [red] [dashed] line ([--]) between the points [A] and [B]. Simples. You can see, though, why we would want to define A and B earlier, since we are using them so often. It would be a pain to have to keep refering to the exact position all the time.<br />
<br />
<pre class="postCode">\path [name path=radius, rotate=\myangle] (A) -- ++(1.5,0);</pre>This command looks quite different. It marks an invisible [path] on the diagram. Why invisible? Well there is no [draw] command. What's the point in this? Wait and see. The path is [name]d [radius]. It is a line ([--]) from the point [A] to a point which is [1.5] units further [++] from the centre in along the x axis and [0] units further from the centre along the y axis. In other words, you take the point A, which is (0,0), and you add [++] 1.5 to the x co-ordinate (the first 0) and 0 to the y co-ordinate (the second 0). All this does is marks an invisible line one and a half units long along the x axis. But that it not all we do! We then [rotate] the line by [\myangle] degrees. If you recall, this was the variable we set right at the beginning. The idea is that when the variable is changed by sed (aaaargh) it will filter down to this instruction as well.<br />
<br />
<pre class="postCode">\draw [red, ->] ($(A)+(0.5,0)$) arc (0:\myangle:0.5cm);</pre>OK, another scary one. This at least [draw]s something. It actually draws an [arc]. The arc is coloured [red] and has a [>] at the end of it. If it had a [>] at the beginning the command would have a [<] in it instead. The arc starts at the point (A) [+] [0.5] units along the x axis. This uses the calc library to work out the starting co-ordinate for the arc from A. To use the calc library you put the calculation itself in between the [$] symbols. Because the calculation returns a bare co-ordinate, you need to have the whole thing in brackets as well.
The arc itself is from [0] degrees on a circle of radius [0.5cm] to [\myangle] degrees (there it is again). This will draw a varyingly large section of a circle that is still centred on the point (A). Why centred on point (A)? Well the zero degree point of the circle is drawn half a unit away from (A) and the radius is half a unit long. So automatically it centres on (A).
<pre class="postCode">\path [decorate,decoration={raise=-5pt, text along path, text={|\tiny|angle ||}, text align=center, text color=red, reverse path}] ($(A)+(0.5,0)$) arc (0:\myangle:0.5cm);</pre>That is fairly horrible. First of all, ignore the bit in square brackets. This command starts by marking another of these invisible paths. The path is actually exactly the same [($(A)+(0.5,0)$) arc (0:\myangle:0.5cm)] as we drew in red last time. Why a new command? Well the bit in square brackets at the beginning does not play well with actually drawing the arc.<br />
<br />
So what's in the square brackets? These commands use the decorations.text library to draw [text] [along] the [path] of the arc. This means the text rounds itself to the arc which is pleasing to look at. The text is [raise]s by [-5pt] or half a unit, from the path itself. It is [align]ed to the [centre] of the path, coloured [red] and [reverse]d (otherwise it would appear upside down). The text itself is [angle] and is in a [tiny] font size. It is a complete mystery to me why these text settings uses a different format to the text settings for nodes, but he ho, that's life.<br />
<br />
<pre class="postCode">\draw [name intersections={of=blue_circle and radius, by=C}] [orange, ->] (A) -- (C) node [pos=0.7, sloped, above] {\tiny radius}</pre>This is our last drawing command. What this does is [draw]s a line [--] between points [A] and [C]. Hang on though, where is point C? Well, look at the bit in square brackets at the very beginning of that. That bit uses the intersections library to [name] the [intersection] [of] the [blue_circle] and the invisible line called [radius]. The name given is [C]. This becomes a co-ordinate we can use just like A and B, although we never need to know exactly what its position is. So we can merrily change the size of the angle, and this command will always know where the radius meets the circle.<br />
<br />
The line we end up drawing is [orange], just to be different, and has a [>] bit on the end of it. It has a node [above] the line, which is [sloped] along the line. The slope works with lines, but not with arcs, which is why we use the decorations library for the arc. The node is [pos]itioned 70% [0.7] of the way to point C. The node contains the text [radius] written in [tiny] font size.<br />
<br />
<pre class="postCode">\end{tikzpicture}</pre>This line [end]s the code to draw the [tikz] [picture].<br />
<br />
OK, good. What does that draw if myangle is 117? It draws this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi87k4_KsJ0t9L0RxOGEnD4rJpzK1HRcNM2Z0jE4ldHdeoz0oG21OQK4Fr7E49A6Aj5M_MiMdOwptDE68WN3jorJg4Xk6zAky34NG1QtyL-d2lpyw8zLEZ6jZkHU7y5m469d244aBlTF04/s1600/offs_example.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi87k4_KsJ0t9L0RxOGEnD4rJpzK1HRcNM2Z0jE4ldHdeoz0oG21OQK4Fr7E49A6Aj5M_MiMdOwptDE68WN3jorJg4Xk6zAky34NG1QtyL-d2lpyw8zLEZ6jZkHU7y5m469d244aBlTF04/s1600/offs_example.png" /></a></div><br />
Hopefully you can see that it is a nice blue circle, with a line drawn at 117 degrees from the horizontal dashed red line, with an arc half the size of the blue circle in red marking the size of the angle.<br />
<br />
Right, how do we animate this? First we need to generate a file which can be read by the Ubuntu command line program [pdflatex]. This has to be a proper Latex file, not just a series of Tikz commands like above. So we need to top and tail our command to generate the proper latex file. We add these commands at the beginning:<br />
<br />
<pre class="postCode">\documentclass{article}
\usepackage{tikz}
\begin{document}</pre><br />
And this command at the end:<br />
<br />
<pre class="postCode">\end{document}</pre><br />
We also need to change the 117 angle to something that we can easily find and replace using sed (aaargh). A random collection of letters should mean that we do not get any false matches. So we end up with:<br />
<br />
<pre class="postCode">\documentclass{article}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{calc,through, intersections,decorations.text}
\begin{tikzpicture} [scale=3]
\def\myangle{xyzzy};
\clip (-1.5,-1.5) rectangle (1.5,1.5);
\coordinate (A) at (0,0);
\coordinate (B) at (1,0);
\node [blue, name path=blue_circle,draw,circle through=(B)] at (A) {};
\draw [black, fill] (A) circle (1pt) node [below] {\tiny centre};
\draw [red, dashed] (A) -- (B);
\path [name path=radius, rotate=\myangle] (A) -- ++(1.5,0);
\draw [red, ->] ($(A)+(0.5,0)$) arc (0:\myangle:0.5cm);
\path [decorate,decoration={raise=-5pt, text along path, text={|\tiny|angle ||}, text align=center, text color=red, reverse path}](0.5,0) arc (0:\myangle:0.5cm);
\draw [name intersections={of=blue_circle and radius, by=C}] [orange, ->] (A) -- (C) node [pos=0.7, sloped, above] {\tiny radius};
\end{tikzpicture}
\end{document}</pre><br />
You copy that code, and paste it into [gedit] and save it to a file called, say, [master_frame.tex] in your [~] home directory. Or you could paste this command into a terminal window, which does the same thing:<br />
<br />
<pre class="postCode">cat > ~/master_frame.tex << "EOF"
\documentclass{article}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{calc,through, intersections,decorations.text}
\begin{tikzpicture} [scale=3]
\def\myangle{xyzzy};
\clip (-1.5,-1.5) rectangle (1.5,1.5);
\coordinate (A) at (0,0);
\coordinate (B) at (1,0);
\node [blue, name path=blue_circle,draw,circle through=(B)] at (A) {};
\draw [black, fill] (A) circle (1pt) node [below] {\tiny centre};
\draw [red, dashed] (A) -- (B);
\path [name path=radius, rotate=\myangle] (A) -- ++(1.5,0);
\draw [red, ->] ($(A)+(0.5,0)$) arc (0:\myangle:0.5cm);
\path [decorate,decoration={raise=-5pt, text along path, text={|\tiny|angle ||}, text align=center, text color=red, reverse path}](0.5,0) arc (0:\myangle:0.5cm);
\draw [name intersections={of=blue_circle and radius, by=C}] [orange, ->] (A) -- (C) node [pos=0.7, sloped, above] {\tiny radius};
\end{tikzpicture}
\end{document}
EOF</pre><br />
When you run [pdflatex] it takes the master_frame.tex file and turns it into a pdf document. This is not what we want. We want a series of jpegs. We also do not want an A4 page, which is what [pdflatex] is going to give us. So what we do is convert a test sample, work out what crop we need to apply (to get rid of the unnecessary areas) and note that down somewhere. If we simply run pdflatex on our master frame it is going to fail, because it will try and draw an angle of size xyzzy, which makes no sense. So first lets create our test frame:<br />
<br />
<pre class="postCode">sed 's/{xyzzy}/{'117'}/' ~/master_frame.tex > ~/test.tex</pre>And we now generate the pdf file from it:<br />
<br />
<pre class="postCode">pdflatex ~/test.tex</pre><br />
That should work. It it doesn't, something has gone wrong with your installation of latex and pgf. Go and look at my post on how to do that to make sure you have covered all the bases. To display the pdf you can open it in any pdf viewer - it is just a pdf. However, we need a jpeg, so let's convert it:<br />
<br />
<pre class="postCode">convert -density 300 test.pdf test.jpg</pre><br />
The [convert] command makes sense, but what about the [density 300] stuff? Well the pdf we have made is of <a href="http://en.wikipedia.org/wiki/Vector_graphics">vector graphics</a> which can scale without losing detail to any resolution you like. A jpeg image is essentially <a href="http://en.wikipedia.org/wiki/Raster_graphics">raster graphics</a> which has a fixed resolution. To convert vector to raster you need to tell the vector image what resolution to scale to. here we have chosen [300] dpi.<br />
<br />
We now need to get our cropping parameters. To get these run the [display] command (from the imagemagick package I think):<br />
<br />
<pre class="postCode">display test.jpg</pre><br />
When the image opens, left click anywhere on it to bring up a menu. Select the Transform drop down menu and then click on crop. This lets you draw a box around the image. While you are doing this, look in the top left corner of the display window. You will see numbers changing as you draw your box. When you are satisfied that it fits the image and no more, note down those numbers AND symbols. For me they were [724x724+789+692]. Now close the display window. We are done with it. If it fights back, click on your terminal window and hit [CTRL+C] to shut it down. Now let's test out cropping parameters by re-doing a conversion to jpeg:<br />
<br />
<pre class="postCode">convert -density 300 -crop 724x724+789+692 test.pdf test.jpg</pre><br />
Note that the numbers and symbols we noted in the last step just get pasted in here, after the [crop] command. Nice and logical. If you now do the [display test.jpg] command again, you should find a nicely cropped picture of our diagram. If not, go back and check your cropping parameters are correct.<br />
<br />
We are now going to generate a whole lot of [.tex] files - one for each frame of the animation we are going to make. It would probably be best to put these in their own directory:<br />
<br />
<pre class="postCode">mkdir ~/frames</pre><br />
You can now generate all your frames by running this command:<br />
<br />
<pre class="postCode">for angle in {1..360}; do sed 's/{xyzzy}/{'$angle'}/' ~/master_frame.tex > ~/frames/$angle.tex; echo $angle; done</pre><br />
That looks pretty horrendous, doesn't it? Well, what is happening here is a loop. We define a variable at the beginning of the command called [angle]. We then run through the hold command setting the variable to every number from [1] to [..] [360]. The variable is then passed to the next section of the command which [do]es the [sed] (aaargh) command on the [~/master_frame.tex] file. The sed command spits out the file, but changes every instance of the text [{xyzzy}] to the same squiggly brackets but with the value assigned to angle in between the brackets. This sets our angle size for the frame. The result from the sed command is sent [>] to a [.tex] file in the [~/frames/] folder named after the size of angle in the file. The command then reports [echo] which frame it has completed, and [done] goes back to the beginning for a new number.<br />
<br />
We now need to move into the frames folder for the next bit:<br />
<br />
<pre class="postCode">cd ~/frames</pre><br />
Now if you look at the contents of the frames directory they will not all be three digit file names, meaning they count up from 1 to 99 to 360. The leading zeros are missing, i.e. they are not 001 to 099 to 360 and our system will break. You can fix that, by adding the leading zeros with these commands:<br />
<br />
<pre class="postCode">for file in ?.tex; do cat $file > 00$file; rm $file; echo $file; done
for file in ??.tex; do cat $file > 0$file; rm $file; echo $file; done</pre><br />
Why could we not just generate angles from 001..360? If we do that pdflatex thinks we are using base 8, or octal numbers, and misses out every ninth and tenth frame. We can now do the mass generation of all the pdf files. This will take a while. The command is as follows:<br />
<br />
<pre class="postCode">for file in ???.tex; do pdflatex -interaction=batchmode $file; echo $file; done</pre><br />
This is another loop, that picks up every [.tex] file with three characters in its name, and sticks it into the [pdflatex] command. Next we need to use our cropping details to produce the jpeg files:<br />
<br />
<pre class="postCode">for file in *.pdf; do convert -density 300 -crop 724x724+789+692 $file ${file%.???}.jpg; echo $file; done</pre><br />
This just uses a similar loop to the last command. It applies to all the [.pdf] files in the folder - so make sure that you started with an empty one. The percentage symbol is clever, it deletes the extension and replaces it with [.jpg] so the output of the command is a whole lot of [.jpg] files with the same name as the [.pdf] files which generated them. If we are really clever, we can just duplicate all our frames in reverse order to make the animation reverse when it gets to the end. This creates an unending loop, but is not strictly necessary with our animation here which is essentially circular.<br />
<br />
<pre class="postCode">marker=360; for file in *.jpg; do frame=$(($marker+360)); cp $file $frame.jpg; marker=$(($marker -1)); echo $marker; done</pre><br />
That is absolutely a nightmare. That it does is set a complicated loop in place counting back from 360 to 1. Why? Well we want the 360 frames we have already to be played in reverse. So we want 361 to be the same as 360, and 362 to be 359 and so on down to 1 being 720. So we start at 360 and count back. The [do] command sets the [frame] variable to be the marker PLUS 360. So when the marker is 360 it is 720. However, the [file] variable is going through the directory in numerical order. So the next command [c]o[p]ies the [file] to the frame number. The loop then reduces the marker by one and goes back to the beginning. The sequence looks like this:<br />
<br />
Marker-File-Maths-Frame<br />
360-1-(360+360)-720<br />
359-2-(359+360)-719<br />
358-3-(358+360)-718<br />
...<br />
2-359-(2+360)-362<br />
1-360-(1+360)-361<br />
<br />
It is a bit of a wrestle, but it gets there.<br />
<br />
Now we have all our jpeg frames, we can use [ffmpeg] to compress them into an mp4 video file like so:<br />
<br />
<pre class="postCode">ffmpeg -r 25 -b 2500k -i %3d.jpg -pass 1 -y circle.mp4 && ffmpeg -r 25 -b 2500k -i %3d.jpg -pass 2 -y circle.mp4</pre><br />
That's another horror, but it breaks down like this: It uses the [ffmpeg] command set at a f[r]ame rate of [25] per second, and a [b]itrate of [2500k] per second, and takes its [i]nput as every [.jpg] file in the current folder with a three digit name. It runs a first [1] [pass] through the file to see where best to use its bitrate and saves the output to [circle.mp4] automatically answering [y]es to any question about overwriting that file. It then immediately [&&] runs a second [2] [pass] with the same input and settings to produce the final output in the file called [circle.mp4].<br />
<br />
You can now view your creation by running:<br />
<br />
<pre class="postCode">mplayer circle.mp4 -loop 0</pre><br />
It should look like this:<br />
<br />
<embed allowfullscreen="true" allowscriptaccess="always" height="480" src="http://www.youtube.com/v/znzJnYqKIyQ?hl=en&fs=1&autoplay=1&loop=1" type="application/x-shockwave-flash" width="480"></embed><br />
<br />
Once you have done it once, it is useful to be able to tweak one entry in the master frame file and then run all the commands that follow automatically. You can do that with this command block. It first cleans out the ~/frames folder of everything, and then runs all the commands above, one after the other:<br />
<br />
<pre class="postCode">cd ~/frames && rm * && cd ~ && for angle in {1..360}; do sed 's/{xyzzy}/{'$angle'}/' ~/master_frame.tex > ~/frames/$angle.tex; echo $angle; done && cd ~/frames && for file in ?.tex; do cat $file > 00$file; rm $file; echo $file; done && for file in ??.tex; do cat $file > 0$file; rm $file; echo $file; done && for file in ???.tex; do pdflatex -interaction=batchmode $file; echo $file; done && for file in *.pdf; do convert -density 300 -crop 724x724+789+692 $file ${file%.???}.jpg; echo $file; done && marker=360; for file in *.jpg; do frame=$(($marker+360)); cp $file $frame.jpg; marker=$(($marker -1)); echo $marker; done && ffmpeg -r 25 -b 2500k -i %3d.jpg -pass 1 -y circle.mp4 && ffmpeg -r 25 -b 2500k -i %3d.jpg -pass 2 -y circle.mp4 && mplayer circle.mp4 -loop 0</pre>smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com5tag:blogger.com,1999:blog-5718818273328171887.post-88081651971262223592011-07-15T11:59:00.000+01:002011-07-21T12:39:43.620+01:00Installing OSX on a HackintoshBecause I don't have enough grey hairs I have decided to try to install OSX on my Intel PC Hardware. Couple of reasons for this. One, I have an iPhone and and iPad and I want to see what the fuss is about Apple Personal Computing without selling a kidney to buy their hardware. Two, it's a technical challenge innit.<br />
<br />
I HAVE managed to install OSX on an AMD Frankenmachine, and it seemed to work OK, but is very slow. The graphics card does not support any of the Steam Games I have for OSX (Portal et al). If I put a bigger graphics card in the Frankentosh the PSU cries enough and shuts down.<br />
<br />
<br />So I have decided to do it properly this time. I started off with a completely genuine (not really) image of Snow Leopard. I wanted to install it onto a USB Key so I could boot from that. OSX didn't like the DVD Image. It refused to write it to the USB Key. It said it needed to be "scanned" and then refused to scan it.<br />
<br />
I managed to find a useful OSX command which forces the machine to write the image without scanning it, and it is thus:<br />
<br />
<br />
<pre class="postCode">sudo asr -noverify -source "/[location of image]/Mac OS X Install DVD.dmg" -target "/Volumes/[mount point of USB Key]"</pre>
<br />
This did at least manage to write the image to the USB Key, and it does seem to boot when using the <a href="http://tonymacx86.blogspot.com/2010/04/iboot-multibeast-install-mac-os-x-on.html">iboot</a> system. However it failed miserably at the bit which says "When you get to the installation screen, open Utilities/Disk Utility.". It doesn't do anything, it just sits there spinning a circle for fecking hours. Ah well.<br />
<br />
This maybe because I have failed to follow all the previous instructions about removing all non essential hardware from the machine, resulting in it being festooned with TV Cards, USB Peripherals and so on. Or it could be because the completely genuine (not really) DVD Image I was using is not really completely genuine.<br />
<br />
So I have shelled out for a boxed set of Snow Leopard, iLife '11 and iWork '09, and I will try this again with the genuine kit when it arrives.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-76144933426813149982011-07-08T15:06:00.000+01:002011-07-08T15:06:00.784+01:00Animating TEXShort post today but I wanted to set out my work-flow used when generating animated tikz diagrams.<br />
<br />
1) Start with your tikz diagram. Instead of fixed values, define variables to be used in their place:<br />
<br />
<pre class="postCode">\def\angle1{x}</pre><br />
2) Run the sed (aaargh) command on that master file using some kind of loop which changes the value {x} each time through and then spits out the results into numerical .tex files.<br />
<br />
2.5) rename all the .tex files to make sure they have the appropriate amount of trailing zeros.<br />
<br />
3) Run PDF Latex on each individual .tex file to get a pdf.<br />
<br />
4) Convert the PDF to jpg using an appropriate DPI and cropping factor - will vary for each master diagram, so generate a test first and id the correct cropping settings. The display [name].jpg command is very useful for this.<br />
<br />
4.5) If desired run another loop to copy all the files in such a way as the animation reverses to create a continuous loop.<br />
<br />
5) Take all the jpg files and pipe them into ffmpeg to compress to whatever you want, but x264 is useful. Animated gif may be attractive but ffmpeg doesn't like it.<br />
<br />
Job done. More details and exact ubuntu commands to come.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-53399293929500871792011-07-01T11:59:00.061+01:002011-07-01T11:59:00.826+01:00Firefox 5 from SourceThese are the instructions for installing FF5 from source on the LFS system I built in earlier posts, assuming that you have not installed any version.<br />
<br />
<pre class="postCode">wget http://ftp.gnome.org/pub/gnome/sources/libIDL/0.8/libIDL-0.8.14.tar.bz2
tar -xjvf /sources/extras/libIDL-0.8.14.tar.bz2
cd libIDL-0.8.14
./configure --prefix=/usr &&
make
make install
cd ..
rm -rvf libIDL-0.8.14</pre><br />
<pre class="postCode">wget http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tar.bz2
wget http://www.linuxfromscratch.org/patches/blfs/svn/Python-2.6.4-bdb_4.8-1.patch
wget http://docs.python.org/ftp/python/doc/2.6/python-2.6-docs-html.tar.bz2
tar -xjvf /sources/extras/Python-2.6.4.tar.bz2
cd Python-2.6.4
sed -i "s/ndbm_libs = \[\]/ndbm_libs = ['gdbm', 'gdbm_compat']/" setup.py
patch -Np1 -i /sources/extras/Python-2.6.4-bdb_4.8-1.patch
./configure --prefix=/usr --enable-shared
make
make test
make install
chmod -v 755 /usr/lib/libpython2.6.so.1.0
install -v -m755 -d /usr/share/doc/Python-2.6.4/html
tar --strip-components=1 --no-same-owner --no-same-permissions -C /usr/share/doc/Python-2.6.4/html -xvf /sources/extras/python-2.6-docs-html.tar.bz2
cat >> /etc/profile << "EOF"
export PYTHONDOCS=/usr/share/doc/Python-2.6.4/html
EOF
cd ..
rm -rvf Python-2.6.4</pre>
<pre class="postCode">wget http://www.tortall.net/projects/yasm/releases/yasm-1.0.1.tar.gz
cd /dev/shm
tar -xzvf /sources/extras/yasm-1.0.1.tar.gz
cd yasm-1.0.1
CC="gcc -fPIC" ./configure --prefix=/usr
time make $CORES_TO_USE
make install</pre><pre class="postCode">wget http://cairographics.org/releases/cairo-1.10.2.tar.gz
cd /dev/shm
tar -xzvf /sources/desktop/cairo-1.10.2.tar.gz
cd cairo-1.10.2
./configure --prefix=/usr --enable-tee=yes
make $CORES_TO_USE
make install
cd ..
rm -rvf cairo-1.10.2</pre><pre class="postCode">wget ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/5.0/source/firefox-5.0.source.tar.bz2
tar -xjvf /sources/extras/firefox-5.0.source.tar.bz2
cd moz*
cat > .mozconfig << "EOF"
ac_add_options --enable-application=browser
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../firefox-build
mk_add_options MOZ_MAKE_FLAGS="-j2"
ac_add_options --prefix=/opt/firefox5
ac_add_options --enable-optimize
ac_add_options --enable-system-cairo
ac_add_options --with-system-jpeg
#ac_add_options --with-system-png
ac_add_options --with-pthreads
ac_add_options --with-system-zlib
ac_add_options --disable-accessibility
ac_add_options --disable-crashreporter
ac_add_options --disable-dbus
ac_add_options --disable-gnomevfs
ac_add_options --disable-necko-wifi
ac_add_options --disable-installer
ac_add_options --disable-javaxpcom
ac_add_options --disable-tests
ac_add_options --disable-updater
ac_add_options --disable-libnotify
ac_add_options --enable-official-branding
ac_add_options --enable-safe-browsing
ac_add_options --enable-strip
EOF</pre>
<pre class="postCode">time make -f client.mk build
make -f client.mk install
cd ..
rm -rvf moz*</pre><pre class="postCode">cat >> /etc/ld.so.conf << "EOF"
# Extra Path so Firefox's libraries can be used by Flash10
/opt/firefox5/lib/firefox-5.0
# End of Extra Path.
EOF</pre>
<pre class="postCode">wget http://curl.haxx.se/download/curl-7.20.0.tar.bz2
cd /dev/shm
tar -xjvf /sources/extras/curl-7.20.0.tar.bz2
cd curl-7.20.0
./configure --prefix=/usr
make $CORES_TO_USE
make install
find docs -name "Makefile*" -o -name "*.1" -o -name "*.3" | xargs rm
install -v -d -m755 /usr/share/doc/curl-7.20.0
cp -v -R docs/* /usr/share/doc/curl-7.20.0</pre><pre class="postCode">wget http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_10_linux.tar.gz
tar -xzvf install_flash_player_10_linux.tar.gz
mkdir -v /opt/firefox5/lib/firefox-5.0/plugins
cp -v libflashplayer.so /opt/firefox5/lib/firefox-5.0/plugins
cp -v ./usr/bin/flash-player-properties /usr/bin/</pre>Add this to the openbox menu.xml file:
<pre class="postCode"><item label="flash player properties">
<action name="Execute">
<execute>
/usr/bin/flash-player-properties
</execute>
</action>
</item></pre>Download Java from <a href="https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=jdk-6u21-oth-JPR@CDS-CDS_Developer">here</a>.
OR:
<pre class="postCode">wget http://download.oracle.com/otn-pub/java/jdk/6u26-b03/jdk-6u26-linux-i586.bin
mv jdk-6u26-linux-i586.bin* jdk-6u26-linux-i586.bin
chmod +x /sources/extras/jdk-6u26-linux-i586.bin
cd /dev/shm
/sources/extras/jdk-6u26-linux-i586.bin
cd jdk1.6.0_26
install -v -m755 -d /opt/jdk-6u26
mv -v * /opt/jdk-6u26
chown -v -R root:root /opt/jdk-6u26
ln -v -sf xawt/libmawt.so /opt/jdk-6u26/jre/lib/i386/
cd ..
sed -i 's@XINERAMA@FAKEEXTN@g' /opt/jdk-6u26/jre/lib/i386/xawt/libmawt.so
ln -v -nsf jdk-6u26 /opt/jdk
ln -sv /opt/jdk/jre/lib/i386/libnpjp2.so /opt/firefox5/lib/firefox-5.0/plugins</pre><pre class="postCode">cat >> /etc/profile.d/30-jdk.sh << "EOF"
# Begin /etc/profile.d/30-jdk.sh
# Set JAVA_HOME directory
JAVA_HOME=/opt/jdk
# Adjust PATH
pathappend ${JAVA_HOME}/bin PATH
# Auto Java CLASSPATH
# Copy jar files to, or create symlinks in this directory
AUTO_CLASSPATH_DIR=/usr/lib/classpath
pathprepend . CLASSPATH
for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
pathappend $dir CLASSPATH
done
export JAVA_HOME CLASSPATH
unset AUTO_CLASSPATH_DIR
unset dir
# End /etc/profile.d/30-jdk.sh
EOF</pre><pre class="postCode">source /etc/profile</pre>
If you have installed openoffice:
<pre class="postCode">ln -sv /opt/openoffice-3.2.1/program/libnpsoplugin.so /opt/firefox5/lib/firefox-5.0/plugins</pre>smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-74185659671530401292011-06-24T11:59:00.003+01:002011-07-21T12:42:05.948+01:00Parameter SubstitutionThat is a bloody boring title for a blog post. AAAAAnyway, it means that when you are farting around with variables holding filenames in bash scripts, or single commands, you may want to edit the file name. For instance, remember in the PDF compression script we strip the file extension off the filename and add .pdf to create the output filename. Very useful.<br />
<br />
This post was prompted by trying to compress a 1000+ page pdf document. The pain was that the pdfimage command only switches to 4 digit file names at 1000. So for 1-999 you get 001 etc instead of 0001. This has the potential to screw everything up when you come to compile your final pdf. You do not want page 1000 to be before page 200, just because it starts with a lower number.<br />
<br />
So how do we insert the missing 0?<br />
<br />
<pre class="postCode">for file in imageroot-???.*; do mv $file imageroot-0${file#imageroot-}; echo $file; done</pre>
smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-20894911911314953812011-06-17T11:59:00.000+01:002011-06-17T11:59:00.806+01:00GnuplotIf you are using the last LTS of Ubuntu, then your Gnuplot version will be out of date. You can't get fancy stuff like transparent surface plots. To download and install the latest version you need to run these commands:<br />
<br />
<pre class="postCode">cvs -d:pserver:anonymous@gnuplot.cvs.sourceforge.net:/cvsroot/gnuplot login
cvs -z3 -d:pserver:anonymous@gnuplot.cvs.sourceforge.net:/cvsroot/gnuplot co -P gnuplot
cd gnuplot
./prepare
./configure --with-readline=gnu
make
sudo make install</pre><br />
This will break your Ubuntu packaging system though - so be careful.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-42500389251154764312011-06-10T11:59:00.011+01:002011-06-10T11:59:00.429+01:00KtikzIf you are doing quite a bit of Latex work with the Tikz graphical librarys then you will probably like to use a wysiwyg program so that you can tweak your wonderful creations. Such a program for Ubuntu is ktikz.<br />
<br />
To install it you need to install the latest version of TexLive. If using Ubuntu Natty or later then I think you get the latest version by:<br />
<br />
<pre class="postCode">sudo apt-get install texlive</pre><br />
With Maverick or earlier, you need to install the latest version manually to get all the bells and whistles:<br />
<br />
<pre class="postCode">wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar -xzvf install-tl-unx.tar.gz
cd install-tl-20110526/
sudo ./install-tl</pre><br />
The install will then run through - takes about an hour to download the stuff. You can also download the DVD image via <a href="http://www.tug.org/texlive/texlive2010.torrent">torrent</a>, which would be a good way to have a backup for quick reinstall. Once installed, you need to make sure you update your path:<br />
<br />
<pre class="postCode">PATH=/usr/local/texlive/2010/bin/i386-linux:$PATH</pre><br />
Installing the ktikz software is a bit easier. You just run the following commands to grab the dependencies in case you do not have them. BTW this is for Lucid only. There isn't a package for Maverick or Natty yet, but you could roll your own.<br />
<br />
<pre class="postCode">sudo apt-get install build-essential cmake libqt4-dev qt4-dev-tools libpoppler-qt4-dev kdelibs5-dev pgf preview-latex-style
wget http://www.hackenberger.at/ktikz/ubuntu_lucid/ktikz_0.10-1_i386.deb
sudo dkpg -i ./ktikz_0.10-1_i386.deb</pre><br />
<br />
You may need to preface some of the scripts with libraries to load:<br />
<br />
<pre class="postCode">\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\usetikzlibrary{through}</pre>smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-14374171451438742982011-06-03T11:59:00.000+01:002011-06-03T11:59:00.646+01:00Compressing PDF filesIf you have got a hold of a PDF file which comprises lots and lots of images and nothing else it may well be huge if the images are not compressed. You can fix this at the command line in ubuntu. You do this as follows:<br />
<br />
You will need:<br />
<br />
<pre class="postCode">sudo apt-get install pdftk imagemagik</pre><br />
First you need to unpack the images from the PDF. Start this from a blank directory because we are going to automatically do things to all the files in this directory with a specific name.<br />
<br />
<pre class="postCode">pdfimages /path/to/filename.pdf imageroot</pre><br />
You get lots of:<br />
<br />
<pre class="postCode">imageroot-[three digit number].somethings</pre><br />
These somethings are either a ppm or a pbm filetype. These are very, very, basic graphic image dumps - like a bmp image. One is for texty stuff, and the other is for imagy stuff. I therefore use these filetypes as wildcards in the next command, but you would need to replace these with the correct image types that are generated by this command if your results are different. Such as if you choose to try and output jpeg files by using the [-j] option.<br />
<br />
Next you compress each image to a pdf, one page long. This will not work properly if you did not start with a blank directory because we are going to command changes to be made to EVERY file in this directory with the extensions produced by the last command.<br />
<br />
For colour sources, you need jpg compression:<br />
<br />
<pre class="postCode">for file in *.{ppm,pbm}; do convert -compress jpeg -quality 50 $file ${file%.???}.pdf; echo $file; done</pre><br />
That applies the commands between the [do] and the [done] bits to all [file]s with the extension of either [{,}] [ppm] or [pbm]. The commands in the middle [convert] the image files into pdf files using [jpeg] [compress]ion with [quality] [50]%. You can obviously change the quality percentage to get the best results depending on your source material. The result is sent to a file whose name is constructed from the input [file] variable [$] less whatever three letter [???] extension [.] it has, plus the characters [.pdf]. The next bit just prints out the last filename processed so you can make sure it is doing something if you are processing LOTS of files.<br />
<br />
For black and white sources you need fax compression:<br />
<br />
<pre class="postCode">for file in *.{ppm,pbm}; do convert -alpha off -monochrome -compress Group4 -quality 100 $file ${file%.???}.pdf; echo $file; done</pre><br />
This is basically the same approach as last time, just with a change to the [convert] command. This time the [jpeg] stuff is gone, and we have the [-alpha off -monochrome -compress Group4 -quality 100] bit instead. I can't get the quality setting to do anything here. The Group4 refers to the particular brand of fax compression which is applied.<br />
<br />
Finally we take all of those individual pdfs and we combine them into one big one. Again, this will not work properly if you did not start with a blank directory. This copies EVERY pdf which matches the search string (the imageroot*.pdf bit where * means anything) into the final pdf. The classic error here would be making your image root name too similar to your original pdf name, with the result that the built pdf incorporates the original - hardly reducing the file size!<br />
<br />
<pre class="postCode">pdftk imageroot*.pdf cat output name_of_final_file.pdf</pre><br />
That uses the [pdf] [t]ool[k]it program to take every [*] file that starts with [imageroot] and ends with [.pdf] and con[cat]enates them into the [output] file named [name_of_final_file.pdf].<br />
<br />
Simples.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-26516129222353549812011-05-27T11:59:00.047+01:002011-05-27T11:59:00.224+01:00Testing Natty on Nvidia HardwareThe BIG THING about the Natty version of Ubuntu is that it comes with a prettified GUI. It has a pop out panel on the left hand side of the screen containing your launcher icons. This is absolutely NOT the same as Windows 7's task bar icons OR OSX's panel'o'icons because both of them are on the BOTTOM of the screen. Ahem.<br />
<br />
Want to see what this looks like with the live cd? Have nvidia hardware? Tough shit. The nvidia driver installed on the live cd is a) open source (yay!) and b) does not support all the bells and whistles that this flashy new panel needs (boo!). So you will have to install the proper nvidia drivers. Which means rebooting. Which is pointless on a live cd.<br />
<br />
Oh dear. This is going to be a pain in the fucking arse isn't it? Yes, yes it is.<br />
<br />
For a start a couple of useful commands for this kind of fiddling are:<br />
<br />
<pre class="postCode">sudo service gdm stop</pre><br />
This stops dead the GUI leaving you to happily fiddle with graphics driver settings.<br />
<br />
To restart the GUI you would just restart the gdm service yes? Yes.<br />
<br />
<pre class="postCode">sudo service gdm start</pre><br />
OK. So we have shut down the GUI. Now we want to download the nvidia drivers. I am presuming you have internet access from the LiveCD. If not, see my earlier posts on that hilarious situation. Download the drivers with this command:<br />
<br />
<pre class="postCode">wget http://uk.download.nvidia.com/XFree86/Linux-x86/270.41.19/NVIDIA-Linux-x86-270.41.19.run</pre><br />
Make the driver file executable:<br />
<br />
<pre class="postCode">sudo chmod +x NVIDIA-Linux-x86-270.41.19.run</pre><br />
And run it:<br />
<br />
<pre class="postCode">./NVIDIA-Linux-x86-270.41.19.run</pre><br />
You will now get some whining messages about nouveau bollicksing up the whole plan. This is the open source nvidia software we are trying to replace. So lets just [r]e[m]ove the nouveau [mod]ule:<br />
<br />
<pre class="postCode">rmmod nouveau</pre><br />
Doesn't fucking work.<br />
<br />
<pre class="postCode">sudo rmmod nouveau</pre><br />
Still doesn't fucking work. Google.<br />
<br />
<pre class="postCode">sudo rmmod --force nouveau</pre><br />
Oh for fucks sake. It still doesn't fucking work. It turns out the nouveau driver is deeply embedded in the OS. It ain't possible to just remove it. It has taken over something called the framebuffer. Without getting horrendously technical (shorthand for I have no fucking clue) this is the thing that gives you the text command line that you are using. So ubuntu is trying to stop you doing the I.T. equivalent of sawing off the branch you are standing on. If you turn off the framebuffer you will get a blank screen. Which is not great as far as user interfaces go, but still probably a better experience than Windows ME.<br />
<br />
At this point you have two choices. First you can disable the in-depth use of nouveau, which will then allow you to remove it without fucking up the framebuffer. This needs to be done at boot time, each and every time you boot the LiveCD. Secondly, you can write a script that forces ubuntu to remove nouveau (fucking up the framebuffer in the process) and then immediately installs the nvidia drivers with the least input necessary.<br />
<br />
The benefit with the first option is that you never get left with a blank screen, but it is a pain. The benefit with the second option is that it can all be scripted, but leaves you with a blank screen for several minutes while it installs the drivers. If it fails for any reason during the blank screen period, you're fucked.<br />
<br />
So, option one first. Copy your downloaded driver file somewhere safe (USB Key). Or just download it again next time, what do I care. If you are using a LiveCD, reboot your LiveCD. When it starts back up it flashes up a symbol of a keyboard and a hand. Hit any key at that stage and you will get a boot menu. You want to chose to Test Ubuntu. You then want to hit F6 for other boot options.<br />
<br />
If you are using the LiveCD image from a USB Key via UNetbootin, then just highlight the "Test..." option and hit the tab key to edit the boot command.<br />
<br />
You should now be able to edit the boot command (it is a long string of options. See the joys of grub elsewhere in this blog for info on what this does). At the end of the boot command type in:<br />
<br />
<pre class="postCode">nomodeset</pre><br />
Now complete the boot as normal. Copy back, or re-download the nvidia driver to the home directory. Now, hit CTRL+ALT+F1 to get to a text interface, and make sure the driver file is executable:<br />
<br />
<pre class="postCode">sudo chmod +x NVIDIA-Linux-x86-270.41.19.run</pre><br />
:and shut down the GUI:<br />
<br />
<pre class="postCode">sudo service gdm stop</pre><br />
:and run:<br />
<br />
<pre class="postCode">sudo rmmod nouveau</pre><br />
It should now work. You can now install the driver:<br />
<br />
<pre class="postCode">sudo ./NVIDIA-Linux-x86-270.41.19.run</pre><br />
And it should eventually install happily. Answer the questions sensibly, ignoring any errors. Then just run this command to restart the GUI:<br />
<br />
<pre class="postCode">sudo service gdm start</pre><br />
Bask in the awe of the flashy bar.<br />
<br />
Option 2 is handled like this. Boot as normal - no need for any fancy boot commands. Copy back, or re-download the nvidia driver to the home directory. Open a terminal window and paste this code into it to set up your script:<br />
<br />
<pre class="postCode">sudo cat > inst_nv.sh << "EOF"
echo 0 > /sys/class/vtconsole/vtcon1/bind
rmmod nouveau
/etc/init.d/consolefont restart
rmmod ttm
rmmod drm_kms_helper
rmmod drm
chmod +x ./NVIDIA-Linux-x86-270.41.19.run
./NVIDIA-Linux-x86-270.41.19.run --accept-license --no-questions --no-nouveau-check --run-nvidia-xconfig --ui=none
service gdm start
EOF
chmod +x ./inst_nv.sh
</pre><br />
(What does this script do? Well, the first line is a command which disconnects the frame buffer from the graphics driver. I think. The second command removes the graphics driver. The third command attempts, but I think fails, to restore some sort of text interface. The next three commands remove more unneeded modules connected with the graphics driver. The [chmod] command makes sure that the nvidia file is executable, and the command after that executes it. All the options added onto the execution of the driver package are designed so that it should just install without asking any stupid questions which you will be unable to read. The last command restarts the GUI.)<br />
<br />
You now shut down gdm as before from the CTRL+ALT+F1 text interface:<br />
<br />
<pre class="postCode">sudo service gdm stop</pre><br />
:and run the script from the text command prompt:<br />
<br />
<pre class="postCode">sudo ./inst_nv.sh</pre><br />
Your screen will go blank. Your cd/dvd drive will hopefully spin up and down. After 5 minutes or so, hopefully, you will get a GUI. If it doesn't work, reboot and try option 1.<br />
<br />
And hey fucking presto, there is the snazzy new bar.<br />
<br />
Admittedly, after all that, it may be a touch underwhelming.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com4tag:blogger.com,1999:blog-5718818273328171887.post-83992767366502636852011-05-20T11:59:00.000+01:002011-05-20T11:59:00.655+01:00Manually Add DNS ServersMy work machine is an Ubuntu machine on a Microsoft Small Business Server network. It gets all of its network settings by way of DHCP from the SBS Server. Sometimes the SBS Server has to be restarted. Most of the software I use can run offline, so that is nor normally a problem.<br />
<br />
What is a problem is that I immediately lose internet access because the SBS Server operates as a [DNS]. This is frustrating. Helpfully, Ubuntu has an option to manually add some extra DNS's which SHOULD take over the burden from the SBS Server if it goes down.<br />
<br />
To achieve this (in Lucid), go System -> Administration -> Network.<br />
<br />
From the program that pops up, select the Network Device drop down menu. Choose your network device. This will be ethX if you are connected by a wired connection. Then click on the Configure button next to the device name. From the new window that pops up, choose the DNS tab. You then need to click on the button between the Help and Close buttons at the bottom of the window, and putin your admin password to allow you to change the settings.<br />
<br />
Now, just click on Add, and type in your new DNS IP address.<br />
<br />
Hopefully this change means that the next time the server goes offline, I can still use the internet.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-39537109323149878882011-05-13T11:59:00.006+01:002011-05-13T19:02:13.739+01:00Testing and Fixing SD CardsYou can test for badblocks in a [n]on-destructive way by running:<br />
<br />
<pre class="postCode">sudo badblocks -snp # /dev/sdxy</pre><br />
where # is the number of passes to run. This report[s] the progress to you as it runs.<br />
<br />
You can then run:<br />
<br />
<pre class="postCode">sudo fsck.vfat /dev/sdxy -a -w</pre><br />
This [a]utomatically fixes problems by [w]riting changes to the disk. Any dodgy files you had will be renamed.<br />
<br />
Finally, if you have cleared the disk of any remaining stuff, you can run a deep [w]rite and read test by running:<br />
<br />
<pre class="postCode">sudo badblocks -swp # /dev/sdxy</pre><br />
If you do not find any physical bad blocks, that suggests that the problem was a software one, and the card remains safe to use.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-82193318791750376172011-05-06T11:59:00.108+01:002011-05-14T10:33:16.548+01:00Making a Natty Live CDThis is further update of my <a href="http://justbloodywork.blogspot.com/2010/10/making-maverick-live-cd.html">Maverick</a> and <a href="http://justbloodywork.blogspot.com/2010/09/building-custom-livecd-for-ubuntu.html">Lucid</a> instructions.<br />
<br />
I am assuming that you have got to a terminal window by following the start of the Lucid instructions either on a Windows or Ubuntu system.<br />
<br />
First of all we are going to need some extra packages for our running system to manipulate the CD image. To install these, run this command from a terminal window.<br />
<br />
<pre class="postCode">sudo aptitude install squashfs-tools genisoimage</pre><br />
The CD image contains one large archive file which stores all of the disk environment for the LiveCD. The squashfs-tools handles this archive. Basically, we unpack everything, add our extra packages, and then repack everything. The genisoimage [gen]erates the final [iso] [image] which we put onto the USB Key in due course.<br />
<br />
First, make a working directory in [~] home:<br />
<br />
<pre class="postCode">mkdir ~/live
cd ~/live</pre><br />
Next we are going to actually mount the CD image so we can use it as if we had burned it to a CD and inserted it. We need to create the mount point first of all:<br />
<br />
<pre class="postCode">mkdir mnt
sudo mount -o loop /media/[whatever]/ubuntu-11.04-desktop-i386.iso mnt</pre><br />
The [whatever] will differ depending on exactly where your system mounts the USB Key you just plugged in. The <a href="http://en.wikipedia.org/wiki/Loop_device">loop</a> [o]ption allows us to mount the image file as a folder.<br />
<br />
Now we need to copy all of the files off the mounted image APART from the large squashed file. Again we want a separate folder to store these files:<br />
<br />
<pre class="postCode">mkdir extract-cd
rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd</pre><br />
Next we need to extract the big archive file:<br />
<br />
<pre class="postCode">sudo unsquashfs mnt/casper/filesystem.squashfs</pre><br />
It uncompresses to a folder name we want to change by the typical linux method of [m]o[v]ing it.<br />
<br />
<pre class="postCode">sudo mv squashfs-root edit</pre><br />
We are going to be chrooting into the filesystem we just unpacked, and we want to use some of the files on our existing machine to point the way to the internet, and to give us access to our current hardware:<br />
<br />
<pre class="postCode">sudo cp /etc/resolv.conf edit/etc/
sudo cp /etc/hosts edit/etc/
sudo mount --bind /dev/ edit/dev</pre><br />
Now we chroot in and mount some virtual filesystems:<br />
<br />
<pre class="postCode">sudo chroot edit
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts</pre><br />
We also need to set some system variables and create a symbolic link for some reason or another. <br />
<br />
<pre class="postCode">export HOME=/root
export LC_ALL=C
dbus-uuidgen > /var/lib/dbus/machine-id
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl</pre><br />
I think the dbus command generates a code for this specific machine that some installation stuff may need. No idea what the [initctl] stuff is all about.<br />
Excellent. We are now at the point where we can start to install stuff. First of all, and this was fucking frustrating trying to work this out, we need to enable the universe and multiverse repositories if we want to install packages from them. We need to do this in command line:<br />
<br />
<pre class="postCode">sudo nano /etc/apt/sources.list</pre><br />
Let's add the PPA's that I covered in a previous post so we can install the useful software they include:<br />
<br />
<pre class="postCode">sudo add-apt-repository ppa:stebbins/handbrake-releases
sudo add-apt-repository ppa:jd-team/jdownloader</pre><br />
This next command adds an external repository (which is a bigger and more complex type of PPA) to the list of places we can download stuff from. It's a biggie but it basically is just a series of commands that run in sequence.<br />
<br />
<pre class="postCode">sudo wget http://www.medibuntu.org/sources.list.d/`lsb_release -cs`.list --output-document=/etc/apt/sources.list.d/medibuntu.list; sudo apt-get -q update; sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring; sudo apt-get -q update</pre><br />
Before installing stuff, it might be a good idea to clean out some stuff we are not going to use. First of all have a look at all the installed packages in order of size:<br />
<br />
<pre class="postCode">dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | less</pre><br />
The first on the list looks like a massive package, but what you have to understand is that this is showing you the UNCOMPRESSED sizes. Yeah, thanks for that. If you check on http://packages.ubuntu.com/lucid for the ubuntu-docs information, you find it is only taking up a few hundred Kb when squashed.<br />
So what can you remove? Evolution is a prime candidate. Not much use on a LiveCD. You will be using webmail from a LiveCD.<br />
<br />
<pre class="postCode">dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | grep evolution</pre><br />
This will show you all packages which have evolution in the title. It should look like this:<br />
<br />
<pre class="postOutput">9824 evolution-common
5560 libevolution
2148 evolution-exchange
1580 evolution-data-server
1084 evolution
764 evolution-plugins
380 evolution-data-server-common
124 evolution-indicator
88 evolution-webcal</pre><br />
You can remove all, apart from evolution-data-server-common which is needed by other applications, by running this command:<br />
<br />
<pre class="postCode">apt-get remove --purge evolution-common libevolution evolution-exchange evolution-data-server evolution-webcal evolution evolution-plugins evolution-indicator evolution-webcal</pre><br />
The language packs also take up a lot of space, and I do not need anything but English. Find these by running:<br />
<br />
<pre class="postCode">dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | grep language-</pre><br />
and then remove the ones we do not want:<br />
<br />
<pre class="postCode">apt-get remove --purge language-pack-gnome-xh-base language-pack-xh-base language-pack-gnome-zh-hans-base language-pack-zh-hans-base language-pack-gnome-es-base language-pack-gnome-pt-base language-pack-gnome-de-base language-pack-pt-base language-pack-es-base language-pack-de-base</pre><br />
There are other language packs, but they are to small to worry about clearing up unless you are intent on getting this image as small as possible. The final obvious low hanging fruit are foreign font sets. Do a search for [t]rue[t]ype[f]ont packages:<br />
<br />
<pre class="postCode">dpkg-query -W --showformat='${Installed-Size} ${Package}\n' | sort -nr | grep ttf</pre><br />
<pre class="postOutput">12580 ttf-unfonts-core - Korean
6196 ttf-takao-pgothic - Japanese
5456 ttf-thai-tlwg - Thai
5184 ttf-wqy-microhei - Chinese
4204 ttf-freefont - Latin, keep
2628 ttf-indic-fonts-core - Indian
2592 ttf-dejavu-core - Latin, keep
2336 ttf-ubuntu-font-family - These are new to Natty, and are used widely in ubuntu, so best keep them.
1724 ttf-liberation - Latin, keep
592 ttf-khmeros-core - Cambodian
500 ttf-opensymbol - Symbols, needed for OpenOffice, keep
220 ttf-punjabi-fonts - Punjabi
144 ttf-lao - Lao, where ever Lao is
116 ttf-kacst-one - Arabic</pre><br />
<pre class="postCode">apt-get remove --purge ttf-unfonts-core ttf-takao-pgothic ttf-thai-tlwg ttf-wqy-microhei ttf-indic-fonts-core ttf-khmeros-core ttf-punjabi-fonts ttf-lao ttf-kacst-one</pre><br />
I am not going to be printing from the LiveCD so I can remove the software and drivers as follows. Do not worry about the ubuntu-desktop meta file - it is just an easy way of ensuring that all the ubuntu basic stuff is installed. As soon as printing is removed, the installation no longer qualifies as an ubuntu desktop but it doesn't actually remove the rest of the stuff.<br />
<br />
<pre class="postCode">apt-get remove --purge cups hplip-data libgutenprint2</pre><br />
I am also going to remove banshee, the rhythmbox replacement, because it does take up a lot of space, and like evolution it is really the type of application you need to set up on an installed machine rather than running from a LiveCD. I have no intention of playing sudoku.<br />
<br />
<pre class="postCode">apt-get remove --purge banshee gnome-sudoku</pre><br />
Even after all of those deletions, once I recompressed the image I found I had saved a paltry 90Mb or so. Ho hum. Once you have carried out all the removals, a good strategy is to upgrade all your remaining packages to the latest versions. You do NOT want to upgrade the Kernel or Grub because that causes bad things to happen and will stop the Live USB stick booting. So, create the following files to 'pin' those packages to their current versions:<br />
<br />
<pre class="postCode">sudo cat > hold_back_kernel << "EOF"
Package: linux-generic linux-headers-generic linux-image-generic linux-restricted-modules-generic
Pin: version 2.6.38.8.22
Pin-Priority: 1001
EOF
sudo mv hold_back_kernel /etc/apt/preferences.d/
sudo cat > hold_back_grub << "EOF"
Package: grub-common
Pin: version 1.99~rc1-13ubuntu3
Pin-Priority: 1001
EOF
sudo mv hold_back_grub /etc/apt/preferences.d/
sudo apt-get update</pre><br />
You can check that the version numbers are correct (they should be for the Live CD you have downloaded) and check the system knows about the new rules by running these commands:<br />
<br />
<pre class="postCode">sudo apt-cache policy
dpkg -l linux-generic
dpkg -l grub-common</pre><br />
The last few lines of all of that should look like this (you can see the version numbers match up):<br />
<br />
<pre class="postOutput">Pinned packages:
linux-headers-generic -> 2.6.38.8.22
linux-image-generic -> 2.6.38.8.22
grub-common -> 1.99~rc1-13ubuntu3
linux-generic -> 2.6.38.8.22
root@Dellbuntu:/# dpkg -l linux-generic
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=============================================-=============================================-==========================================================================================================
ii linux-generic 2.6.38.8.22 Complete Generic Linux kernel
root@Dellbuntu:/# dpkg -l grub-common
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=============================================-=============================================-==========================================================================================================
ii grub-common 1.99~rc1-13ubuntu3 GRand Unified Bootloader, version 2 (common files)
</pre><br />
You should now be able to run the upgrade excluding those troublesome packages.<br />
<br />
<pre class="postCode">sudo apt-get upgrade</pre><br />
We can now run a massive install command to add the extra packages that we want.<br />
<br />
<pre class="postCode">sudo apt-get install \
\
libgtk2.0-dev bison texinfo \
\
flashplugin-installer openjdk-6-jre icedtea6-plugin \
\
libreoffice-java-common libreoffice-l10n-en-gb libreoffice-help-en-gb openoffice.org-hyphenation-en-us openoffice.org-thesaurus-en-us \
\
ttf-mscorefonts-installer \
\
smplayer vlc avidemux audacity \
\
totem-plugins-extra gstreamer0.10-pitfdll gstreamer0.10-ffmpeg gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse \
\
non-free-codecs libavcodec-extra-52 libdvdcss2 libdvdread4 libdvdnav4 \
\
lame mjpegtools twolame mpeg2dec liba52-0.7.4-dev ffmpeg ffmpeg2theora w32codecs \
\
keepassx handbrake-gtk jdownloader \
\
xchm comix gqview pdfmod \
\
wine \
\
transmission \
\
dcraw gimp gimp-data-extras gimp-help-en \
\
celestia celestia-common celestia-common-nonfree stellarium googleearth-package lsb-core \
\
git-core subversion libssl-dev \
\
monodevelop</pre><br />
To install Google Earth from the package downloaded above, you run:<br />
<br />
<pre class="postCode">make-googleearth-package --force</pre><br />
You then need to install the package the previous command creates. At the time of writing the version numbering creates a package which can be installed with this command (but this is likely to change):<br />
<br />
<pre class="postCode">sudo dpkg -i googleearth_6.0.2.2074+0.6.0-1_i386.deb</pre><br />
I also want a bit of software which is not available in the repositories. Truecrypt is a handy encryption system. Truecrypt is a pain in the arse since they want you to accept their stupid licence instead of just releasing under the GPL.<br />
<br />
<pre class="postCode">cd /tmp
wget http://www.truecrypt.org/download/truecrypt-7.0a-linux-x86.tar.gz
tar -xzvf truecrypt-7.0a-linux-x86.tar.gz
./truecrypt-7.0a-setup-x86</pre><br />
Extract the package file - it automatically stores it in /tmp. We need to extract it to /, and it auto installs to the correct folders. So:<br />
<br />
<pre class="postCode">cd /
tar -xzvf /tmp/truecrypt_7.0a_i386.tar.gz</pre><br />
And that is that for Truecrypt.<br />
<br />
If you were stupid enough to upgrade the kernel package, it is extremely likely that doing a upgrade of all the packages will change the kernel version. To ensure that the new kernel is actually used, you need to go into the ...<br />
~/live/edit/boot<br />
...folder and copy the latest versions of the vmlinuz compressed kernel and the initrd.img files to the ...<br />
~/live/extract-cd/casper<br />
...folder. You then need to delete the existing initrd.lz file, and rename the initrd.img file you just copied over to replace it. Do the same with the vmlinuz files. This has NEVER worked for me so I do not upgrade the kernel package.<br />
<br />
If you want the clock in the LiveCD machine to show the proper time, take a moment and set your time zone and keyboard for UK use:<br />
<br />
<pre class="postCode">sudo setxkbmap gb
sudo cp -v --remove-destination /usr/share/zoneinfo/Europe/London /etc/localtime</pre><br />
Of course, the keyboard command does not fucking work. I now have no fucking idea how to change the keyboard map from the command line. Brilliant. I mean there must be a file somewhere, anywhere, that actually stores these settings. Where? No fucking clue. Moving on:<br />
<br />
We now need to clean up some user account stuff incase any of the installed packages made changes:<br />
<br />
<pre class="postCode">awk -F: '$3 > 999' /etc/passwd
usermod -u 500 $hit #where hit is any user ID greater than 999</pre><br />
Right, and we are good to do a general clean up:<br />
<br />
<pre class="postCode">apt-get clean
rm -rf /tmp/* ~/.bash_history
rm /etc/resolv.conf
rm /var/lib/dbus/machine-id
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl
umount -l /proc
umount /sys
umount /dev/pts
exit
sudo umount edit/dev</pre><br />
The [rm] commands obviously [r]e[m]ove stuff, and the remaining commands undo the setup commands we used to get into the [chroot] environment. Virtually every time I do this I get a fucking annoying error telling me that it can't umount these things because they are in use. Well, you know what I say to that? Hello Mr. Reboot.<br />
<br />
Once the system has come back on, fire up a terminal and:<br />
<br />
<pre class="postCode">cd ~/live</pre><br />
Now, update the .manifest file which is a list of installed packages:<br />
<pre class="postCode">chmod +w extract-cd/casper/filesystem.manifest
sudo chroot edit dpkg-query -W --showformat='${Package} ${Version}\n' > extract-cd/casper/filesystem.manifest
sudo cp extract-cd/casper/filesystem.manifest extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/ubiquity/d' extract-cd/casper/filesystem.manifest-desktop
sudo sed -i '/casper/d' extract-cd/casper/filesystem.manifest-desktop</pre><br />
Now delete the existing squashed archive and replace it. Don't worry if it cannot find one, there shouldn't be one the first time you run through these instructions.<br />
<pre class="postCode">sudo rm extract-cd/casper/filesystem.squashfs
sudo mksquashfs edit extract-cd/casper/filesystem.squashfs</pre><br />
That last command will take most time of anything here, as it (re)compressess all the packages we want. If you are feeling particularly narcisstic you can edit the disk details (change the image name) that pop up on boot:<br />
<br />
<pre class="postCode">sudo nano extract-cd/README.diskdefines</pre><br />
Now we need to rebuild the md5sum check file:<br />
<pre class="postCode">cd extract-cd
sudo rm md5sum.txt
find -type f -print0 | sudo xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee md5sum.txt</pre><br />
That will probably take two [sudo] password requests - one for the straight [sudo] and one for the [| sudo] piped version. Do not know why. Irritating as fuck.<br />
<br />
And finally we need to build a new iso image:<br />
<br />
<pre class="postCode">sudo mkisofs -D -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../ubuntu-11.04-desktop-i386-custom.iso .</pre><br />
Once you have that image you use the unetbootin software (which comes in both windows and linux flavours) to load the image onto the USB Key. You need to use version 494 at least to get it to work with Natty. Job done.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-69673831635318239452011-04-29T11:59:00.005+01:002011-05-04T11:05:33.643+01:00Adding a PPA in MaverickHappy day for those ubuntu users who want the video transcoding application Handbrake. I find this useful because it is the only application that will spit out video that an iPhone or iPad will actually play. Anyway, my <a href="http://justbloodywork.blogspot.com/2010/10/making-maverick-live-cd.html">live cd</a> instructions contained a breathless explanation of how to build handbrake from source. You no longer need to do that. You just need a ppa instead.<br />
<br />
OK, what's a PPA? It is like an official ubuntu source of packages, but it is not maintained by canonical. It stands for personal package archive. These are useful for all kinds of things. Here it is used for software not tested by the people who make ubuntu, and which doesn't form part of the ubuntu repositories of packages.<br />
<br />
In addition, a useful download manager is also now available for ubuntu in a ppa: <a href="http://jdownloader.org/">jdownloader</a>. What we are about to do is add two ppa's to our list of sources of ubuntu applications, then update our list of what applications are contained in all of our sources, and then we will install the two applications in question.<br />
<br />
<pre class="postCode">sudo add-apt-repository ppa:stebbins/handbrake-releases
sudo add-apt-repository ppa:jd-team/jdownloader
sudo apt-get update
sudo apt-get install handbrake-gtk jdownloader</pre>smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0tag:blogger.com,1999:blog-5718818273328171887.post-56849390843060945382011-04-22T11:59:00.004+01:002011-04-22T11:59:00.484+01:00Batch flv to mp4 conversionIf you have been happily downloading and storing <a href="http://justbloodywork.blogspot.com/2011/03/downloading-flash-videos.html">flash videos</a> you may end up with a whole pile of flv files. My instructions above included a command to convert each file into an mp4 file which is much easier to work with.<br />
<br />
What about converting a whole folder full at once?<br />
<br />
Try this:<br />
<br />
<pre class="postCode">for file in *.flv ; do ffmpeg -i $file -acodec copy -vcodec copy ${file%.flv}.mp4 ; done</pre><br />
That three stage command does the following (in english):<br />
<br />
The first bit before the semi colon means, [for] each [*] file that you find in the current folder with the extension [flv], take the full name of the file forward into the next part of the command as a variable [file]. The next bit says that you [do] the command [ffmpeg] using as an [i]nput the variable [$] called [file]. The options for the ffmpeg command are to [copy] the [a]udio [codec] and the [v]ideo codec, so no recompression. You retain the same data but in a different container. The output of the command is a file with a name made up of the variable [$] called [file] minus [%] the characters [.flv] PLUS the characters [.mp4]. The last bit after the second semi colon closes the command sequence started by the [do]. If you felt brave you could stick a [r]e[m]ove command in here to get rid of your input files in before the [; done].smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com2tag:blogger.com,1999:blog-5718818273328171887.post-2720316214345695802011-04-15T11:59:00.012+01:002011-04-15T12:16:25.895+01:00Listening to BBC Radio Shows on an MP3 playerIn the name of bastard fuck, this was far fucking harder than it had any right to be.<br />
<br />
You have Windows Media Centre installed on your PC. Either XP, or Vista or 7. Whatever. Fine. You record DVB-T1 broadcast TV programs and watch them quite happily. You record the odd radio program (also broadcast over DVB-T1), and you can play it back on the TV. But who wants to sit around the TV listening to radio programs, what do you think this is, the 1930's?<br />
<br />
You have recorded an audio file. You want to listen to the audio on another device. How fucking difficult do you think this is going to be? Oh, boy you are in for a fucking treat.<br />
<br />
So, how do we do this? I should interject here and say that there is a fairly straightforwards, albeit time-consuming, way to deal with this. You fire up <a href="http://audacity.sourceforge.net/">audacity</a>, change the input source to be the sound card audio out, then hit record and play whatever it is you want to record. The problem with this is that you are recording a compressed track so you are going to lose quality. In my view the BBC are the experts when it comes to digital audio compression and trasmission, and it is going to spoil whatever they broadcast if I recompress it. Its like sitting in the back row of the cinema with your digital video camera. You are not exactly going to walk out with a blue ray quality version of the film are you?<br />
<br />
First thing. If using Vista or Windows 7, media centre spits out files with the extension .<a href="http://wiki.multimedia.cx/index.php?title=WTV">wtv</a>. These are unreadable by anything but windows, so we need to convert them into a more common format. Helpfully if you right click on the file you will find an option to convert it to <a href="http://wiki.multimedia.cx/index.php?title=DVR-MS">dvr-ms</a> file.<br />
<br />
What I would then ordinarily do is fire the file up in <a href="http://www.videoredo.com/en/index.htm">Video Redo</a>. This is an excellent product for taking in a dvr-ms file, cutting out all the bits you do not want (ads and so forth) and then spitting out the original video and audio streams in an mpg file. You can then happily load that mpg file into <a href="http://fixounet.free.fr/avidemux/">avidemux</a>, or your editor of choice and convert it to whatever format you desire.<br />
<br />
However, Video Redo shits itself when it is given a dvr-ms file without any video. It just cannot handle it. The more recent versions of Video Redo may be different, but I am not paying for an upgrade for something this simple.<br />
<br />
So we want to extract the audio in some other fashion. When something is difficult, then make it harder by doing it on the command line. If we want robust command line editing tools then we want Linux. I have tried ffmpeg under ubuntu with a command that looks a bit like this:<br />
<br />
<pre class="postCode">ffmpeg -i filename.dvr-ms -acodec copy -o filename.mp2</pre><br />
Doesn't fucking work. Apparently ffmpeg also cannot handle the earth shattering reality of a dvr-ms file without a fucking video stream.<br />
<br />
How about:<br />
<br />
<pre class="postCode">mplayer -dumpaudio -dumpfile audio.mp2 filename.dvr-ms</pre><br />
No fucking joy. Cannot ever find an audio stream. It turns out that <a href="http://www.videolan.org/vlc/">vlc</a> is practically the only fucking thing on the planet that will spit the untouched audio out of a BBC Digital TV Broadcast Radio Recording. The command is this gem:<br />
<br />
<pre class="postCode">cvlc "[filename].dvr-ms" vlc://quit --sout '#transcode{vcodec=none}:duplicate{dst=std{access=file,mux=raw,dst="[filename].mp2"}}'</pre><br />
That's a fucking little beauty isn't it. Far more than you could ever realistically want to know about those options can be found <a href="http://www.videolan.org/doc/streaming-howto/en/ch03.html">here</a> and <a href="http://wiki.videolan.org/Transcode">here</a>.smoo bandithttp://www.blogger.com/profile/15724333504028596665noreply@blogger.com0