Skip to content

Instantly share code, notes, and snippets.

View scoates's full-sized avatar

Sean Coates scoates

View GitHub Profile
@scoates
scoates / gist:1711131
Created January 31, 2012 15:40 — forked from chartjes/gist:1711104
Hands On Node File System Exercise #3
var fs = require('fs');
function readBytes(filename, position) {
fs.open(filename, 'r', function(err, fd) {
if (err) {
console.log(err.message);
return;
}
var readBuffer = new Buffer(5);
<?php
/**
* Sends statistics to the stats daemon over UDP
*
**/
class StatsD {
/**
@scoates
scoates / Stack.php
Created December 12, 2010 21:24 — forked from stenehall/New stack
<?php
/*
* README
* mkdir one && mkdir two && mkdir three && touch one/blueprint-1.3.css && touch one/foobar.css && touch two/jquery.js && touch three/jquery-1.4.js
*
*/
include('stack.php');
var Step = require('./lib/step');
Step(
function () { console.log("one"); },
function () { console.log("two"); }
);
browser
.chain
.session()
.and(function (browser) { // log out
try {
browser
.open('/')
.assertElementPresent('link=Log out')
.clickAndWait('link=Log out')
.assertElementPresent('link=Log in')
browser
.chain
.session()
.and(function (browser) {
browser
.chain
.open('/')
.assertElementPresent('link=Log out')
.clickAndWait('link=Log out')
.assertElementPresent('link=Log in')
sarcasm:~/src/tmp$ cat repl.js
repl = require("repl");
repl.start("testrepl> ");
sarcasm:~/src/tmp$ node repl.js
testrepl> 5+5
10
testrepl> sarcasm:~/src/tmp$ echo "5+5" | node repl.js
node.js:63
throw e;
var readline = require('readline');
module.exports = readline;
readline.Interface.prototype.cursorToEnd = function() {
// place the cursor at the end of the current line
this.output.write(
'\x1b[0G\x1b[' + (
this._promptLength + this.line.length
) + 'C'