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 blessed = require('blessed'); | |
var screen = blessed.screen(); | |
// FOR THE GLORY OF THE LOG | |
var fs = require('fs'); | |
var log = require('npmlog'); | |
var stream = fs.createWriteStream('loggit.duh'); | |
log.stream = stream; | |
log.heading = "node irclient"; |
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 blessed = require('blessed'); | |
var screen = blessed.screen(); | |
// FOR THE GLORY OF THE LOG | |
var fs = require('fs'); | |
var log = require('npmlog'); | |
var stream = fs.createWriteStream('loggit.duh'); | |
log.stream = stream; | |
log.heading = "node irclient"; |
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
// One | |
function getMarket(mrkt, callback) { | |
request('http://xyzzy.net/api.php?method=singlemarketdata&marketid=' + mrkt, callback); | |
} | |
// Two | |
function getMarket(mrkt, callback) { | |
request('http://xyzzy.net/api.php?...=' + mrkt, function (error, response, body) { | |
// handle error | |
callback(body); |
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
function getPrice(market) { // make w/ callback? | |
// do work | |
return getMarket(market, function (data) { | |
//if (data.sucess != 1) throw new Error('problem getting market'); | |
sellPrice = data.return.markets.MARKETID.lellorders[0].price; // .RDD? | |
console.log(sellPrice); | |
return Number(sellPrice); | |
}); |
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
describe('Crypt', function () { | |
describe('#getPrice("169")', function () { | |
it('should return a number not NaN', function () { | |
should.be.a.Number(crypt.getPrice('169')); | |
}) | |
}) | |
}) |
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
function parseDiv($div) { // blocking | |
var $nick = $div('b span'); | |
var $msg = $div('span:last'); | |
var message = { | |
nick: { | |
$e: $nick, | |
text: $nick.text() | |
}, |
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 nonce = "NONCE STRING HERE. FOUND IN PAGE SOURCE"; | |
function sendMessage(text) { | |
$.ajax({ | |
type: "GET", | |
url: '/users/ajaxsendchat', | |
dataType: 'json', | |
async: true, | |
data: {"nonce": nonce, |
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
int *get_move() | |
{ | |
const int moves[4][2] = { | |
{ 1, 0}, // North | |
{ 0, 1}, // East | |
{-1, 0}, // South | |
{ 0, -1} // West | |
}; | |
int move; |
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
(defn y-or-n-p [prompt] | |
(do | |
(setv answer (get (.lower (raw_input prompt)) 0)) | |
(if (in answer (, "y" "n")) | |
answer | |
(y-or-n-p prompt) | |
))) |
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
$(function () { | |
var model = { | |
init: function () { | |
if (!localStorage.cats) { | |
localStorage.cats = JSON.stringify([]); | |
} | |
}, | |
add: function (obj) { | |
var data = JSON.parse(localStorage.cats); | |
data.push(obj); |