Bash-Shell.Net

I'm a developer, not a writer

Configuration and Architecture Experiments

by justin on Sept. 12, 2017, 11:21 p.m. UTC

I've recently been playing with new tools for configuration management and deployment, both at work and with my own projects. These include Docker, Ansible, and an InfluxDB/Telegraf/Grafana stack. I have been using all them for production in house tools at work as well as this blog.

I first got started with Docker using it at work. It works great as a production environment. I can make an image which is easily deployable anywhere Docker is found. Configuration of images and containers is dead simple, rarely more complex than writing a bash script. After years of fighting with ...

→ read more

Django Fractions Has A User!

by justin on Jan. 1, 2017, 3:13 a.m. UTC

I got my first bug report for Django Fractions.  That's awesome!  It means someone uses it and finds it useful enough to report a bug!  The bug was that it was not playing nicely at all with forms in the django admin site (or elsewhere using a ModelForm, most likely).  I fixed it and learned a bit more about Django's internals.

The base fix was to implement the formfield() method on djfractions.models.fields.DecimalFractionField.  That in itself took a bit more work than expected and in the end I stopped subclassing the built in ...

→ read more

Django Mail Viewer Released!

by justin on Dec. 23, 2016, 10:08 p.m. UTC

So I've been delayed on my promised Phoenix for Django Devs post, but I've got something else fun instead.

One of the challenges when developing Django apps is email testing.  Having to actually send emails and check in your real email client is kind of a hassle and always risks accidentally sending an email to an incorrect person.  You can use something like mailtrap.io, which at least ensures the email will never get to an incorrect person and provides some great functionality, but you still need a network connection and have somewhere else to log in to ...

→ read more

Running Injuries And Starting More Phoenix Posts

by justin on Nov. 6, 2016, 1:11 a.m. UTC

I started trying to post stuff more regularly awhile back.  I did well for a few posts and then it died off.  I am finally starting to write up the promised follow up post to my previous post about how to implement nested changesets in Phoenix and comparing and contrasting that to using Django InlineFormsets.  I have all of the actual work done, but I am now going through my code and cleaning it up.  The current code has a lot of "it works, move on" sloppiness to it, so I have to clean that up ...

→ read more

Phoenix for Django Devs: Inline FormSet Via Nested Changesets Part 1

by justin on Sept. 17, 2016, 11:18 p.m. UTC

A pretty common use case is to create or edit a main object while also manipulating a list of related objects.  On the database side the list of objects usually have a foreign key back to your main object's table.  Using Django the form, data validation, and saving is handled with a ModelForm while related object saving is handled via an inlineformset_factory.  Previous version of Phoenix did not have a very elegant solution to solving the same problem.  Posts on Stack Overflow and elsewhere detailed manually handling transactions to create the parent object, then validate the ...

→ read more

Phoenix for Django Devs: The {% block %} Tag

by justin on Sept. 5, 2016, 4:05 p.m. UTC

Last night I came up with a solution for the specific problem of page or template specific javascript in Phoenix, which I posted here.  When I woke up this morning I realized that the more generic problem was simulating the {% block %} template tag.  So to expand upon the example from my previous post, a top level parent Django template (without lots of elements to keep it clear) might look like this.

<html>
  <body>
    Common page elements and text here
    {% block content %}Page specific content gets displayed here.{% endblock content %}

    Some more common page elements.

    <!-- Now ...
→ read more

Phoenix for Django Devs: Per Page JavaScript Without The Mess

by justin on Sept. 5, 2016, 3:47 a.m. UTC

When I work on a Django project I normally have a simple block at the bottom of my base template which is empty, something like so:

<html>
  <body>
    Common page elements and text here
    {% block content %}{% endblock content %}
    Some more common page elements such as a site footer, etc. here.
    <!-- Load jquery, etc. whatever common js to every page here -->
    <!-- now this block is overridden in child templates to load page specific external js or in page js -->
    {% block page_js %}{% endblock page_js %}
  </body>
</html> 

And then child templates ...

→ read more

New Balance Fresh Foam Vongo Followup

by justin on Aug. 21, 2016, 1:40 p.m. UTC

I've put about 250 miles on these shoes now and they are great.  Knee pain I've been battling with since starting running seriously is gone and I've increased my mileage.  I wish the forefoot/toe area was a little more flexible and I have some concerns about how the insole is wearing.  The sole/tread has a large open gap down the middle and the insole shows a visible crease right there as well.  I do need to try out a bit larger shoe next time, though.  I am currently using a 12 2E, but ...

→ read more

New Balance Fresh Foam Vongo 1st Run

by justin on June 25, 2016, 3:36 p.m. UTC

I've kept the rare posts on this blog technical, but I'm expanding in hopes of having more to say.  Back in August or September 2015 I started running fairly seriously.  Since then I have been on the search for running shoes which don't suck.  I have wide, flat feet, with additional weird bones on the outsides near the middle which stick our further than on anyone else I have spoken with about it.  It makes it hard to find decent shoes which fit.  Additionally I've been fighting with knee pain... possibly due to over pronation ...

→ read more

What's Going On?

by justin on May 14, 2016, 2:44 a.m. UTC

Alright, so I finished my final class for my Associate's Degree in Computer Science after many years of slowly taking classes while working full time and having a child.  It's awesome.  I decided to immediately fill up my free time by modernizing the code running bash-shell.net a bit.  It's still nothing fancy, but doesn't need to be.  I finally updated Django to 1.9, generally reorganized code, added ssl using letsencrypt, and tonight I added django-wysiwyg to hopefully make posting easier and encourage me to do so.

I hope to continue to improve bash-shell.net's ...

→ read more

Reworking The Code

by justin on May 7, 2016, 12:13 p.m. UTC

Just a small post here. Finally done with school and work has begun on updating the code for this blog. I am moving models and apps around to align with how I would do it these days, use newer features, etc. My hope is to get this thing in a state where I really would like to post more.

The first step has been moving apps around. I will then strip out some older functionality like get_user_profile() and use a custom user model, get rid of South and update to a modern Django version, add in a nice text editor ...

→ read more

Django-Fractions

by justin on Aug. 1, 2015, 8:58 a.m. UTC

I just put my latest project, django-fractions, up on github. It's a set of tools for manipulating fractions on Django sites. It is not fully fleshed out yet, needs test cases, etc. This was extracted from a separate (yet to be made public) project and code which was specific to that project. It's useful and works well enough as is, so I figured I should take the first step and get it on github, which will hopefully inspire me to finish cleaning it up.

→ read more

RequireJS Shared Modules and Cache Busting with Django-Require

by justin on Aug. 26, 2014, 2:55 a.m. UTC

I've recently been experimenting with using RequireJS in a Django environment. The biggest hurdle I ran across was cache busting and that I'm using a multi-page setup, with some shared js, and knockout with a viewmodel for handling the navbar which is on every page. Django-Require comes with two classes for managing static files, OptimizedStaticFilesStorage and OptimizedCachedStaticFilesStorage, the latter of which provides hashed filenames so that as your files change long cache times don't cause stale files to be served. The OptimizedCachedStaticFilesStorage only works when using the require template tag which comes as part of django-require.

In ...

→ read more

Django, CORS, and CSRF Validation

by justin on Aug. 16, 2014, 7:41 p.m. UTC

This week I had the need to build some functionality on a Django site where a small part of the site would live on a subdomain. So, for example, if the main site was on example.com, this new bit needed to be on abc.example.com. The two parts of the site share sessions, cookies, and so on and abc.example.com needs to be able to make POST requests to AJAX form handlers on example.com (with a bit of an exception I'll get to in a moment).

For the domain and subdomain with share sessions the ...

→ read more

RequireJS and Django

by justin on May 5, 2014, 1:49 a.m. UTC

I just finished converting one of my projects over to using RequireJS. I've been moving towards more Javascript heavy stuff lately and keeping all of the dependencies in order has begun to get very messy. RequireJS seemed to be the standard way of managing this, so I decided to give it a try on one of my side projects (which will hopefully go live soon-ish).

RequireJS basically gives you about as close as you're going to get to includes in other languages implemented in Javascript. Overall it works very well, with just a couple of small, easy to ...

→ read more
Member of The Internet Defense League