var tfs = require('tfs')
, cp = require('child_process');
suite.add('recursively iterate through files', function(deferred) {
tfs.glob('node_modules/**/*.js', function() {
deferred.resolve();
});
}, options);
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.BeforeClass; | |
import org.junit.Test; | |
import org.vertx.java.core.Handler; | |
import org.vertx.java.core.Vertx; | |
import org.vertx.java.deploy.impl.VertxLocator; | |
public class PromiseTests { | |
private Object lock = new Object(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.jewelsea.examples.jruby.fruit; | |
import javafx.fxml.FXML; | |
import javafx.scene.control.ComboBox; | |
import javafx.scene.control.Label; | |
import javafx.scene.image.ImageView; | |
/** JavaFX fxml controller for fruit combo fxml demo application. */ | |
public class FruitComboController { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Register a new package: | |
Tower.Package.register -> | |
# Require some core modules: | |
fs = require("fs") | |
path = require("path") | |
# Add information to the package. | |
@info | |
name: "Auth" |
In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.
A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval
.
You can find instance_eval
used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.
class Article < ActiveRecord::Base
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var serialport = require('node-serialport') | |
var sp = new serialport.SerialPort("/dev/ttyO3", { | |
parser: serialport.parsers.raw, | |
baud: 9600 | |
}) | |
sp.on('data', function(chunk) { | |
console.log(chunk.toString('hex'), chunk.toString(), chunk) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original version is here: https://gist.github.com/1358093 | |
require 'jrubyfx' | |
require 'jrubyfx/dsl' | |
class AnalogClock | |
include JRubyFX | |
include JRubyFX::DSL | |
def start(stage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro flip-flop (left right) | |
"Evaluates to false until the left test is satisfied. Then evaluates to true until the right test is satisfied, etc." | |
;; create a collision-safe name for our state variable | |
(let ((state-var (gensym))) | |
;; create a toplevel variable to keep state of flip-flop | |
`(progn | |
(defvar ,state-var nil)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Step 1: | |
** Place (only one) Titanium API lib (from jsca2js package) in: | |
** /path/to/project_root/.codeintel/libs | |
*/ | |
/* Step 2: | |
** Create text file: /path/to/project_root/.codeintel/config | |
*/ | |
{ | |
"JavaScript": { |