Short source code examples

Without much introduction or discussion, here’s an example of how to use Scala’s Try, Success, and Failure classes:

I used the following Scala source code to build a semi-transparent dialog (a Java JFrame, actually) for the second version of Sarah:

Yesterday I needed to be able to specify a port with a git clone command, because the git server runs ssh on a non-standard port. In short, the solution was to put this text in my ~/.ssh/config file:

I get stock quotes on my Radio Pi system with this simple Python script:

These are some notes on how I installed a Play Framework + MongoDB application on a Linux server at A2 Hosting. These notes probably won’t make sense to other people, they’re just here for me. (Sorry about that, I don’t have a great way to post things here just for myself.)

Here are the notes:

Here’s a quick Linux Bash if/else example featuring an or clause:


day_of_week=`date +"%a"`

if [ "$day_of_week" == "Sat" ] || [ "$day_of_week" == "Sat" ]; then
  echo 'Weekend!'
  echo 'Not weekend!'

The if/or clause is similar to other if/or expressions, and uses the || syntax shown.

Until now I haven’t had a Sencha Touch app.js example out here, so here’s one:

I normally don’t like to throw large blocks of code out here, but the following Sencha Touch source code shows how to use the refs config parameter.

refs documentation

Before getting to the source code, here are the refs comments you’ll find in the code:

"In the refs configuration, you can set up references to view instances. This allows you to retrieve and manipulate components on the page inside of your controller’s actions."


The following Sencha Touch code shows how to define a Store, where the store references a model, has a proxy, and also uses some configuration parameters to help control the REST/GET URL/URI the store generates:

The following controller code shows how I dynamically render radio buttons in a Sencha Touch controller. Just scroll down and look for the recordedStreamsStore.each block of code:

The following code shows my current Sencha Touch utilities. Much of it comes from a Packt book I can’t remember the name of, but several of the JavaScript functions are my own:

This code shows how to add a title bar (titlebar) to a Sencha Touch panel:

The following code shows how I created a tab panel in a Sencha Touch application, with a few important parts highlighted:

The Sencha website has a few good examples of how to use an ActionSheet, including this basic one:

The following code shows how I set the margins on a Sencha Touch component (an item in a list of items):

    xtype: 'container',
    style: 'text-align: left; margin-left: 26px; margin-top:14px;',
    html: '<div>Funny - 20<br/>Voted Yes, But Not Worth It - 2</div>',
    id: 'checkboxView',

As shown, you do this by setting the style on the component.

It seems like the following code should have also worked, but it didn’t:

Nothing major to see here, but some Linux xscreensaver commands I don’t want to forget:

# download an xscreensaver package
$ sudo apt-get install xscreensaver-data-extra

# restart xscreensaver
$ pkill xscreensaver && xscreensaver -nosplash &

This example shows how to URL-encode HTTP query parameters using Ext.urlEncode in a Sencha ExtJS (or Touch) application:

Here is a small collection of Sencha ExtJS ‘Store’ objects from a recent project. I suspect they will also work with Sencha Touch, though I haven’t tried them there yet. (They may need a few small modifications, dunno.) I share them here hoping they will help anyone who needs to see some =Store= examples.

First, this Store object is named Users:

As a quick example of how to loop over each element in a Sencha Touch or ExtJS store, I use the following code to dynamically create a series of checkboxes.

In short, in a Sencha controller:

Ext.define('Focus.controller.Projects', {
    extend: '',

I declare a Store:

stores: [

then later create a reference to the Store:

This source code shows how to use the Sencha Touch Ext.XTemplate: