Ben's Blog

ben

1189 Articles

nature encounters ben August 09, 2018

Slow-mo Bird Song

I love recording birds in slow-mo to hear the complexity of their calls. My brain can’t process them at actual speed.

[mejsvideo mp4=”http://ben.akrin.com/videos/slomo_bird.mp4.mp4″ ogg=”http://ben.akrin.com/videos/slomo_bird.mp4.ogv” webm=”http://ben.akrin.com/videos/slomo_bird.mp4.webm” poster=”http://ben.akrin.com/videos/slomo_bird.mp4.jpg” width=”640″ height=”360″]

I.T. ben August 02, 2018

PHP file upload to a Google storage bucket

Download

bucket_upload_1.0.php.gz

Google setup & use

1- Create a storage bucket for the script to upload into

 

Go to the Google Cloud Console, click on “Storage”, “Browser”.

 

“Create Bucket”

 

Give it a name and click “Create”.

 

2- Create a service account for the script

Expand the “IAM & admin” section, click on “Service accounts”.

 

Click “Create Service Account”.

 

Give it a name, check “Furnish a new private key”, JSON, and click “Save”.

 

Save the JSON credentials file which you are prompted to download into a safe location.

3- Grant “Object Creator” permissions on the bucket to the service account

Go back to the storage bucket you created

 

Edit its permissions

 

The JSON credentials file you just downloaded contains the email for the service account you created, copy it.

 

And paste it into the “Add members” field, select the permission to be “Storage Object Creator”. This service account doesn’t need permissions for anything else than dumping files in there. Not even viewing them.

 

Optional: if you want the files uploaded by the script to be publicly viewable, add the permission “Storage Object Viewer” to the user “allUsers”. Accounts are all referred to by email in Google land, but there exist special keywords such as “allUsers”.

Done with the Google setup 🙂

4- Running the script

If you haven’t already, download the script at the top of this page. Decompress it and edit the config at the top.

$credentials_file_path is the full path to the JSON credentials file you got from Google when you created the service account. It should be a secure location.

$destination_bucket_name is the name of the bucket you created

$access_token_cache_file_path is a location where Google’s OAuth tokens are cached, it too should be a secure location.

Run the script with only 1 argument being the file you want to upload. The script can also be included and used outside of CLI, in that case simply call the upload( $filename ) function.

The script returns the URL to the file in the bucket.

VoilĂ :

I.T., web development ben July 31, 2018

A small milestone

The millionth penstroke on Mandalagaba since the code rewrite last February

There’s more data I’d like to pull out of this. For example the average length of a stroke, average time, how many human lives where spent drawing mandalas, et cetera :).

self sustainability ben July 31, 2018

Counter Measures

The fauna has taken a huge bite out of our work this year. A woodchuck ate the garden, crows ravaged the blueberry plants, deer went after young fruit trees & currants, finally a racoon simply killed all the keets and didn’t even eat them. One animal after another has gone after our work and voided much of it, this is the first year this happens to such a scale and it is making us feel besieged.

It’s interesting just how much brutal competition there is in nature. I used to think of nature as an idealized garden of Eden, but it’s closer to a ruthless competition which often ends in death. I despise man’s expansionist dominance over nature, yet living closer to nature means participating in the competition. Hawks circles over our baby, ticks & mosquitoes suck our blood, raccoons take out our flocks, deer reap the fruits of our sweat. I’m fine with letting nature get its share but nature is perfectly fine taking it all. I don’t enjoy exerting human dominance but I can’t let that go, it’s time to be more aggressive.

 

Intel gathering

 

The little fuckers parade around the chicken coop like they own the place

 

Unfortunately not at a set time at which I could throw them a little welcome party

 

A trap does stay up all night, notice to pull string in case the skunk gets in there

 

Well at least I caught something with the box the trap came in

 

Super scary scarecrow

 

The trees are now in prison until they have more mass

building, self sustainability ben July 15, 2018

Protected: One more finished room

This content is password-protected. To view it, please enter the password below.

self sustainability ben July 04, 2018

Protected: Brutal heat wave

This content is password-protected. To view it, please enter the password below.

poultry, self sustainability ben July 01, 2018

Keets

The chickens were “gifted back to nature” last Winter. No egg production and a new baby in the house brought this shortcut we didn’t like taking.

I’ve updated the list of traditions and cultural artifacts I understood since moving to Vermont for the occasion. It made me understand how so many religions have the concept of sacrificing animals to deities, and the idea of offerings to gods in general. I heard the coyotes come from the next hill over the same night and rejoice at the bounty. I never had issues with coyotes, coincidence? I think not. Everything happening at night feels supernatural. It’s not the first time we take animals deep into the forest to be cleaned up, and this was likely a frequent occurrence in the lives of humans when religions popped up.

We’re populating the coop this time with Guinea Hens. Apparently they’re like guard dogs, but they also eat ticks, and snakes, and they require little feeding.

I.T., web development ben June 23, 2018

An HTML5 canvas Flood Fill that doesn’t kill the browser

I took the longest time implementing the fill tool  on Mandalagaba. How hard could it be? Recurse through pixels looking for a color and update them to a new color.

While this method certainly works and is easy to implement, it is also extremely slow. Slow in a way that hangs the browser, yielding infamous messages from the browser.

Here we’ll take a look at various Javascript flood fill implementations along with their drawbacks. Jump to #4 if you are only interested in the best one.

2018-10-04 – edit – added fill algorithm #5 which proposes an alternate approach to filling pixel by pixel. Depending on your project it may or may not serve your needs better.

In all cases, the code is available in the example iframe, look for the function flood_fill.

1. Simple Recursive

Not much to explain here, we simply recursively call the function on adjacent pixels when they match the color we are trying to fill over.

Click to change color / pop-out link

It’s reasonably fast but the problem with this one is that any fill area slightly large yields too much recursion which breaks subsequent JS. This Canvas box is 200x200px and at 300x300px, Firefox complained about:It’s easy to see how this implementation will not satisfy a reasonably featured paint program. Even if your browser let you stack more function on the heap, I would bet it would lead to slowness.

2. Iterative

We simply take the previous idea of looking at adjacent pixels and filling them, and make it iterative instead so the function calls don’t get stacked to a ceiling.

Click to change color / pop-out link

The problem with this is is that is is sloooow. So slow it stalls browser. Most of time is spent having to keep track of pixels_stack. Recursion doesn’t have that need but as we’ve seen, it has other issues.

3. Recursive-Iterative (AKA catch-your-breath iterative)

This is a twist on #2 which every so often, recurses on itself via a setTimeout to let the browser catch it breath a little. It also yields a cool visual effect.

Click to change color / pop-out link

I really like the visual effect, and it makes the slowness tolerable. But the issue is that Mandalagaba has a network engine and allows for re-rendering of one’s work. So synchronization is a big deal, and you know what makes synchronization easy? Not having to worry about it.

So as long as I can help it, my life is a lot easier if the operations the users can perform are atomic. Operations need to be able to be processed one after the other counting on the fact that the ones that came before have completed.

The first 2 solutions are atomic but suck; this 3rd one, however cool it may be, isn’t.

4. The Holy Grail

I’m not sure where this algorithm originated from, but I’ve gotten to know it on this web page which explains it very well (with GIFs!). It is iterative and goes about finding pixels to fill in a much smarter way.

Click to change color / pop-out link

That’s it, no drawback here 🙂 I’ve tested it on large canvasses and this is what is implemented on Mandalagaba. Now of course, in a real application there is a ton more complexity dealing with smoothing edges and blending alpha. I only wanted to expose boiled down versions of these algorithms so they are easier to wrap your mind around.

5. The Holier Grail?

While #4 is fastest algorithm for filling pixel by pixel, I found myself in the need to have a fill operation in for form of a path which is filled with the native HTML5 canvas capabilities. This algorithm is a bit different from all the other ones in that it doesn’t go through every pixel and fills it. What it does is pathfinding to draw the outline of the shape of be filled, and then simply calls the native canvas fill() function. It does come with certain drawbacks and so I wouldn’t recommend it unless you specifically need this sort of approach.

Click to change color / pop-out link

Feel free to ask questions in the comments.

agriculture, self sustainability ben June 19, 2018

Haying Fever

I’m getting good at changing implements

[mejsvideo mp4=”http://ben.akrin.com/videos/haying_fever.mov.mp4″ ogg=”http://ben.akrin.com/videos/haying_fever.mov.ogv” webm=”http://ben.akrin.com/videos/haying_fever.mov.webm” poster=”http://ben.akrin.com/videos/haying_fever.mov.jpg” width=”640″ height=”360″]

A nightmare if you’re allergic to pollen

Stuck in the mud once more… The truck will pull it out.

Take 2, with board to help not sink in. We need more culverts.

Off we go! later suckers, me & my tractor have got some fields to mow.

self sustainability ben June 19, 2018

Chestnut leaves

All 3 chestnut saplings are looking great with fresh new leaves.

agriculture, self sustainability ben June 12, 2018

Garlic Baby

Farmer baby is satisfied with the garlic inspection.

agriculture, self sustainability ben June 12, 2018

Black gold

From one Vermont hill

To our Vermont hill

Featuring: some guy with a giant ass tractor

Compost is gold, we haven’t been so good at making our own and the raspberries haven’t grown so well. This year we’re trying to pamper them more by weeding them more aggressively and making sure they’ve got more than enough nutrients in the soil.

building, self sustainability ben June 12, 2018

Room flooring

This is a bedroom a kid will grow up and become a teenager in, I laid tongue and groove pine because I could use the hardest of woods, there will be holes through it. I figured it’ll be easier to be ok with the damage if it’s not super expensive wood. The result looks great but it will wear faster. I love the angles in that room, Robin has not been in it for weeks, we’re keeping it a surprise and will have a ribbon cutting ceremony in a couple of days.

The old crowbar helping straighten up recalcitrant boards

Working in tight spaces

Construction baby managing the crew

building, self sustainability ben June 01, 2018

A first in 3 years

A nicely finished room, no visible insulation, studs or vapor barrier. It is incredibly satisfying to work on finishing a room. Since we now have enough space in the house, all the others will follow. We are done making temporary arrangements.

A guide for the circular is incredibly useful for making rip cuts.

How trims are born

Finer work is super satisfying

I opened the windows and discovered the view a few weeks ago, giving them a nice frame makes it all the more enjoyable.

nature encounters ben May 31, 2018

Snake on a food coma

I kicked this guy out from under the outside shower, it was incredibly hard to get it moving. Then I noticed the bump on his body, thank you for taking care of rodents snake bro.

nature encounters ben May 28, 2018

The Robins really like that spot

They’re back every year laying in the same few trees. A little higher this year.

self sustainability, water ben May 14, 2018

Protected: Flowering marsh, a nascent swim hole & the incredible prospect of getting the tractor over the stream

This content is password-protected. To view it, please enter the password below.

maple syrup, nature encounters, self sustainability ben May 14, 2018

Maple seedling

Something is making this year an excellent one for maples to come out of the ground. Maple seedlings are everywhere.

self sustainability ben May 14, 2018

Marking rocks to save mower blades

I’ll pop them out when the backhoe is attached. I took a lots of rocks out and these are the last ones :).

agriculture, self sustainability ben May 11, 2018

18 more blueberries in the ground

all out geekery, I.T. ben May 05, 2018

Nosy Monster alive and well

The Nosy Monster has been sitting on my desk idle for a while now, I’ve always wanted to work on it a bit and make it more reactive to web input. Finally, I bit the bullet and it’s now a lot smoother to operate. Instead of clicking for pre-timed commands, the start of a key press actuates and the end stops. With a websocket communication layer and a socket python command server, the commands find their way from keyboard to motors super fast.

To account for wireless imperfections and AP hopping, I also wrote the logic such that there isn’t a “start” and a “stop” command. Instead there is only a “start” command which gets sent every 200ms and if it isn’t heard every 300ms, Nosy Monster stops. This ensures it won’t be locked in a state of actuation which could lead to perilous situations.

I intend on polishing the code & publish a tutorial that hopefully a 7 year old could handle.

The Nosy Monster was deployed at the Dartmouth Thayer School of Engineering’s open house. I didn’t know how robust it was going to be under sustained kid use.

It turned out to be a huge hit, I let the kids drive it around a bit and then I’d throw the Nosy Monster in another room where they would have to find their way around with no visibility other than the camera. It performed flawlessly through the evening.

It’s always an enormous point of satisfaction to see kids get into something you made. Once I sent the RC car “to Mars” (the other room), the kids were really focused.  All but one got stuck and never came home. I should have had a prize for the one, but what’s next, participation trophies?

With a much more usable and reliable toy, I decided to setup the same kind of maze in a house room under construction.

I moved the camera up on a stick for a better angle of vision, the next model will have a fisheye camera.

Without a reverse, it takes a few tries to get through the maze without getting stuck. He had to learn to be careful.

I’m bubbling up with ideas  of cool things to do with the concept and acquired techniques. From a solar powered exterior land rover, to battle bots.

agriculture, self sustainability ben April 28, 2018

Oddly fascinated by the leaves

We’ve been watching an excellent crowdfunded documentary series called Woodlanders. It brought to our attention a guy working to reintroduce the chestnut tree to American forests. We couldn’t believe it was even possible to acquire young chestnuts so we pretty much had to place an order. It arrived this week and to our surprise it still had leaves from the season previous. This is when it hit us what it meant to be planting this.

aesthetics ben April 24, 2018

Mandala session on a huge touch screen

Posts pagination

← Previous 1 … 25 26 27 … 52 Next →

This blog is solar powered

Interactive

Handwriting Capture
Mandalagaba
IPv6 link-local to MAC converter
IPv6 MAC to link-local converter
Markov Text Generation
Markov Word Generation
Markov Music Generation
Duplogrifier
Flood Fill Algorithms
Homestead Metrics
RGB Playground
Web Games

Categories

  • aesthetics111
    • plots54
    • specular holography6
  • Books3
  • I.T.202
    • 3D modeling / printing21
    • AI6
    • all out geekery36
    • electronics27
    • homestead automation6
    • maniacal paranoia25
    • plotters49
    • unix / linux29
    • video games4
    • web development29
    • web games3
  • Lego / Duplo67
  • life in the U.S.42
  • miscellaneous202
  • nature encounters114
  • old vinyls3
  • organs2
  • self sustainability561
    • agriculture106
    • apiculture38
    • apple20
    • building131
    • canning3
    • crochet6
    • foraging6
    • hunting10
    • maple syrup47
    • poultry39
    • preserving2
    • solar power28
    • water23
    • wood84
  • trip to a new life6
  • Uncategorized2
Theme by Bloompixel. Proudly Powered by WordPress