Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Sunday, March 17, 2019

A rewrite of the Ruby example programs from the Tcl/Tk tutorial at TkDocs

Arguably, for the Ruby computer programming language, the default graphical user interface (GUI) toolkit is Tk (a part of Tcl/Tk). A high-level toolkit, it is cross-platform as well. Some ways of installing Ruby include Tk automatically.

Tk has been given a beautiful introduction in a tutorial by Mark Roseman at TkDocs. Begun in 2008 (its full history can be seen here), it covers multiple languages: Perl 5, Python 3, Ruby, and Tcl.

Roseman's tutorial provides eighteen (18) code examples. They are all written in each of the four languages listed above. Naturally, the code is written in a way which eschews each language's idiomatic features. At least, uncomfortably, I experienced this for Ruby!

In order to learn more fully how to use Tk, I borrowed the tutorial's Ruby example code and rewrote it, using the kind of programming style I might use for production. All eighteen of the resulting Ruby production-style example programs (each in its own file) together comprise my GitHub repository, tutorial-tkdocs.

Copyright (c) 2019 Mark D. Blackwell.

Wednesday, August 1, 2018

Install Ruby and Git For Windows on Windows XP, howto

Here's how to install the last binary releases, of both Ruby and Git for Windows, which work on 32-bit Windows XP (SP3):


Copyright (c) 2018 Mark D. Blackwell.

Saturday, September 3, 2016

Cygwin on Windows XP, howto

If you've damaged your Cygwin installation on Windows XP recently by doing a normal Cygwin update (as I did), here's how to recover.

Normally, Cygwin's program, setup(-x86).exe installs the latest version of their Cygwin DLL.

However, the last release of the Cygwin DLL which still works on Windows XP was version 2.5.2-1 (released June 23, 2016). The next release was 2.6.0-1 (on August 31, 2016), and it doesn't work on Windows XP.

First, back up (perhaps using 7-Zip) your Cygwin etc/ and home/ directories to a safe location (outside your Cygwin installation).

Then rename your Cygwin directory, to get it out of the way.

Download the latest setup(-x86).exe as usual from the Cygwin web site.

Add the option flag --no-verify to the shortcut you use for it, and run it. On its "Choose a Download Site" screen, enter (as a User URL):

http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2016/08/30/104223/

Click the "Add" button and "Next". It will say:
  1. "The current ini file is from a newer version of setup-x86.exe" and
  2. "This setup is version 2.873, but setup.ini claims version 2.874 is available."
Ignore those warnings.

After you're satisfied it's working for you, you can delete your old, renamed Cygwin directory.

For more information, see these two pages by Peter Castro, the creator of the Cygwin Time Machine.

EDIT: Regarding the screen, "Choose a Download Site", I've updated the "User URL".

Copyright (c) 2016, 2018 Mark D. Blackwell.

Tuesday, September 23, 2014

Visual project design & reporting & Pivotal Tracker with add-ons

UML

Some business owners wish to see diagrams which can explain the software structure of a project visually. In those cases, UML is a good choice:

  http://en.wikipedia.org/wiki/Unified_Modeling_Language
  http://en.wikipedia.org/wiki/Applications_of_UML

The following (kinds of) UML diagram are useful for that purpose:

  http://en.wikipedia.org/wiki/Activity_diagram
  http://en.wikipedia.org/wiki/Component_diagram
  http://en.wikipedia.org/wiki/Sequence_diagram
  http://en.wikipedia.org/wiki/Use_Case_Diagram

VISUAL PARADIGM

Often, business owners are attracted to the tool, Visual Paradigm. Unfortunately, it is quite expensive.

The tool itself isn't web-based, but the company (free of charge) offers VPository, cloud storage for developers working collaboratively.

IMO, a download for each user is fine in itself if the project data is shared.

Its Professional Edition is the minimum practical level to obtain the features which business owners often are interested in: Requirements Gathering ("uexceler"), Task Management, and Wireframes.

Regarding Visual Paradigm's cost factor, they levy a surcharge to receive bug fixes for their software. (Like all software, I suppose it's buggy.) Therefore, currently the Single Seat License for the Professional Edition is really $838.50 per person (= $699 + $139.50). Floating Licenses—for transient project contributors—are $1,090.00 each (= $908.50 + $181.50. All prices are in US dollars.).

Maybe using Visual Paradigm is really taking things too far.

Basecamp can maintain a project glossary as a versioned, editable file.

For most projects, the database schema diagram can be auto-generated (at least once) and stored in Basecamp.

Perhaps User Stories, and images for each wireframe block, can be tied together in some easy fashion (see "Add-ons adding pictures to User Stories", below).

TOOLS SIMILAR TO VISUAL PARADIGM

I came across this list of tools similar to Visual Paradigm. Of them, the following might be useful:

  http://www.gentleware.com/uml-software-community-edition.html
  http://www.modeliosoft.com/en/products/features.html
  http://www.softwareideas.net/en/features/

PIVOTAL TRACKER

Because Pivotal Tracker is quite successful (or popular), people have contributed quite a large number of add-ons:

Add-ons adding pictures to User Stories:
  http://blog.snapengage.com/2010/03/pivotal-tracker-snapashot-integration/
  https://trackduck.com/en/content/integrations/pivotaltracker/
  https://usersnap.com/pivotaltracker

Add-ons adding User Stories from plain text:
  https://github.com/gabehollombe/Pivotxt
  https://github.com/hashrocket/slurper

Add-ons dumping User Stories:
  https://gist.github.com/glarrain/5861055

Add-ons for bugs:
  http://bugdigger.com/pivotal/
  http://bugherd.com/blog/bugherd-and-pivotal-tracker-best-of-friends/
  http://www.redline.cc/

Add-ons for reporting:
  https://www.dashofagile.com/pivotaltracker
  http://www.easy-insight.com/solutions/PivotalTracker.html
  https://github.com/jimlindstrom/Tracker-Dashboard
  https://www.in-sight.io/
  http://www.just-facts.co/#tabs-services
  http://support.leftronic.com/customer/portal/articles/1120034-create-a-pivotal-tracker-dashboard
  https://www.leftronic.com/services/pivotal-tracker/
  https://www.prodpad.com/2013/05/integrate-with-jira-trello-and-pivotal-tracker/
  http://apps.splunk.com/app/1584/
  http://start-software.com/tracker/modules/tracker-dashboard/
  https://www.tenxer.com/how/
  https://www.tenxer.com/what/
  http://www.timecamp.com/blog/index.php/2012/11/
      log-time-on-a-story-card-in-pivotal-tracker-and-timecamp-integration/


Add-ons for testing:
  http://www.gurock.com/testrail/
  http://www.testlodge.com/

Add-ons liaising other sites with Pivotal Tracker, also with Basecamp:
  http://www.redline.cc/
  http://www.testlodge.com/
  https://trackduck.com/en/content/integrations/basecamp/

Add-ons liaising with Cucumber:
  https://github.com/tpope/pickler

Add-ons liaising with GitHub:
  https://github.com/getvega/Pivothub
  https://github.com/stevenharman/git_tracker
  https://github.com/zauberlabs/gh-pivotal-integration

Add-ons liaising with Redbooth:
  https://help.redbooth.com/hc/en-us/articles/200752732-Pivotal-Tracker-Integration

Add-ons liaising with Redmine:
  https://github.com/capita/redmine_trackmine

Other relevant add-ons:
  http://blog.aha.io/index.php/aha-integrated-with-pivotal-tracker-for-visual-product-roadmaps/
  http://blog.busyflow.com/2012/01/16/the-benefits-of-a-deep-pivotal-tracker-integration/
  https://github.com/bimovidia/planning-poker
  https://github.com/joncooper/lorem-tracker
  https://github.com/nathanmcdaniel/pivotalstuff/tree/master/viewallmywork
  https://chrome.google.com/webstore/detail/
      clone-stories-for-pivotal/mpaldiblbgdmmnolghhbohicignfhimb

  https://chrome.google.com/webstore/detail/
      easy-copy-for-pivotal-tra/mmlaaianjmomeolpmmhdcmjnnmmoalbh

  https://code.google.com/p/mastercontrol/
  http://hojoki.com/
  https://www.honeybadger.io/
  http://sluglug.com/
  https://storymapper.io/

OTHER POSSIBLY INTERESTING PLANNING TOOLS

  http://www.clarizen.com/project-management-solutions/agile-project-management.html
  http://www.clockingit.com/screenshots
  http://www.goplanapp.com/home/features
  http://www.huddle.com/product-overview/
  http://leankit.com/product/
  http://www.mangoapps.com/features
  https://www.planbox.com/tour/
  http://planship.com/
  https://pmrobot.com/features
  http://www.strikebase.com/
  http://www.thymer.com/why/
  https://trello.com/
  https://www.ubirimi.com/
  https://www.ubirimi.com/product/agile
  https://www.ubirimi.com/product/documentador
  https://www.ubirimi.com/product/yongo
  http://www.versionone.com/product/agile-collaboration-tools/
  http://www.versionone.com/product/agile-visualization/
  http://www.webplanner.com/site/index.php
  http://wholemeal.co.nz/projects/fulcrum.html
  http://www.zoho.com/

TRACK DUCK

Track Duck (highly popular) allows people to add comments to any website, after it automatically takes a screen shot.

Track Duck integrates with Pivotal Tracker and Basecamp, etc.

With it, one easily can add (one or multiple) images to Pivotal Tracker User Stories, and also create images for Basecamp. But see other "Add-ons adding pictures to User Stories", above.

Reviews of Track Duck:
  http://techcrunch.com/2014/02/17/
      trackduck-a-tiny-web-site-build-tracking-startup-appears-to-be-on-a-roll/

  http://goaleurope.com/2014/02/04/
      lithuanian-trackduck-launches-new-version-of-its-interactive-website-feedback-tool/


Copyright (c) 2014 Mark D. Blackwell.

Tuesday, January 7, 2014

GitHub should ease line-specific links to the latest commit while browsing master

While (naturally) browsing on branch 'master', GitHub currently requires three(!) clicks to generate any line-specific link for future (permanent) use. These clicks are: History, Browse code (at the top of the history list), and (again) clicking the desired line.

But (only) rarely do people follow these three (extra) steps.

You can blame people (posters) for not following these extra steps, but (as a matter of human nature, IMHO) we can't expect most people actually to follow them, because currently (as they observe it) their gathered links are correct. They merely become obsolete over time.

In practice, this screws up blog and StackOverflow posts, etc. which contain links to specific locations inside source code (on GitHub). For most of these links, their reasonable use is to point to source code (sometimes source lines) visible in the latest commit. Yet these posters (almost always) gather links which actually point to an evolving branch (usually 'master'). As source code evolves, these links quickly become obsolete.

This obsolescence is especially bad with line-specific links, but also happens for file-specific ones.

Here let me say that GitHub's wonderfully good UI is GitHub's greatest and best feature! :)

But the clumsiness of this detail of GitHub's UI (here) is at fault IMHO for this problem. :(

I tried to enlist StackExchange's help to argue this case with GitHub, but to no avail. Also, I asked GitHub directly. We shall see.

This screwup (of obsolete links in people's posts) is apparent, bothersome, and quite frequent!

As a solution, GitHub should consider implementing the following UI improvement:

Make generating such permanent, line-specific links (in browsers' address bars) much easier for their users by adding a button (to all source-display web pages on branches). This button (with a single click) would:
  • Switch from viewing the source code (including a line reference) on a branch, to viewing that source code (including the same line reference) in a blob. To be helpful, that blob must be the latest commit of that branch.

GitHub already distinguishes branch heads from blobs. This is apparent in GitHub's sometime use of the word 'blob' as an URL path segment name (versus the words 'commits/master').

Therefore, GitHub seems easily able to find the latest commit SHA1 for a given branch and do what is desired here: that is, redirect the browser to the corresponding line in the latest commit.

UPDATE: Just four(!) hours later, this nice reply came back from a GitHub staffperson:

"Great idea, thanks! There is a shortcut key "y" that you can hit on any code page to change the URL to the permanent link. But you're right that people may not always choose to do that.

"I've added your idea to our internal Feature Request List. We can't say if/when we may add a feature, however your feedback has definitely been recorded."

Although GitHub's pages don't present this feature in an obvious way, GitHub's Help here further describes their 'Y' shortcut key's hidden access (to it) that she's talking about.

UPDATE: StackExchange support replied with:

I'm not entirely certain what you were trying to accomplish with that post. First, it was on meta.stackoverflow.com, where users go to talk about Stack Overflow itself. We discuss features, community governance, file bugs and similar activities on meta.

However, your post would not have been on topic for Stack Overflow either, it's a complaint about how Github works, as far as I can tell, not a question. We're not a typical forum, we're a Q&A site. To get a better idea of how our engine works, take a brief tour of the features.

Sorry that you had a bad experience, but there's not much we can do about it at this point. If you've got a succinct programming question where the problem can be demonstrated with a short code snippet, you're more than welcome to ask on Stack Overflow. If you have a question about Stack Overflow itself, how it works, or an idea to improve it - then feel free to post on meta.

Regards
Stack Exchange Team

I replied to StackExchange support with:

Hi, Team,
> it was on meta.stackoverflow.com, where users go to talk about Stack Overflow[.]
> about Stack Overflow itself, how it works, or an idea to improve it -
> then feel free to post on meta.
> it's a complaint about how Github works, as far as I can tell, not a question.

Yes, this is about StackExchange.

If you think about it, permanent links, including those to GitHub.com, comprise part of the business value of the StackExchange family of sites.

Your reply doesn't answer my suggestion that it's in the interest of StackExchange, the company, to try to encourage GitHub, the company, to improve their GUI, so that permanent links are easier (and less error-prone) to make.

I'm sure there are ways the staff of StackExchange can convey this interest (of the StackExchange company) to the staff of GitHub.

I cast about for how I can communicate this (I believe helpful) idea to the staff of StackExchange, and the two methods I tried (which you already know about) came to mind. Yes, I have contacted GitHub about this, but I am suggesting that StackExchange do this for itself, as well.

Who else can I contact, besides the StackExchange support team? Do tell!

> Sorry that you had a bad experience

To me, that has little importance. Much more important is the business suggestion for StackExchange, and (as you know) to improve the world, if I can.

From a reply from GitHub, I learned that hitting the 'Y' key switches their webpages to permanent links, easily.

For StackExchange, the problem is that accessing this GitHub switching functionality by hitting 'Y' is not widely known. So, in questions and answers on StackExchange, many people (perhaps) are sharing transient GitHub links.

GitHub may be reluctant to use a half-square inch of real estate on their webpages to make this functionality visible, since that visibility wouldn't help them directly.

But as good neighbors (or something like that) GitHub may be willing to "do the right thing," especially if StackExchange and Wikipedia, et al, ask them to. That's what I think.

Who knows whether GitHub might actually respond? Why doesn't StackExchange try? (i.e., for the purpose of aiding StackExchange's own business interest).

With warm regards,
Mark D. Blackwell

Copyright (c) 2014 Mark D. Blackwell.

Monday, July 8, 2013

Use file extension ".yml" for YAML

Generally, YAML files should be referred to by extension ".yml" (instead of ".yaml", if they have one).

Currently, any remaining use of the extension ".yaml" seems (in my view) slightly silly.

Commonly, the letter X is used for a great variety of meanings including "cross", "extensible", "variable", etc. (e.g. in XML). On the other hand, Y (e.g. in YML or YAML) carries no such extra baggage.

Relatively speaking, Y's use is rather uncommon. The acronym YACC comes to mind (for "Yet another compiler compiler"—BTW, its extension is simply ".y" when generating C language files). Actually, YACC assists more than it conflicts, because historically (as you may know) YAML was an acronym for the similar phrase, "Yet another markup language".

Linguistically speaking, therefore, the acronym "XML" has (in a way) only two informative letters. By contrast, all three of the letters of "YML" are fully informative. Indeed, the existing set of acronyms beginning with Y seems extremely small.

Per Wikipedia's article on information theory, "Abstractly, information can be thought of as the resolution of uncertainty." By implication, this is why a four letter YAML file extension feels greatly overspecified.

For the sake of completeness (though less important), this Ansible project comment (regarding their choice of extension) exemplifies other motivations:

> Three letter extensions owe historical relevance from DOS.
> They also save typing.

But these last two aren't the important reasons—instead, see above.

This comment (from March, 2014 in the Symphony project) also seems relevant:

> Once you have two of the biggest industry players doing ".yml" as the extension, it is the standard.

Information from the YAML.org website dates the organization's most recent activity to 2009 (approximately). Evidence of this comes from:

1. > © 2001-2006 YAML.org All Rights Reserved

2. > [The latest] News:
> 20-NOV-2011 -- JS-YAML, a JavaScript YAML parser by Alexey Zapparov and Vitaly Puzrin.

3. > [The latest] YAML Resources:
> YAML 1.2 (3rd Edition): http://yaml.org/spec/1.2/spec.html

Their latest specification (1.2 above) is from 2009, presumably before much of YAML's worldwide adoption:

> YAML Ain’t Markup Language (YAML™) Version 1.2
> 3rd Edition, Patched at 2009-10-01

Even their latest news item, the above-referenced JS-YAML, uses BTW the extension '.yml":

> var doc = require('/home/ixti/example.yml');

Therefore the staleness of YAML.org's information should greatly lessen the impact today from the recommendation in their FAQ:

> Is there an official extension for YAML files?
> FAQ
> 1. Please use ".yaml" when possible.

Here is a URL for web-searching the usage of the two YAML data file extensions (.yml and .yaml). I found time-wasting discussions of which extension to use here, here and here. Apparently these discussions are a result of the official organization exerting its influence uphill, against prevailing practice.

Maybe the public should complain. Maybe YAML.org would listen!

Here are merely some (of the many existing) usage examples of the shorter extension ".yml" in common use:

Per http://php-mysql-mvc.gajdaw.pl/instalacja/download/DoctrineExport.grt.lua:

> -- NOTES:
> -- 1. The YAML file extension usually is ".yml"

Per http://wiki.catalystframework.org/wiki/howtos/forms/formfu.view:

> NOTES:
> If you want a YAML file extension of .yaml (instead of .yml), you have to configure that.

Per https://code.google.com/p/javabuilders/issues/detail?id=114:

> The default YAML for most projects seems to be .yml, instead of .yaml.
> In NetBeans in particular, the YAML wizard only allows creating a file with a .yml extension

Per http://docs.doctrine-project.org/en/latest/reference/yaml-mapping.html:

> All mapping documents should get the extension ”.dcm.yml” to identify it as a Doctrine mapping file.
> $driver->setFileExtension('.yml');
> The Symfony project sponsored a driver that simplifies usage of the YAML Driver. The changes between the original driver are:
> File Extension is .orm.yml
> Filenames are shortened, “MyProject\Entities\User” will become User.orm.yml
> $driver->setGlobalBasename('global'); // global.orm.yml
> As a quick start, here is a small example document that makes use of several common elements:
> # Doctrine.Tests.ORM.Mapping.User.dcm.yml

Per http://www.fileinfo.com/extension/yaml:

> NOTE: YAML files more often use the .YML extension.

Per https://github.com/jasedit/rypple/issues/3:

> Configuration files should end in .yml, not .yaml
> That's the standard file ending, and should be consistent with expectations.

Per https://drupal.org/node/1935708:

> Posted by cweagans on March 6, 2013
> .info files are now .info.yml files

The only counterexample I have found (using ".yaml") comes from cPanel (in their EasyApache interface, apparently a cPanel product). Generally, cPanel seems somewhat "stuffy" and old-fashioned (i.e., likely to prefer the recommendation of an official organization over common usage). Per cPanel's EasyApacheHowToMoveProfiles:

> Profile are located in the /var/cpanel/easy/apache/profile/custom directory. The filename will be identical to the name you save it with, plus the .yaml file extension.

EDIT: The above reference is from the Wayback machine. However, as of August, 2016, we can still see cPanel using only extension ".yaml".

Copyright (c) 2013 Mark D. Blackwell.

Wednesday, July 3, 2013

Use Ruby-like Mirah to develop for Android

I have minimal experience in Android development—I have set up its development environment and merely compiled something that another has written. I work mainly in Ruby on Rails.

However, for the intrinsic joy from developing something on an Android device, I'm particularly interested in the language Mirah created by Charles Oliver Nutter (the developer of JRuby). I keep Mirah in mind, for whenever it will become practicable to use in Android development.

Perhaps Mirah is ready now—a Google search shows plenty of people using Mirah on Android.

Back in 2011, Nutter wrote an article about Mirah in Dr. Dobb's Journal. To sum up, this is a Ruby-like language designed in such a way that, for any program feature (or user feature) a programmer desires to implement, she would create a new keyword or plugin for the language (somewhat directly in the compiler—this being Mirah's main point of departure) rather than add a new Java package. And, it compiles to the JVM.

Therefore in Mirah (unlike in JRuby-based approaches such as Ruboto) no program needs a package or library beyond what is already in standard Java and Android. Programs written in it are extremely tiny (due to running without huge, additional language libraries) and they load and run (both) extremely quickly on Android devices (with their Dalvik Java virtual machine).

To use Mirah to build an Android app, see the Pindah project.

In order for someone to use Mirah (essentially syntax sugar on top of Java) BTW not only should they be familiar with Ruby, but they must also know Java well.

There's more about Mirah here:

For Android development, other JVM languages, Scala, Clojure, etc., as well as Ruboto, are also interesting.

Various StackOverflow questions relate to Android development using Mirah, JRuby, Ruboto, etc.:

Copyright (c) 2013 Mark D. Blackwell.

Friday, June 28, 2013

Ongoing open-source Rails secret_token vulnerability

Today I was re-alerted to a somewhat dangerous insecurity for open-source Rails apps if their Application.config.secret_token is kept under version control. The relevant file:

config/initializers/secret_token.rb

Rails itself generates this file in this way (without an entry in .gitignore) but it's still dangerous. There's lots of discussion here.

Presumably easily an environment variable could be set in config/application.yml (often kept out of version control) and retrieved at run time into config/initializers/secret_token.rb.

Remembering this would seem the only way to solve the problem and protect one's apps into the future from this known security vulnerability.

Here are Ruby on Rails Security Guide's recommendations:

'[P]lease secure your database configuration, e.g. config/database.yml, and your server-side secret, e.g. stored in config/initializers/secret_token.rb. You may want to further restrict access, using environment-specific versions of these files and any others that may contain sensitive information.' — per its Environmental Security section.

'If you have received an application where the secret was exposed (e.g. an application whose source was shared), strongly consider changing the secret.' — per its Session Storage section.

BTW, newly, Rails 4 has added Application.config.secret_key_base (described in the previous link and Guide for Upgrading Ruby on Rails' section, Action Pack).

'If you happen to share your code publicly, make sure your secret_key_base value is kept private.' — per this blog post.

Presumably, however, this new variable name setting does not remove the current security vulnerability either in Rails 3 or 4 since the Rails secret_token still is under version control.

Copyright (c) 2013 Mark D. Blackwell.

Wednesday, June 19, 2013

Raspberry Pi hobbyist computer

Just now (albeit belatedly) I came across a small, fun $35 computer for hobbyists: the Raspberry Pi.

Have you heard of it?

This recalls _why and others' passionate advocacy of "The Little Coder's Predicament" with projects such as hackety-hack that provide hackable computers again for children.

BTW, Raspberry Pi runs Debian Linux (wheezy).

Copyright (c) 2013 Mark D. Blackwell.

Tuesday, June 4, 2013

Blog posts' date position

Just now I was reading a blog to avoid emailing its author with questions they already blogged about. Like others with this purpose, I read it reverse-chronologically (i.e. from the top).

While reading a blog purposefully to learn the current status of a fast-changing software system it seems important to gather a quick sense of time context for each post.

Inevitably I observe myself sliding my browser window downward to the bottom of each post to get a sense of how long prior to the post above it each was released—just in case the time interval is much, much longer than those above.

Then I slide the window back, indeed with resulting uncertainty that I have recovered the proper beginning of the proper post.

Some blogs may never have a delay of more than two weeks between posts.

If I knew this were the case always I wouldn't even look. But since I am not sure, I find myself looking at the dates.

Viewing a blog's archive helps somewhat (and furthermore I can read a whole blog by clicking its posts in an archive list; but this seems less natural).

So the minor suggestion here, for blog formatters' consideration, comprises the usefulness of placing the date of each post immediately below its title.

Copyright (c) 2013 Mark D. Blackwell.

Tuesday, April 30, 2013

Essential jQUERY

Recently, I picked up the bare essentials in jQuery from the book, jQUERY Visual Quickstart Guide by Steven Holzner, Peachpit Press, 2009.

However, a word of warning: the book is somewhat badly edited, and there is no corrected edition (still as of this writing).

From the core jQuery source code, this page also is useful. Here are my brief notes:

JQuery refers to a certain syntax $(thing) for any thing as 'jQuery-wrapping'.

The keyword $ is an alias for jquery. Both are used in the following ways:

  • $(function)  –  Append a function to the list to be run when the document is ready: a shortcut for $(document).ready(function).

  • $(CSS-selector-string)  –  Select some nodes in the document.

  • $(HTML-string)  –  Create HTML for insertion.

  • $(DOM-node)  –  Like saying simply DOM-node, but change the value of this and set context (an attribute used by jQuery). Examples are:
    •   $(document)  –  The document.
    •   $(this)  –  this.

  • $.method  –  (This one has a dot and no parentheses.) Run a utility method.

The jQuery methods selected for explanation in the book are:

  • Methods on jQuery-wrapped collections of HTML elements:
    • addClass,  after,  alt,  animate,  append,  attr,  before,  bind,  clone,  css,  each,  (event binder methods),  fadeIn,  fadeOut,  fadeTo,  height,  hide,  hover,  html,  is,  (jQuery-UI methods),  length,  load,  one,  serializeArray,  show,  size,  slice,  slideDown,  slideToggle,  slideUp,  text,  toggle,  toggleClass,  unbind,  val,  width,  wrap

  • Event binder methods:
    • Keyboard   –   keydown,  keypress,  keyup

    • Mouse   –   mousedown,  mouseenter,  mouseleave,  mousemove,  mouseout,  mouseover,  mouseup

    • The rest   –   beforeunload,  blur,  change,  click,  dblclick,  error,  focus,  load,  resize,  scroll,  select,  submit,  unload

  • jQuery-UI methods:
    • accordian,  datepicker,  dialog,  progressbar,  slider,  tabs

  • Methods on jQuery-wrapped HTML strings:
    • insertAfter,  insertBefore

  • Utility methods:
    • ajax,  browser,  each,  get,  grep,  inArray,  isArray,  isFunction,  makeArray,  map,  post,  support,  trim,  unique

Copyright (c) 2013 Mark D. Blackwell.

Thursday, April 25, 2013

Meetup authentication & email addresses

As part of its OAuth authentication process with other apps, Meetup doesn't provide email addresses of its users. (I refer to this official Meetup forum question, and to this page in the Meetup API docs—search the page for 'email'.)

Twitter doesn't provide email addresses either. However, Meetup seems nicer than Twitter.

People use multiple Twitter accounts (I know some who do). But people don't use multiple Meetup accounts (at least supposedly not).

When registering new users through this difficult class of OAuth authentication providers (those which don't supply an email address) one might ask each new user directly for some email address, or might not. Requesting this is normally recommended.

If an app uses Meetup authentication (and it doesn't request and confirm an email address during user registration), and uses another form of authentication also (even added later) then there's no way to identify the same user, if or when they sign on by a different way.

So Meetup authentication (without email) is only good if the app is forever limited to using Meetup authentication alone. With that permanent limitation, in such an app, nobody (mysteriously) will run into the problem of having more than one account.

Of course, having Meetup as the single method of authentication is useful, reasonably, only to apps which are already limited to Meetup users.

Keeping the UI simple (by not requesting an email address when people register) means the app might never have email addresses. But that might be okay if an app uses Meetup authentication alone, forever.

Then one need not bother people with asking for their email address when they first use an app. The ease of that emotional UX moment when new customers are forming their first impression of an app (and making their initial commitment to it), from the standpoint of building a customer base—depending on the app—could be considered more important than ever knowing their email addresses.

BTW, omniauth-meetup is a good gem for doing Meetup authentication in Rails.

Copyright (c) 2013 Mark D. Blackwell.

Saturday, April 20, 2013

Flat UI and Twitter Bootstrap "Mobile First" for Rails

Designmodo's announcement for their free Flat UI (which uses Sass) mentions plans (in the discussion) to release a pay version containing LESS code. And an issue on their Flat UI gem floats a suggestion of possibly porting it to LESS.

Darthdeus' gem flat-ui-rails contains Flat UI precompiled to CSS with no LESS code.

Whether Flat UI will continue to be maintained and useful for Rails doesn't relate to Darthdeus' trivially easy to maintain gem but therefore instead to Designmodo's free Flat UI product itself. So far, BTW, their Pro version seems to be vaporware.

There is a rumor Twitter Bootstrap version 3 "Mobile first" will have a flatter UI, but that's only temporary (for development purposes) according to this article.

Web searching revealed no sign how Designmodo's Flat UI might be affected by Twitter's new "Mobile first" initiative otherwise.

Copyright (c) 2013 Mark D. Blackwell.

Friday, March 22, 2013

StackExchange family (including Stackoverflow) doesn't care about signout

I again registered a test account for 'Log in with Stack Exchange'.

Disappointingly, after logging out of every (SE family) site, it still lets me log in again merely by button clicks, while I type nothing.

After more than a year, clearly the managers of the Stack Exchange network family of websites don't give a hoot about protecting users of shared computers with a truly effective signout.

What if some rude person at a party click-logged into and deleted someone's account, thus trashing their vast accumulation of reputation?

Copyright (c) 2013 Mark D. Blackwell.

Wednesday, November 14, 2012

Node.js event loop does not poll

Node.js uses a well-known event loop, but does it work by polling? Some have that impression.

An event loop1 works by requesting its events from a message pump (per Wikipedia).

Here's how the event loop is implemented: 'Internally, node.js relies on libev to provide the event loop, which is supplemented by libeio[,] which uses pooled threads to provide asynchronous I/O.'2.

Here's Wikipedia's article on polling3 and another definition4.

Now, 'poll' is a system call which asks Unix to check a set of file descriptors:

'poll, ppoll - wait for some event on a file descriptor...If none of the events requested (and no error) has occurred for any of the file descriptors, then poll() blocks until one of the events occurs.'5

Possibly, the system call's name may have misled people into thinking a userland program is doing polling. Nevertheless, when the 'poll' (Unix system call) is invoked, this is not polling in itself.

Hypothetically, in order to get information from a message pump, an event loop could employ the Unix system call 'poll' to check a file descriptor, to which the message pump would write events.

Ultimately, this may be the source of the conceptual confusion here, or it may be caused by the fact that (actual) polling is the easiest method to think of, when programming.

For our case in particular, if an event loop calls Unix 'poll', this is not an instance of the event loop polling anything. Neither node.js, nor any event loop, but only Unix, polls the file descriptors (if indeed it even really does, anymore).

Anyway, an event loop, such as node.js's, does not poll its message pump. Instead, it merely makes a (blocking) request to it. Calling just any request 'polling' pollutes the meaning of the word (and that may be happening here.)

tl;dr – So, let's try anymore not to say that node.js is polling its events—okay? Instead, let's simply say that node.js waits for its events. (A lost cause, I know—but at least I've said it.)

1 http://en.wikipedia.org/wiki/Event_loop
2 http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/
3 http://en.wikipedia.org/wiki/Polling_%28computer_science%29
4 http://whatis.techtarget.com/definition/polling
5 http://linux.die.net/man/2/poll

Copyright (c) 2012 Mark D. Blackwell.

Wednesday, November 7, 2012

Install Opa language on 32-bit Debian squeeze, howto

The coolest feature of the Opa web programming language is that it automatically divides developers' programs into server and client sides, compiling to JavaScript.

Though the Opa compiler (as of this writing) doesn't have a 32-bit binary for Windows, I got it working in an easy way on (32-bit) Debian squeeze, after upgrading my nodejs installation.

Following Opa's instructions to install as a user (under the heading, Other Linux Distribution), I downloaded and ran their 32-bit Linux self-extracting package. When prompted, I chose to install it into ~/progra/mlstate-opa.

Then, after navigating to A tour of Opa in the sidebar, under the heading, Easy Workflow, I found and typed into a file, 'hello.opa' their sample program. The command:

$ opa hello.opa --

errored out, asking for more npm modules to be installed.

Rather than exactly following their suggested course of action, which would have installed node modules to root-owned directories, I typed:

$ npm install mongodb formidable nodemailer simplesmtp imap

After that the compiler worked just fine.

Copyright (c) 2012 Mark D. Blackwell.

Friday, November 2, 2012

PC timer for online tests, howto

I needed a timer to take online tests with (on an IBM PC).

And I found PC Timer. It seems ideal for this purpose:

http://www.brothersoft.com/the-pc-timer-1862.html

In order to alert me when a timed test is nearly over, I configured it to run this simple batch file:

@echo off
mode con: cols=100 lines=8
color 4e
echo .
echo .
echo "Time's up"
echo .
echo .
pause

Simple!

Presumably, it will be useful in timing other things, as well.

Beyond the timer, it also has two alarms (for moments, rather than durations, as of version 4.0).

Copyright (c) 2012 Mark D. Blackwell.

Monday, October 29, 2012

Free private hosting, howto

Recently, I came across this discussion of inexpensive alternatives for project source code hosting of private projects:

http://stackoverflow.com/questions/109440/best-git-repository-hosting-for-a-commercial-project

I investigated, and of those with apparent substance, the cheapest (actually free of charge for five users) is Bitbucket:

https://bitbucket.org/plans

I thought someone might appreciate a free alternative to GitHub for their private projects. If so, I recommend you follow these steps:

1. Download a backup of the current version of the source code, and save it on your computer. It should be available here:

https://github.com/{your username}/{your private project}/zipball/master

2. Open a free account with Bitbucket and there create a free, private repository (under your control, for your safety).

Possibly BitBucket will let your developers themselves push to the original repository, just as they can on GitHub.

Copyright (c) 2012 Mark D. Blackwell.

Friday, September 28, 2012

Frontend experience

Recently, I acquired some practical website frontend experience—which took quite a bit of learning!

For an initial demo for a startup, I analyzed, selected and set up all the infrastructure (Rails, Heroku & Amazon). I wrote all the CSS frontend. I also wrote all the working database backend.

See the demo! See how its layout is fluid?

(Click here, if you missed the above links.)

It doesn't have multiple user capability yet; it's just a demo, at this time.

I made this in the pursuit of becoming a does-everything website developer.

Copyright (c) 2012 Mark D. Blackwell.

Monday, September 17, 2012

Website page layouts, proofs of concept

A big part of frontend website development is implementing webpage layouts using CSS stylesheets (of course).

Recently, I've been experiencing a great deal more of business in the area of layouts (specifically for Rails websites) and especially the work of implementing these layouts through developing CSS stylesheets—whether or not this is really programming! (Well, I think it is.)

I find it much less efficient to run the Rails server, and much more efficient to 'web-browse' the local filesystem. The work progresses much more quickly, in other words, when it is isolated from any complicating factors arising from our misunderstanding of the Rails server, jQuery, ERB/HAML, and perhaps even Sass. The weightiest reason for this improvement (by far) is the troubleshooting principle: 'divide and conquer'. Less important is that the filesystem also is relatively quicker.

It is much more doable (dare I say, even feasible) to get isolated layouts working using pure CSS and HTML (while keeping class names simple). And the same is true while paring down a stylesheet to be as simple and clean as possible.

Of course, further simplifying cross-browser development is the use of a CSS-reset stylesheet. Also it is essential, for HTML5's semantic tags: header, footer and nav (etc.), to include a (JavaScript) HTML5 shim (or 'shiv') script. So I include both of these best practices.

I have prepared a repository of my CSS (layout) proofs of concept on GitHub—including nine(!) useful proofs (as of now, September, 2012).

These layout proofs contain stylesheet code the way I write for Rails projects as much as possible (without actually including Rails).

Copyright (c) 2012 Mark D. Blackwell.