Skip to content

Instantly share code, notes, and snippets.

Sean Coates scoates

Block or report user

Report or block scoates

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View custom_readline.js
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'
View Node REPL stdin?
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;
View gist:615392
browser
.chain
.session()
.and(function (browser) {
browser
.chain
.open('/')
.assertElementPresent('link=Log out')
.clickAndWait('link=Log out')
.assertElementPresent('link=Log in')
View gist:615412
browser
.chain
.session()
.and(function (browser) { // log out
try {
browser
.open('/')
.assertElementPresent('link=Log out')
.clickAndWait('link=Log out')
.assertElementPresent('link=Log in')
View gist:616188
var Step = require('./lib/step');
Step(
function () { console.log("one"); },
function () { console.log("two"); }
);
View Stack.php
<?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');
View gist:989357
<?php
/**
* Sends statistics to the stats daemon over UDP
*
**/
class StatsD {
/**
@scoates
scoates / gist:1711131
Created Jan 31, 2012 — forked from chartjes/gist:1711104
Hands On Node File System Exercise #3
View gist:1711131
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);
@scoates
scoates / gist:3355357
Created Aug 15, 2012
MongoDB: findandmodify seems to use the wrong query on the update command
View gist:3355357
> db.runCommand({ findAndModify: 'assets', query: {$or: [ { "_id" : "4ff70c97c87a97bc7f000002" }, { "_id" : ObjectId("4ff70c97c87a97bc7f000002") } ]}, update: {$set: {private: true}}, new: true, upsert: false })
{
"lastErrorObject" : {
"updatedExisting" : true,
"n" : 1,
"connectionId" : 1317,
"err" : null,
"ok" : 1
},
"value" : {
@scoates
scoates / timeline
Last active Dec 10, 2015
Times each line of stdin
View timeline
#!/usr/bin/env python
import time
from sys import stdin, stdout, argv, exit
try:
if argv[1] == 'help' or argv[1] == '--help' or argv[1] == '-h':
print "%s: times each line of stdin.\n Optional parameter is a float of a threshold. (defaults to 2.0)" % argv[0]
exit(255);
else:
You can’t perform that action at this time.