Skip to content

Instantly share code, notes, and snippets.

View jason-s13r's full-sized avatar

Jason Schwarzenberger jason-s13r

View GitHub Profile
@jason-s13r
jason-s13r / constants.js
Created November 7, 2012 01:30
@js gist: loading test.
self.Constants = function () {
var _constants = {};
return {
get: function (name) {
return _constants[name];
},
add: function (name, value) {
if(typeof _constants[name] != "undefined") {
return value;
}
@jason-s13r
jason-s13r / ideas.md
Created November 7, 2012 01:16
Some xbot + javascript ideas

So @passcod added the ability JavaScript variables to be persistent across resets by storing them in the DB and loading them again.

We could go a bit further than just the attacks and attack_results arrays.

JavaScript Modules

Consider LOLcryption as a JavaScript library that extends xbot.

It could be possible to store the LOLcryption.js file in the database as a dynamically added JS libary.

@jason-s13r
jason-s13r / ghetto.js
Created November 6, 2012 11:38
ghetto, based on xbot's !ghetto
var ghetto = function(str, part) {
var gTable = ghettoTable;
return str.split(" ").map(function(T) {
function tr(U) {
return gTable[U.toLowerCase()] || U
}
if(part === true) {
return T.length < 5 ? T : T.substring(0, Math.ceil(T.length * 0.75)) + "-" + T.substring(Math.ceil(T.length * 0.75)).split("").map(tr).join("")
}else {
return T.split("").map(tr).join("")
@jason-s13r
jason-s13r / attack.js
Created November 6, 2012 08:46
xbot js attack ;)
var attack = function (to) {
var user = to || Object.keys(bot.users)[Math.floor(Object.keys(bot.users).length * Math.random())];
var attack = attacks[Math.floor(attacks.length * Math.random())];
return attack.replace(/\{defender\}/g, user)
.replace(/\{attacker\}/g, bot.caller)
.replace(/{year}/g, Math.round(Math.random() * 10000) + (Math.random() * 100 < 35 ? "BC" : ""));
};
@jason-s13r
jason-s13r / LOLcryption.js
Created November 2, 2012 21:18 — forked from passcod/LOLcryption.js
enLOLcryption.
String.prototype.enlolcrypt2 = function () {
var cipher = "aeoiubcdfghjklmnpqrstvwxyz";
return this.split("").map(function (T) {
var c = /[A-Z]/.test(T), T = T.toLowerCase(), i = cipher.indexOf(T);
if (/[^a-z]/.test(T)) { return T; }
if (/[aeoiu]/.test(T)) {
T = cipher[(i+2)%5];
} else {
T = cipher[(i+5)%21+5];
@jason-s13r
jason-s13r / LOLcryption.js
Created November 2, 2012 08:23 — forked from passcod/LOLcryption.js
enLOLcryption.
String.prototype.enlolcrypt2 = function () {
var cipher = "aeoiubcdfghjklmnpqrstvwxyz";
return this.split("").map(function (T) {
var c = /[A-Z]/.test(T), T = T.toLowerCase(), i = cipher.indexOf(T);
if (/[^a-z]/.test(T)) { return T; }
if (/[aeoiu]/.test(T)) {
T = cipher[(i+2)%5];
} else {
T = cipher[(i+5)%21+5];
@jason-s13r
jason-s13r / LOLcryption.js
Created November 2, 2012 08:09 — forked from passcod/LOLcryption.js
enLOLcryption.
String.prototype.enlolcrypt2 = function () {
var cipher = "aeoiubcdfghjklmnpqrstvwxyz";
return this.split("").map(function (T) {
var c = /[A-Z]/.test(T), T = T.toLowerCase(), i = cipher.indexOf(T);
if (/[^a-z]/.test(T)) { return T; }
if (/[aeoiu]/.test(T)) {
T = cipher[(i+2)%5];
} else {
T = cipher[(i+5)%21+5];
@jason-s13r
jason-s13r / Array.prototype.js
Created October 30, 2012 06:25
doing !js this.toSource() on woot then http://jsbeautifier.org/
Array.prototype.reduce = function (c) {
if(null === this || void 0 === this) {
throw new TypeError("O is null or undefined");
}
var a = 0,
d = this.length >> 0,
b;
if("function" !== typeof c) {
throw new TypeError("1st arg is not callable");
}
@jason-s13r
jason-s13r / calendar.lua
Created August 2, 2012 10:24
Practising lua by making a calendar thing.
#!/usr/bin/env lua
function february(year)
if year == nil or year == "context" then year = os.date("%Y"); end
if year%4==0 and (year%100~=0 or year%400==0) then
return 29
else
return 28
end
end
@jason-s13r
jason-s13r / linked_list.html
Created November 1, 2011 11:15
Linked List in JavaScript.
<!DOCTYPE HTML>
<html>
<head>
<title>Linked List</title>
<script type="text/javascript"><!--
function ListNode(data) {
this.data = data;
this.next = null;
this.previous = null;