Posted on Programming

Adding text to google maps markers

If you’ve ever used the Google Maps Javascript API, you’re probably aware that marker labels can only be one letter long. But sometimes you want them to say something meaningful, and often that takes more than a single character.

In case you’re looking for a way to display arbitrary strings in a Google Maps marker, good news, here’s how you can do it!

You can pass a data URL when you’re supplying an image for an marker, which is great. We can send it some SVG which includes our label text.

  1. Import your marker icon into Illustrator, or some other vector graphics software.
  2. Type in some sample text, formatted however you like.
  3. Export it as SVG.
  4. Create a function that replaces the sample text with whatever you want to display, and returns the adjusted SVG
  5. Pass that to the Google Maps API as a data URL.

// Generate a pin!
function createPin(text) {
	var svg = '...'; // Imagine there's SVG here.
	return 'data:image/svg+xml,' + svg.replace('sample-text', text);
// Create the map. Position and style it however you like
var map = new google.maps.Map(document.getElementById('maps_marker_text_example'), {
	center: {lat: 49.264691, lng: -123.100},
// Create the marker
var marker = new google.maps.Marker({
	map: map,
	icon: createPin('delicious burritos'), // Generate the SVG for this marker
	position: {lat: 49.2630584, lng: -123.0945}

Bam! You’re done. You’ve got map markers showing custom text.

One thing to be aware of is the <svg /> tag must include width and height attributes, otherwise weird things will happen. When I exported from Illustrator, my file had a viewBox attribute, but no width and height. So if yours is missing those, add them in.


Posted on Uncategorised

Things I’ve learned about Don’t starve together

The F key will attack, so you don’t have to try to click on a moving target, and the space key will perform the nearest action.

You definitely want a science machine and an alchemy engine at your camp.

If you find the walking cane, pick it up. It’ll let you explore a more quickly, especially on roads.

If you find Chester‘s eyebone, he’ll follow you around. Sometimes he’ll distract enemies, which can be good or bad, depending on the situation. He can get in your way, so often I’ll leave him at camp by dropping the eyebone.

A fully grown birchnut tree will give you 3 logs and 2 seeds during the Fall. You can replant the seeds, which are edible once cooked. You can tell a fully grown one by the two branches supporting its floof of leaves.

If you find gears, make a fridge (icebox). Sometimes you can find them in tumbleweeds.

With a shovel you can dig up plants and replant them elsewhere. Berries and grass will require fertilization to grow, sapplings will not. You can get manure from around a beefalo herd, or by feeding berries to pigs. Rot works too.

Plant grass on the savanna ground type to ensure it’s not overcome by disease.


manure, beefalo, birchnut tree, gears, tumbleweed, icebox,
eyebone, chester, walking cane, birchnut tree, birchnut seed, science machine, alchemy engine

If you find the pig king, you can give him meat or trinkets in exchange for gold. Not monster meat though, this guy’s health conscious. Tumbleweeds are a good place to find trinkets, and less terrifying than digging up graves.

Instead of a camp fire the first night, I like to make a torch and spend it in the safe glow of a raging forest fire. This is a good source of ashes, and more importantly charcoal. Some will be on the ground, but once the fire is good and truly out take your axe to those charred husks and harvest all the charcoal you need.


When in doubt set everything on fire

If you can’t find any rocks, you can mine petrified trees.

Picking flowers helps you regain your sanity. Also, hats.

Every so often you’ll be attacked by hounds. This is actually pretty easy to survive, at least so far as I’ve gotten. The trick is just don’t fight them. Find a herd of beefalo (preferred), or a grouping of spider nests and keep leading them through until they accidentally harm a beefalo, then collect their meat and any teeth they may have dropped. Pigs work too. If it’s night time, carry a torch.

Once you can handle the hounds, surviving the forgiving fall isn’t all that difficult. But like those elves from the hobbit always say: winter is coming.

Winter is cold, and you should start preparing in the fall. Grow your beard to stay in theme, make some ear muffs (two bunnies and a twig) or a toque (winter hat), but most importantly, make a thermal stone – or even two. Heat these by the fire at night and carry them with you during the day.

camp during winter

Smallbirds are pretty cute!

Food is scarce in the winter, and things don’t really grow. In the fall I like to plant a bunch of birchnut trees near camp, and then cut them all down right before winter. The wood is useful for those long, cold nights, and the seeds go in the fridge for meatballs, if necessary, or potential replanting.

Bunnies and spiders are still available in the Winter (but bunnies disappear in the Spring), so an infrastructure to easily collect those is helpful. This will make cooking bacon & eggs a breeze. I like to set up my camp near a bunch of bunny holes. You can place traps basically right over them. This has an added benefit that usually beefalo and bunnies both frequent the savanna land type.

Speaking of beefalo, you can shave them while they sleep. This is useful, sure, but also hilarious. Don’t be surprised if you feel bad afterward, they look so sad waking up sans fur.

Spiders drop three things that are useful – silk (web), glands, and monster meat – but are super easy and fun to catch, without endangering yourself. Just throw some traps down around one side of a nest, walk onto the webbed ground to draw them out, and run away such that they chase you into the traps. Then repeat. Be careful not to set your traps too close together, or one spider might set off a few of them. And be aware that in the evening spiders react differently – they wander around all willy-nilly and won’t chase you quite as easily. So just set some traps and retire to a safe distance. Maybe do some fishing.

too many spiders

not like this not like this not like this

In the evening frogs slink back into their ponds, so this is the perfect time to catch some fish. Head to one of the little ponds, and equip a fishing rod. Keep your cursor over the pond and click when prompted by “hook” and “reel in”.

I like to make a few drying racks to make fish jerky. It lasts a long time, and is good for regaining sanity and health.

In the winter, the ponds freeze over so you won’t be able to fish.

Once the spider nests are three-tiered, you can destroy them to collect the eggs. Just lure the spiders out as you normally would, until they refuse to play your game, then start knocking. when you attack the nest more spiders will emerge, but you can trap them as well. Repeat until you’re rich in both silk and spider eggs.

Why spider eggs, you ask? Turns out you can plant them like a tree! I like to move them close to, but not too close to, my camp.

Once you have sufficient silk, things get easier. I like to make a bird cage and a bird trap (baited with seeds). Keeping a pet bird has a few benefits. It makes you feel powerful, and provides an easy source of eggs. You can trade it cooked monster meat or bunny morsels for eggs, seemingly without limit. Once I had a nocturnal bird, but mostly you’ll have to do this during the day or in the evening.

Throw two eggs, a monster meat, and a morsel in a crock pot and you’ll end up with eggs & bacon.

A meat and three of any combination of carrots, berries, or cooked birchnuts will get you meatballs. Not as good as eggs & bacon, but they’ll do in a pinch.

Now that you have an endless supply of silk, you can make a beekeeper mask and a bug net. Catch some bees and make a bee mine of you want, but I like to destroy some beehives. Sure this is cruel, but it also provides the requisite materials to make bee boxes, which you can harvest for honey.

Bees aren’t active in the winter, but don’t let that fool you – they’ll still attack if you try to destroy a hive. In the Spring, all bees are deadly, so don’t put them too close to your camp.

Bees are cool and all, but my favourite part about the bug net is starting a flower garden. Bees like flowers, but so do butterflies. You’ve probably seen them fluttering around a flower now and then.

If you catch a butterfly, you can plant it in the ground to make a flower. Soon that flower will have its own butterfly, which you can catch to plant another flower. In this way your flower garden can explode wildly out of control, which is just the way I like it.

flower garden

Come at me, bee

Winter’s here. You have your toque, your sustainable sources of bacon & eggs. A heat stone. A whole wack of wood, and maybe some turf you’ve dug up to keep the fires going. You’re all set. Nothing bad can happen now, it’s time to hole up!

Wait. Do you hear that? What? Oh, that. Don’t worry that’s just the giant beast who wants to destroy everything you’ve ever built and possibly you yourself, should you anger it.

The good news is you’re prepared. You’ve been making gunpowder right? (nitre, rotten egg, charcoal.) You’ll need 9 of them. And ideally an ice staff.

I like to make a small camp a ways away from my main camp. A fire pit, maybe a stone pillar or two. As soon as I hear the huffing/moaning noise that signifies the coming of the deerclops I head there. Light the fire, make sure I have a few torches, and relax.

If all goes well, the deerclops shows up and destroys my decoy camp while I watch, with ever decreasing sanity, torch in hand.

If your camp is far enough away, maybe you can just head back – I don’t know. In my heart I tell myself the deerclops is too dangerous to live. Really, I just want to kill it. Imagine all I could construct with that giant, glistening eye of his.

eyebrella hat

like a nice, new hat!

Step one: freeze him with that freeze ray. Speaking of freeze ways, graveyards are a good place to dig up gems.

Step: two, drop a pile of 9 gunpowder next to him and light it up.

Did it explode? Good! He’s probably only got 200 health left, that’s nothing to a guy or gal like you. Don that log armour and get in there. Don’t forget to run away.

For the true cowards (like me) maybe lead him toward something else that will weaken him further. He’ll probably kill them all, so target someone who’s given you guff.

Let’s be honest, you probably died. That’s okay, there’s no shame in that. Welcome to the exciting wold of ghosts – it’s where I spend most of my time. Sure it’s boring, but I guess you can haunt things. Sometimes haunting flowers will turn them into evil flowers, or haunting hounds will turn them into more specialized hounds. If you see a tumbleweed, maybe it will unwrap itself – who know?



Eventually you’ll get bored of ghosting around. It’s not as fun as horror movies would have you believe. The map doesn’t even update when you go exploring. But, hey, maybe you’ve seen a touchstone around? If you do, haunt it and you’ll come back to life. Each touchstone only works once per player, but don’t worry, there are other ways to come back to life.

If you have a red gem (graves, fire hounds) you can make a lifegiving amulet. Haunting one of those will bring you back to life as well, so I like to leave some lying around camp.

Telltale hearts have to be given to you by another player, but when you’re revived your maximum health will be decreased. A booster shot will fix that.

Well guys, that’s what I’ve learned about Don’t starve together so far. I hope it saves you some trial and error.

As always, feel free to use the tool I made to aid in your survival endeavours, it looks like this.

crafting tool
Posted on Programming

Don’t starve together

I’ve been playing Don’t Starve Together lately, and it’s awesome. There’s a constant sense of pressure imposed by the passage of time, days turn to night, a mild Autumn to bleak Winter. It makes any wasted time seem at worst dire, or at best mildly frustrating.

There are so many items you can cobble together, with twigs, bunny-flesh, and the like. At least 144, by my count. But unless you memorize their positions and ingredients, you’re going to waste a lot of time searching through categories for some item you’re sure you’d seen but just can’t seem to find.

I, myself, often kept a wikia tab open on my secondary monitor. But as I’m sure you’re aware, Wikia is slow and prone to annoying ads blaring sound this way and that. And even so, didn’t provide an ideal interface for that sort of thing.

I wanted to type in “charcoal” and immediately see what I could make. Or “crock pot” and see what I needed. Or even “science” to see everything that’s in that category.

And now I can!

The What can I make page is where I spend most of my time. The What do I need page is for those situations where I’m starting a new game, and know I want to create, say, 2 crock pots and 1 bird cage. It’ll tell me everything I need to collect to fulfill my crafting dreams.

If you find anything that doesn’t work, let me know, I haven’t tested it all that much.

I made it just using jquery. Then I remade it using backbone. Then I remade it using webpack, sass and react. Because why not?

This is the backbone version, because the react interface felt strangely clunky.


Posted on Programming

Duplicate emails, chrome, and favicons

Switching away from Mandrill, I found Amazon SES was sending two emails from my PHP test script. This only happened when hit from the web, running the same script through the PHP-CLI sent one email, as expected.

Looking at Chromes network tab, turns out it was loading the script as well as favicon.ico. Alas, there was no favicon.ico, and in the sites-enabled config for that location the FallbackResource was set to /index.php. Turns out it was loading index.php twice, resulting in two emails.

I used Bradicon! to create a quick favicon, uploaded it, and bam!, just one email from then on.