Short source code examples

This Sencha Store Ajax JSON proxy reader/writer example comes from the link shown. It shows how to use:

This code shows how to dynamically add a hidden field to a form with Sencha ExtJS 4:

A Sencha ExtJS checkboxgroup and checkbox listener example:

A Sencha ExtJS checkbox listener and textfield example. First, the checkbox and textfield definitions:

    fieldLabel: 'myCheckBox'
    xtype: 'checkbox',
    name: 'myCheckBox'
    fieldLabel: 'myTextField'
    xtype: 'textfield',
    name: 'myTextField',
    disabled: true

Next, how to add a listener to the checkbox, and enable or disable the textfield when the checkbox is clicked:

Here’s a Sencha ExtJS form panel (Ext.form.Panel) example, using an hbox layout:

Here are some Sencha ExtJS Model examples, from the official Sencha docs.

Define a User:

This Sencha ExtJS code snippet shows how to use the Ext.Element down method to get the value from a textfield:

I know remarkably little about using JSHint with Sublime Text 2 at the moment, but I finally found that if I installed JSHint like this from the command line:

$ npm install -g jshint

after earlier installing JSHint from within Sublime Text 2, JSHint magically started working in Sublime Text.

I guessed this in part by finding a README file with the Sublime Text JSHint install:

To display an alert message dialog in Sencha Ext JS (ExtJS), use code like the following:

Ext.Msg.alert('Dialog Title', 'Your body text goes here ...');

This displays a simple JavaScript-like message dialog.

Source code for a Sencha Touch 2 native dialog:{
    title: 'One Button',
    message: 'This is a simple notification with one button.'

This example comes from this URL.

This is like an Ext.Msg dialog, but native instead. See!/api/Ext.Msg for more information.

Here's a quick Sencha Touch 2 Carousel example:

Here's an example of a Sencha Touch 2 List view that's populated with static data:

Ext.create('Ext.List', {
    store: {
        fields: ['name'],
        data: [
            {name: 'Notes'},
            {name: 'To-Do List'},
            {name: 'Contacts'},

    itemTpl: '{name}'

Something like this could be used for a list of data items, or menu items.

This example comes from this link.

As a quick note, to use the Scala Swing library (scala.swing.*) with an SBT project, all I had to do today was add this line to my SBT build.sbt file:

libraryDependencies += "org.scala-lang" % "scala-swing" % "2.10+"

Once I did that, I was able to compile the Scala Swing project normally with the sbt compile command.

I just saw this code that shows how to declare an empty immutable SortedSet in Scala, and wanted to save it as a helpful snippet here:

 * The node ring gossipped that contains only members that are Up.
var nodes: immutable.SortedSet[Address] = immutable.SortedSet.empty

Here’s a simple Scala call-by-name example. I’ll show the normal approach to writing a method and passing in a parameter, and then show a call-by-name (pass by name) example.

1) A “normal” Scala method (call-by-value)

Here I show how to pass a parameter to a method “normally,” i.e., call by value:

The classic book, Programming in Scala, states that you need to be careful about using var fields when defining equals methods. They specifically state:

Pitfall #3: Defining equals in terms of mutable fields.

Personally, I think I've always defined equals methods with mutable fields, at least in Java. They share the following source code example that demonstrates a problem when defining an equals method in a Scala class when used in a collection.

This is a quick example of how to use the geolocation web service at using Scala:

 * an example of how to use the geolocation web service at
 * using scala
object GetRestContent extends App {

  val url = ""
  val result =


I don't show how to handle the JSON string in this example, but if you search this website you'll find other Scala JSON examples.

Here's a snippet of Scala code I use to get a list of all files beneath a given directory: