Skip to content

Instantly share code, notes, and snippets.

Repeat = {};
Repeat.__noSuchMethod__ = function __noSuchMethod__ (id, args) {
var numTimes = /x([0-9]+)/.exec(id);
if (numTimes != null) {
for (var i = 0;i < numTimes[1]; i++) {
if (typeof args[0] == 'function') {
args[0]();
} else {
system.console.log(args[0]);
}
// prototype
new Ajax.Request("/your/mom", onSuccess: function(response) { $("lightbox_content").innerHTML = response.responseJSON.contents })
// jquery
$.getJSON("/your/mom", function(json) { $("#lightbox_content").html(json.contents) })
// XUI
x$(window).xhrjson( "/your/mom", {map:{'contents':'#lightbox_content'} });
system.use("com.joyent.Sammy");
function resources( name , options) {
// var db = new DebugConsole();
// system.console.log(db.processMessage(this.name));
name = name.toLowerCase();
// Using XUI FX - Tween
x$('#add').click(function(){
// This fails, blue fires before red is finished
x$('#baz').tween({ background:'red' }).tween({ background:'blue'});
// This also doesn't work as expected.
x$('#baz').tween([{ background:'red' },{ background:'blue'}]);
});
+ show me your pic
- ^addMessageProp(icon_url, http://laorquesta.mx/wp-content/uploads/2014/12/bikers-300x225.jpg) Does this make you smile?
@silentrob
silentrob / bootstraper.js
Created January 24, 2015 23:37
Creating a boot file for a superscript bot
var facts = require("sfacts");
var fs = require("fs");
var worldData = [
'./data/concepts.top',
'./data/names.top',
'./data/oppisite.tbl',
'./data/worlddata/animals.tbl',
'./data/worlddata/color.tbl'
];
@silentrob
silentrob / weather.js
Created December 22, 2014 08:08
weather.js
var request = require("request");
exports.weather = function(cb) {
if (this.message.names) {
var location = this.message.names[0]
request.get("http://api.openweathermap.org/data/2.5/find?q="+location+"&type=like&units=metric&mode=json", function(err, res, body) {
var results = JSON.parse(body);
if (results.list.length != 0) {
cb(null, "It is " + results.list[0]['weather'][0]['description']);
} else {
cb(null, "I'm not near a window.");
@silentrob
silentrob / gist:528e1fcddfb5749817e3
Created December 11, 2014 23:55
telnet superscript example
// Run this and then telnet to localhost:2000 and chat with the bot
var net = require("net");
var superscript = require("superscript");
var debug = require('debug')("Server");
var options = {};
var facts = require("sfacts");
var factSystem = facts.explore("britfacts");
@silentrob
silentrob / gist:ad795eb955c9f6478814
Created December 11, 2014 23:44
Weather Plugin
var request = require("request");
debug = require("debug")("Weather Plugin");
exports.weather = function(city, cb) {
request.get("http://api.openweathermap.org/data/2.5/find?q="+city+"&type=like&mode=json", function(err, res, body) {
// debug("Weather Results", body);
var results = JSON.parse(body);
if (results.list.length != 0) {
cb(null, "It is " + results.list[0]['weather'][0]['description']);
} else {
@silentrob
silentrob / plugins
Last active August 29, 2015 14:07
SuperScript Plugin Example
+ custom function
- ^runCode()
// When the input "custom function" is seen, we call the function runCode() from the plugin folder.
exports.runCode = function(cb) {
cb(err, reply);
}
// Data can also be passed into the function like this: