I 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.
SO it is time to revisit my post - which could not get audio working.
Here is my fresh solution.
We open the file through a ffmpeg virtualdub input plugin, apply the deshaker filter once, then frameserve the second pass through avisynth proxy, to avidemux to apply final filters and compression settings.
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:
http://virtualdub.sourceforge.net/
I have been using version 1.10.4, so anything later than that should be fine.
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.
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:
http://sourceforge.net/projects/virtualdubffmpeginputplugin/
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.
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".
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.
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.
Tune in next time for more hilarious adventure of how to deshoogle!
Thursday, 11 September 2014
Saturday, 26 May 2012
Digital Photo Frames
Digital 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.
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.
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!:
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:
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.
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.
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!:
find . -name '* *' | while read file; do target=`echo "$file" | sed 's/ /_/g'`; echo "Renaming '$file' to '$target'"; mv "$file" "$target"; done;
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:
for file in *.{jpg,JPG}; do echo $file && convert -resize 800x480 -quality 80 $file small_$file; done
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.
Friday, 27 January 2012
Skyrim
For a change, it is a new year after all, I present my comments on levelling a character in Skyrim.
Skyrim is the latest installment of the Elder Scrolls series, which has been running for nigh on twenty years. I missed Arena, the first one, but thoroughly enjoyed Daggerfall the sequel. I tried Morrowind, and didn't like it. Too weird, dark and depressing. Oblivion was awesome but quirky, and Skyrim is Oblivion with all the stuff I didn't like taken out.
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.
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.
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 speechcraft and acrobatics, 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.
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.
OK, so the game starts, and you pick your character. If I am going magey, I do like a high elf magicka bonus. The dragon attacks just in the nick of time, and you are up and running. My advice is to follow this guy, 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 sneak 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.
You can take the tedium out of stabbing the NPC in the back by blasting him with flames to level your destruction 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.
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 sneak or go invisible. You can go invisible by levelling illusion to 75 and casting the requisite spell, or by levelling alchemy 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.
Every time you level up you get to choose to increase one of health, magicka or stamina. 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.
Also, because the world still levels, when you reach late thirties in level, there are bandit archers 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.
Money, money, money.
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 "enchant banish on iron daggers, 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.
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 Riverwood, 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 Riften, Windhelm, Winterhold, Dawnstar, Morthal, Solitude, Markarth, Falkreath and Whiterun in that order. Kill any animals/bandits and pick any flowers/mushrooms you come across. In Winterhold, join the college to get a room with wardrobes that you can permanently store stuff in. Go to the first guild quest to get a free shield spell, 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 leather strips. Store these in your room in the college if you get too many.
You are now ready to start the alchemy grand tour. Using fast travel visit every alchemist in every city (apart from Winterhold) and buy as many of their ingredients as you can afford. Just empty their inventories, apart from Void Salts 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 Giant's toes and wheat. 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.
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.
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.
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.
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.
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.
When your speech skill hits 25, stop by the Black-Briar Meadery 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 Merchant 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 Alure 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.
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 smith. Buy Iron Ore. Don't buy the ingots, just the ore. The Ironbreaker mine 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.
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 damage magicka sells for 250 gold pieces. To enchant you need to know the enchantment, have an item to enchant, and a filled soul gem. You can buy soul gems from most trading wizards in the College, from most court wizards, and from most general stores. 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.
If you are running low on leather strips and you are going hunting anyway, you can buy the Soul Trap spell from Phinis Gestor 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.
The best starting enchantment is damage magicka. 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.
The next best enchantments are damage stamina or absorb health. 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 Banish enchanted weapon for sale. This really kicks things into top gear. A banish dagger has a value of 1750gp.
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.
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 Faralda 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.
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.
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:
Helm: Fortify Destruction and Magicka
Chest: Fortify Destruction and Light Armour
Arms: Fortify Carry Weight and Light Armour
Feet: Fortify Carry Weight and Sneak
Neck: Fortify Destruction and Resist Magic
Finger: Fortify Destruction and Resist Magic
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 moonstone and quicksilver (if you have the gilded elven chest plate, 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.
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 grab a claw from a dungeon. 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) stone which is part of a quest given by the Whiterun mage. 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.
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 suitable amulet 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.
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.
Skyrim is the latest installment of the Elder Scrolls series, which has been running for nigh on twenty years. I missed Arena, the first one, but thoroughly enjoyed Daggerfall the sequel. I tried Morrowind, and didn't like it. Too weird, dark and depressing. Oblivion was awesome but quirky, and Skyrim is Oblivion with all the stuff I didn't like taken out.
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.
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.
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 speechcraft and acrobatics, 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.
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.
OK, so the game starts, and you pick your character. If I am going magey, I do like a high elf magicka bonus. The dragon attacks just in the nick of time, and you are up and running. My advice is to follow this guy, 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 sneak 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.
You can take the tedium out of stabbing the NPC in the back by blasting him with flames to level your destruction 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.
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 sneak or go invisible. You can go invisible by levelling illusion to 75 and casting the requisite spell, or by levelling alchemy 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.
Every time you level up you get to choose to increase one of health, magicka or stamina. 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.
Also, because the world still levels, when you reach late thirties in level, there are bandit archers 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.
Money, money, money.
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 "enchant banish on iron daggers, 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.
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 Riverwood, 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 Riften, Windhelm, Winterhold, Dawnstar, Morthal, Solitude, Markarth, Falkreath and Whiterun in that order. Kill any animals/bandits and pick any flowers/mushrooms you come across. In Winterhold, join the college to get a room with wardrobes that you can permanently store stuff in. Go to the first guild quest to get a free shield spell, 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 leather strips. Store these in your room in the college if you get too many.
You are now ready to start the alchemy grand tour. Using fast travel visit every alchemist in every city (apart from Winterhold) and buy as many of their ingredients as you can afford. Just empty their inventories, apart from Void Salts 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 Giant's toes and wheat. 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.
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.
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.
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.
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.
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.
When your speech skill hits 25, stop by the Black-Briar Meadery 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 Merchant 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 Alure 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.
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 smith. Buy Iron Ore. Don't buy the ingots, just the ore. The Ironbreaker mine 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.
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 damage magicka sells for 250 gold pieces. To enchant you need to know the enchantment, have an item to enchant, and a filled soul gem. You can buy soul gems from most trading wizards in the College, from most court wizards, and from most general stores. 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.
If you are running low on leather strips and you are going hunting anyway, you can buy the Soul Trap spell from Phinis Gestor 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.
The best starting enchantment is damage magicka. 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.
The next best enchantments are damage stamina or absorb health. 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 Banish enchanted weapon for sale. This really kicks things into top gear. A banish dagger has a value of 1750gp.
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.
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 Faralda 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.
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.
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:
Helm: Fortify Destruction and Magicka
Chest: Fortify Destruction and Light Armour
Arms: Fortify Carry Weight and Light Armour
Feet: Fortify Carry Weight and Sneak
Neck: Fortify Destruction and Resist Magic
Finger: Fortify Destruction and Resist Magic
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 moonstone and quicksilver (if you have the gilded elven chest plate, 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.
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 grab a claw from a dungeon. 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) stone which is part of a quest given by the Whiterun mage. 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.
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 suitable amulet 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.
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.
Friday, 23 December 2011
Formatting Video for iPad
This, 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.
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.
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).
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.
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.
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.
As a bonus, here are the commands necessary to extract audio from a clip in an iPod/iPhone friendly format:
Same rules apply.
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.
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).
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
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.
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.
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.
As a bonus, here are the commands necessary to extract audio from a clip in an iPod/iPhone friendly format:
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
Same rules apply.
Friday, 11 November 2011
Fixing a fucked Grub2
I 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.
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.
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.
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.
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.
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.
I then got my terminal window open, and found out where this partition had been mounted by running
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.
The output I got was along these lines:
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:
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:
Please note that I was installing the grub to /dev/[sdx] and NOT /dev/[sdxy], for whatever x and y I got.
And then, surprisingly, it worked fine.
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.
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.
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.
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.
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.
I then got my terminal window open, and found out where this partition had been mounted by running
mount | tail -1
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.
The output I got was along these lines:
/dev/[sdxy] on /media/[string of letters and numbers] type ext4 (rw,nosuid,nodev,uhelper=devkit)
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:
ls /media/[string of letters and numbers]/boot
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:
sudo grub-install --boot-directory=/media/[string of letters and numbers]/boot /dev/[sdx]
Please note that I was installing the grub to /dev/[sdx] and NOT /dev/[sdxy], for whatever x and y I got.
And then, surprisingly, it worked fine.
Friday, 4 November 2011
More Ubuntu Wifi Joy
My 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.
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.
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.
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.
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.
(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)
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:
I have to run this script every time I boot. Joy of all joys.
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.
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.
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.
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.
(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)
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:
cd /tmp
cp '/home/[user]/Dropbox/Essential Drivers/Wireless Drivers/hybrid-portsrc-x86_32-v5.60.48.36.tar.gz' .
mkdir hybrid_wl
cd hybrid_wl
tar -xzvf ../hybrid-portsrc-x86_32-v5.60.48.36.tar.gz
unzip '/home/[user]/Dropbox/Essential Drivers/Wireless Drivers/sta_5.60.48.36_2.6.33_kernel_patch.zip'
patch -p0 < patch
unzip '/home/[user]/Dropbox/Essential Drivers/Wireless Drivers/sta_5.60.48.36_2.6.34_multicast_kernel_patch.zip'
patch -p0 < patch_hybrid_multicast
make clean
make
sudo rmmod b43
sudo rmmod b44
sudo rmmod b43legacy
sudo rmmod wl
sudo rmmod ssb
sudo rmmod ndiswrapper
sudo rmmod lib80211_crypt_tkip
sudo rmmod lib80211
sudo modprobe lib80211
sudo insmod wl
I have to run this script every time I boot. Joy of all joys.
Friday, 14 October 2011
Evolution
Unable 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.
Friday, 16 September 2011
Recently
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.
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.
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.
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.
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.
Friday, 26 August 2011
Installing OSX
Having 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?
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.
I then had exactly the same bloody problem as with the previous attempt. It would freeze when starting up the installer. What to do?
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.
The command that I needed to add on were:
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.
The next problem is getting the system to boot without using the iBoot disk. To do so I needed to use the multibeast 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.
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.
Fantastic. It was at this point, after much searching on the internet, that I discovered that I needed to use the further boot parameters:
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:
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.
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.
I then had exactly the same bloody problem as with the previous attempt. It would freeze when starting up the installer. What to do?
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.
The command that I needed to add on were:
PCIRootUID=1
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.
The next problem is getting the system to boot without using the iBoot disk. To do so I needed to use the multibeast 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.
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.
Fantastic. It was at this point, after much searching on the internet, that I discovered that I needed to use the further boot parameters:
max_valid_dma_addr=1024
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:
<key>Kernel Flags</key>
<string>arch=i386 max_valid_dma_addr=1024</string>
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.
Friday, 29 July 2011
Installing Latex and PGF
I 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.
Ahem.
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.
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 this page. My nearest CTAN mirror is in the UK, so my command to download the DVD Image is:
You can then grab the PGF file by running these commands:
However, if it is regularly updated, you would probably just want to go to this page and download the latest version manually.
To install the software first you need to mount the DVD image. You can do that as follows:
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:
To then run the installer, you use this command:
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.
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].
Once installed, you want to tell your system where to find the nice new files, which you can do as follows:
Ahem.
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.
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 this page. My nearest CTAN mirror is in the UK, so my command to download the DVD Image is:
cd ~ wget http://mirror.ox.ac.uk/sites/ctan.org/systems/texlive/Images/texlive2011.iso
You can then grab the PGF file by running these commands:
wget http://sourceforge.net/projects/pgf/files/pgf/version%202.10/pgf_2.10.tds.zip/download mv download pgf_2.10.tds.zip
However, if it is regularly updated, you would probably just want to go to this page and download the latest version manually.
To install the software first you need to mount the DVD image. You can do that as follows:
mkdir ~/texlivedvd sudo mount -o loop ~/texlive2011.iso ~/texlivedvd
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:
sudo apt-get install perl-tk
To then run the installer, you use this command:
sudo ~/texlivedvd/install-tl -gui perltk
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.
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].
Once installed, you want to tell your system where to find the nice new files, which you can do as follows:
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 ~/.bashrcWhat 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:
cd ~/texlive/2010/texmf/ sudo unzip ~/pgf_2.10.tds.zip sudo texhashThe [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:
sudo apt-get install build-essential cmake libqt4-dev qt4-dev-tools libpoppler-qt4-dev kdelibs5 kdelibs5-dev khelpcenter4Basically 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:
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 installThat 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:
\usetikzlibrary{calc,through, intersections,decorations.text, decorations.pathreplacing}
Friday, 22 July 2011
Detailed Tikz Animations
I 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:
First of all we need to create a decent image in ktikz. This code works well for this purpose:
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:
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.
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.
OK, good. What does that draw if myangle is 117? It draws this:
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.
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:
And this command at the end:
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:
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:
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:
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:
The [convert] command makes sense, but what about the [density 300] stuff? Well the pdf we have made is of vector graphics which can scale without losing detail to any resolution you like. A jpeg image is essentially raster graphics 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.
We now need to get our cropping parameters. To get these run the [display] command (from the imagemagick package I think):
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:
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.
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:
You can now generate all your frames by running this command:
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.
We now need to move into the frames folder for the next bit:
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:
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:
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:
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.
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:
Marker-File-Maths-Frame
360-1-(360+360)-720
359-2-(359+360)-719
358-3-(358+360)-718
...
2-359-(2+360)-362
1-360-(1+360)-361
It is a bit of a wrestle, but it gets there.
Now we have all our jpeg frames, we can use [ffmpeg] to compress them into an mp4 video file like so:
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].
You can now view your creation by running:
It should look like this:
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:
First of all we need to create a decent image in ktikz. This code works well for this purpose:
\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}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:
\usetikzlibrary{calc,through, intersections,decorations.text}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.\begin{tikzpicture} [scale=3]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. \def\myangle{117}This is the key to our whole animation. We are setting a variable which we can then change using sed (aaaargh).\clip (-1.5,-1.5) rectangle (-1.5,-1.5);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.
\coordinate (A) at (0,0); \coordinate (B) at (1,0);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.
\node [blue, name path=blue_circle,draw,circle through=(B)] at (A) {};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].\draw [black, fill] (A) circle (1pt) node [below] {\tiny centre};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.\draw [red, dashed] (A) -- (B);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.
\path [name path=radius, rotate=\myangle] (A) -- ++(1.5,0);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.
\draw [red, ->] ($(A)+(0.5,0)$) arc (0:\myangle:0.5cm);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).
\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);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.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.
\draw [name intersections={of=blue_circle and radius, by=C}] [orange, ->] (A) -- (C) node [pos=0.7, sloped, above] {\tiny radius}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.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.
\end{tikzpicture}This line [end]s the code to draw the [tikz] [picture].OK, good. What does that draw if myangle is 117? It draws this:
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.
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:
\documentclass{article}
\usepackage{tikz}
\begin{document}And this command at the end:
\end{document}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:
\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}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:
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}
EOFWhen 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:
sed 's/{xyzzy}/{'117'}/' ~/master_frame.tex > ~/test.texAnd we now generate the pdf file from it:pdflatex ~/test.tex
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:
convert -density 300 test.pdf test.jpg
The [convert] command makes sense, but what about the [density 300] stuff? Well the pdf we have made is of vector graphics which can scale without losing detail to any resolution you like. A jpeg image is essentially raster graphics 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.
We now need to get our cropping parameters. To get these run the [display] command (from the imagemagick package I think):
display test.jpg
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:
convert -density 300 -crop 724x724+789+692 test.pdf test.jpg
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.
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:
mkdir ~/frames
You can now generate all your frames by running this command:
for angle in {1..360}; do sed 's/{xyzzy}/{'$angle'}/' ~/master_frame.tex > ~/frames/$angle.tex; echo $angle; doneThat 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.
We now need to move into the frames folder for the next bit:
cd ~/frames
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:
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
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:
for file in ???.tex; do pdflatex -interaction=batchmode $file; echo $file; done
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:
for file in *.pdf; do convert -density 300 -crop 724x724+789+692 $file ${file%.???}.jpg; echo $file; doneThis 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.
marker=360; for file in *.jpg; do frame=$(($marker+360)); cp $file $frame.jpg; marker=$(($marker -1)); echo $marker; done
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:
Marker-File-Maths-Frame
360-1-(360+360)-720
359-2-(359+360)-719
358-3-(358+360)-718
...
2-359-(2+360)-362
1-360-(1+360)-361
It is a bit of a wrestle, but it gets there.
Now we have all our jpeg frames, we can use [ffmpeg] to compress them into an mp4 video file like so:
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
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].
You can now view your creation by running:
mplayer circle.mp4 -loop 0
It should look like this:
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:
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
Friday, 15 July 2011
Installing OSX on a Hackintosh
Because 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.
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.
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.
I managed to find a useful OSX command which forces the machine to write the image without scanning it, and it is thus:
This did at least manage to write the image to the USB Key, and it does seem to boot when using the iboot 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.
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.
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.
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.
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.
I managed to find a useful OSX command which forces the machine to write the image without scanning it, and it is thus:
sudo asr -noverify -source "/[location of image]/Mac OS X Install DVD.dmg" -target "/Volumes/[mount point of USB Key]"
This did at least manage to write the image to the USB Key, and it does seem to boot when using the iboot 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.
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.
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.
Friday, 8 July 2011
Animating TEX
Short post today but I wanted to set out my work-flow used when generating animated tikz diagrams.
1) Start with your tikz diagram. Instead of fixed values, define variables to be used in their place:
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.
2.5) rename all the .tex files to make sure they have the appropriate amount of trailing zeros.
3) Run PDF Latex on each individual .tex file to get a pdf.
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.
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.
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.
Job done. More details and exact ubuntu commands to come.
1) Start with your tikz diagram. Instead of fixed values, define variables to be used in their place:
\def\angle1{x}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.
2.5) rename all the .tex files to make sure they have the appropriate amount of trailing zeros.
3) Run PDF Latex on each individual .tex file to get a pdf.
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.
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.
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.
Job done. More details and exact ubuntu commands to come.
Friday, 1 July 2011
Firefox 5 from Source
These 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.
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
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
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
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
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
time make -f client.mk build make -f client.mk install cd .. rm -rvf moz*
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
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
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/Add this to the openbox menu.xml file:
<item label="flash player properties"> <action name="Execute"> <execute> /usr/bin/flash-player-properties </execute> </action> </item>Download Java from here. OR:
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
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
EOFsource /etc/profileIf you have installed openoffice:
ln -sv /opt/openoffice-3.2.1/program/libnpsoplugin.so /opt/firefox5/lib/firefox-5.0/plugins
Friday, 24 June 2011
Parameter Substitution
That 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.
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.
So how do we insert the missing 0?
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.
So how do we insert the missing 0?
for file in imageroot-???.*; do mv $file imageroot-0${file#imageroot-}; echo $file; done
Friday, 17 June 2011
Gnuplot
If 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:
This will break your Ubuntu packaging system though - so be careful.
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
This will break your Ubuntu packaging system though - so be careful.
Friday, 10 June 2011
Ktikz
If 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.
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:
With Maverick or earlier, you need to install the latest version manually to get all the bells and whistles:
The install will then run through - takes about an hour to download the stuff. You can also download the DVD image via torrent, which would be a good way to have a backup for quick reinstall. Once installed, you need to make sure you update your path:
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.
You may need to preface some of the scripts with libraries to load:
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:
sudo apt-get install texlive
With Maverick or earlier, you need to install the latest version manually to get all the bells and whistles:
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
The install will then run through - takes about an hour to download the stuff. You can also download the DVD image via torrent, which would be a good way to have a backup for quick reinstall. Once installed, you need to make sure you update your path:
PATH=/usr/local/texlive/2010/bin/i386-linux:$PATH
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.
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
You may need to preface some of the scripts with libraries to load:
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\usetikzlibrary{through}
Friday, 3 June 2011
Compressing PDF files
If 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:
You will need:
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.
You get lots of:
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.
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.
For colour sources, you need jpg compression:
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.
For black and white sources you need fax compression:
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.
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!
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].
Simples.
You will need:
sudo apt-get install pdftk imagemagik
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.
pdfimages /path/to/filename.pdf imageroot
You get lots of:
imageroot-[three digit number].somethings
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.
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.
For colour sources, you need jpg compression:
for file in *.{ppm,pbm}; do convert -compress jpeg -quality 50 $file ${file%.???}.pdf; echo $file; doneThat 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.
For black and white sources you need fax compression:
for file in *.{ppm,pbm}; do convert -alpha off -monochrome -compress Group4 -quality 100 $file ${file%.???}.pdf; echo $file; doneThis 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.
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!
pdftk imageroot*.pdf cat output name_of_final_file.pdf
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].
Simples.
Friday, 27 May 2011
Testing Natty on Nvidia Hardware
The 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.
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.
Oh dear. This is going to be a pain in the fucking arse isn't it? Yes, yes it is.
For a start a couple of useful commands for this kind of fiddling are:
This stops dead the GUI leaving you to happily fiddle with graphics driver settings.
To restart the GUI you would just restart the gdm service yes? Yes.
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:
Make the driver file executable:
And run it:
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:
Doesn't fucking work.
Still doesn't fucking work. Google.
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.
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.
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.
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.
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.
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:
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:
:and shut down the GUI:
:and run:
It should now work. You can now install the driver:
And it should eventually install happily. Answer the questions sensibly, ignoring any errors. Then just run this command to restart the GUI:
Bask in the awe of the flashy bar.
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:
(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.)
You now shut down gdm as before from the CTRL+ALT+F1 text interface:
:and run the script from the text command prompt:
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.
And hey fucking presto, there is the snazzy new bar.
Admittedly, after all that, it may be a touch underwhelming.
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.
Oh dear. This is going to be a pain in the fucking arse isn't it? Yes, yes it is.
For a start a couple of useful commands for this kind of fiddling are:
sudo service gdm stop
This stops dead the GUI leaving you to happily fiddle with graphics driver settings.
To restart the GUI you would just restart the gdm service yes? Yes.
sudo service gdm start
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:
wget http://uk.download.nvidia.com/XFree86/Linux-x86/270.41.19/NVIDIA-Linux-x86-270.41.19.run
Make the driver file executable:
sudo chmod +x NVIDIA-Linux-x86-270.41.19.run
And run it:
./NVIDIA-Linux-x86-270.41.19.run
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:
rmmod nouveau
Doesn't fucking work.
sudo rmmod nouveau
Still doesn't fucking work. Google.
sudo rmmod --force nouveau
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.
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.
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.
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.
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.
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:
nomodeset
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:
sudo chmod +x NVIDIA-Linux-x86-270.41.19.run
:and shut down the GUI:
sudo service gdm stop
:and run:
sudo rmmod nouveau
It should now work. You can now install the driver:
sudo ./NVIDIA-Linux-x86-270.41.19.run
And it should eventually install happily. Answer the questions sensibly, ignoring any errors. Then just run this command to restart the GUI:
sudo service gdm start
Bask in the awe of the flashy bar.
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:
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
(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.)
You now shut down gdm as before from the CTRL+ALT+F1 text interface:
sudo service gdm stop
:and run the script from the text command prompt:
sudo ./inst_nv.sh
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.
And hey fucking presto, there is the snazzy new bar.
Admittedly, after all that, it may be a touch underwhelming.
Friday, 20 May 2011
Manually Add DNS Servers
My 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.
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.
To achieve this (in Lucid), go System -> Administration -> Network.
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.
Now, just click on Add, and type in your new DNS IP address.
Hopefully this change means that the next time the server goes offline, I can still use the internet.
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.
To achieve this (in Lucid), go System -> Administration -> Network.
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.
Now, just click on Add, and type in your new DNS IP address.
Hopefully this change means that the next time the server goes offline, I can still use the internet.
Subscribe to:
Posts (Atom)
