If you’re trying to learn Clojure(Script) and Om, perhaps using the otherwise fantastic Om Basic Tutorial, you may (if you skipped certain steps of the tutorial) run into the following error:
1
Uncaught Error: Cannot manipulate cursor outside of render phase, only om.core/transact!, om.core/update!, and cljs.core/deref operations are allowed
If you do, you’re likely running one of the older versions of Om that are on the main clojars repositories, as opposed to the current version (as of February 1st), 0.8.6.
To fix this error, just update your project.clj file from referencing [om "0.7.X"] to referencing [org.omcljs/om "0.8.6"]. Make sure to re-start your REPL.
I recently purchased a Brother MFC-L2700DW Printer/Scanner/Fax combination monstrosity.
It’s an inexpensive black and white laser printer, perfect for the occasional home based business printing of tax forms and contracts.
Getting it set up on Linux (Xubuntu 14.10) was a tad fiddly.
First, I connected the printer to my local network and printed a self-test page by printing the Fax and Copy buttons together.
This confirmed that the printer can in fact print.
To make sure that the printer is connected to the network and visible, you can go to the ‘Printers’ dialogue and click ‘Add’.
In the pop-up menu, select ‘Network Printer’ - the list will take some time to populate.
On my system, it took about 15 seconds.
If you see two options for “Brother MFC-L2700DW …”, the printer is visible on the network.
Don’t set up the printer this way!
The MFC-L2700 is not in the printer database, at least not that I could find.
Instead, go to the brother website, select “Linux” / “Linux (deb”) as your operating system, and download two files.
First, download and install the “Generic LPR Printer Driver”.
Then download and install the “Generic CUPSwrapper printer driver”.
Once both of these are installed, the printer should appear automatically in your list of printers in the printers dialogue.
However, it will default to expecting to being connected via USB.
If you want to connect via the network, you can open the printer properties, and select “Change” next to the “Device URI” box.
Then, navigate to the “Network Printer” section again, wait for the list to populate, and select the second of the two Brother options.
When you hit “Apply”, it won’t show the change in the “Device URI:” dialogue, but it will have changed.
Just hit “Print Test Page” to confirm that your printer is working, and click “OK” to exit.
If you re-open the properties dialogue, you should see the updated Device URI beginning with “dnssd://”.
Enjoy the new printer!
(So far I have not been able to get network scanning working.)
Ruby on Rails supports the ability to be extended through the use of libraries, which are packaged as ‘gems’ and included in your ‘Gemfile’.
This much is well known.
Rails also has, depending on the version, engines and/or plugins.
Engines are ‘subapplications’ that can have their own models, controllers, and views 1
Plugins are gems that extend the core Rails classes - before engines came along, if you wanted to add views and controllers to a gem, you’d make it a plugin.
So, how do we make a gem that can extend rails applications with views, controllers, and the rest?
What we want to do is create an ‘engine’ packaged as a ‘gem’.
I’ve found that the documentation on this process isn’t quite as good as the documentation for the rest of the rails API.
Perhaps because creating an engine is a little bit more of an advanced topic, and much of the documentation for Rails is of the ‘blog in fifteen minutes variety’ 2.
In Rails 3.1+ we should be able to create the skeleton of a plugin (actually an engine) with the following command 3:
1
rails plugin new engine_name --full
Helpfully, this command to create your engine skeleton will tell you that validations have failed: FIXME or TODO is not an author.
This is referring to the required fields in your brand new engine_name/engine_name.gemspec file, which asks for an author and author email.
You can edit the engine_name/engine_name.gemspec file to update this information now.
You’ll have to update all the lines that include TODO or FIXME: s.authors, s.email, s.homepage, s.summary, and s.description.
Your new rails engine is a gem.
So, it can be pushed to rubygems.org to be shared with the entire world.
Which is fantastic!
Unless you’re working on client code, or patented code, or otherwise can’t share.
If that’s the case, you should be able to add the following line: to your .gemspec:
This will disable pushes 4.
You can still work on your gem locally.
If you later decide you need to make your gem available to some servers and collaborators but no the entire world, consider a service like Gemfury
You can still push the gem to a git repository, of course.
To do so, follow the usual steps: git init ., git add -A, git commit, git remote add, git push, and so on.
If you do this, you can actually install the gem from other machines that have read access to the git repository, though it might be a tad slower than installing directly from a gem server.
If you do push your new engine to a git repository, you can install it in a rails application you control by adding the following line to your Gemfile:
One of the rails projects I am working on requires user-selectable ‘skins’ (or themes).
This could mean that the HTML depends on a user setting, but for early stage development, we’re going to do the minimal option that could possibly work: when users select a ‘skin’, all they select is a CSS file.
CSS is surprisingly powerful. With display: none; and visibility: hidden, we could hide different parts of the site. We can change colors and sizes of elements as well.
Until there is a business case for needing to generate differing HTML based on a user-selectable theme, this will probably work.
What will we need to implement this?
We’ll need some set of themes - which will be .css (or, really, .scss) files.
We need the application to be aware of the possible skin options, and provide a form element somewhere that allows the user to choose a theme.
The app needs to persist their choice to the application database.
Then, the application needs to render the appropriate theme on every page view, choosing the appropriate file.
There are two ways we could store a list of themes.
We could store them in some configuration file somewhere, for example a .yml file in the config directory, perhaps themes.yml.
Or we could check to see which themes are actually available in the themes CSS folder when the application starts.
The latter method has the advantage of making sure that the list of available themes is always consistent with the list of themes displayed.
But the former method would allow us to have partial theme files in the themes CSS folder, perhaps ones that are unfinished.
I’ll take the easier maintenance trade - let’s load the list of themes based on the files that are in the folder.
We’ll put our skin css files in app/assets/stylesheets/themes. Then, we can load the list of files with:
The first line just gets the absolute file path in a convenient way.
The second gets a list of files.
The third strips out everything except the file name itself, so that we can display the skin name to the user.
(There’s probably a better way to do this somewhere in the Ruby or Rails API.)
We need to make sure that these files are included in Rail’s asset pipeline.
Throw a couple CSS files in the app/assets/stylesheets/themes folder, and make sure that your defauilt app/assets/stylesheets/application.scss file isn’t auto-including the theme files.
You can do this by moving your other css to a sub-directory of app/assets/stylesheets/ and then changing require_tree . in application.scss to require_tree ./<subdirectory>.
You’ll need to re-start your development server after adding the initialization file.
Then we can present a selectable list in the appropriate as so (using simple_form):
Fill in the appropriate details - the above line has to be wrapped in a form, of course, and skin needs to be allowed through Rails 4’s strong_params, and so on.
Today I discovered the Jadoo Box via a post on r/linux. It is, apparently, a set-top box that caters almost exclusively to people interested in viewing television from South Asia and India in North America. After all, from the website, “Jadoo4 is the best South Asian IPTV box out there.”
This statement taught me three things:
Jadoo4 is the best South Asian IPTV box out there
Thus there are competing South Asian IPTV boxes
There is an entire technology market that I had no idea existed.
I had no idea this market existed. No inkling. Granted, I have no idea how many units the Jadoo Box has sold. Given that they are currently on version 4, I’m assuming it is quite a few.
I have no real reason to have been aware of the existence of the Jadoo Box. But I consider myself well read, and the fact that I have not even heard of the South Asian IPTV market is bothersome.
Specialization took us from the mid 1600s (when there was so little to learn that you could lump everything under “Philosophy”) to the mid 1900s - as late as 1906, Albert Einstein could essentially single-handedly advance a wide field like ‘physics’ substantially.
Technology is by definition on the bleeding edge of human activity. But today it moves so fast that it is thoroughly beyond the comprehension of any individual. There is too much to know: ignorance is inevitable.