Skip to content

Instantly share code, notes, and snippets.

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";
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";
// 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);
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);
});
describe('Crypt', function () {
describe('#getPrice("169")', function () {
it('should return a number not NaN', function () {
should.be.a.Number(crypt.getPrice('169'));
})
})
})
function parseDiv($div) { // blocking
var $nick = $div('b span');
var $msg = $div('span:last');
var message = {
nick: {
$e: $nick,
text: $nick.text()
},
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,
int *get_move()
{
const int moves[4][2] = {
{ 1, 0}, // North
{ 0, 1}, // East
{-1, 0}, // South
{ 0, -1} // West
};
int move;
(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)
)))
@t3h2mas
t3h2mas / app.js
Last active August 29, 2015 14:15
$(function () {
var model = {
init: function () {
if (!localStorage.cats) {
localStorage.cats = JSON.stringify([]);
}
},
add: function (obj) {
var data = JSON.parse(localStorage.cats);
data.push(obj);