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 / 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 / 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 / gist:4037648
Created November 8, 2012 08:58
My attempt at some sort of string builder for a chat thing.
// http://stackoverflow.com/questions/5306729/how-do-markov-chain-chatbots-work
// Following this answer to try and make something.
function Chat(dict) {
var dictionary = dict || {};
var add_words = function(str, dict) {
var i = 0;
var words = str.split(" ");
var first = words[i++];
var second = words[i++];
import util
from pubsub import pub
import re
import random
words_dict = {}
def add_words(bot):
global words_dict
i = 0
@jason-s13r
jason-s13r / gist:4058192
Created November 12, 2012 08:42
Playing with JS.
/*
var named = (function(n) { return namedArguments(arguments); })(5, 10);
named.n = 5
named["-1"] = (the arguments)
named[0] = 5
named[1] = 10
*/
function namedArguments(args) {
var params = args.callee.toString().replace(/function\ ?([A-Za-z_]+[A-Za-z0-9_]+)*\((.*)\)\ ?\{.*/, "$2");
params = params.split(/,\ ?/);
@jason-s13r
jason-s13r / toy hash.coffee
Last active October 13, 2015 07:18
just playing with things up to base90 :P
hash = (() ->
_alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!#$%&()*+,./:;<=>?@[]^_`{}~"'
toNum = (c) -> if (_alphabet.indexOf c) == -1 then '' else _alphabet.indexOf c
(text, salt) ->
str = (text + salt).split ""
hashed = (str.map (c) -> toNum(c) << 0x501).join ''
return (hashed * 1).toString(36)
)()
@jason-s13r
jason-s13r / gist:4249823
Created December 10, 2012 10:29
Trolling #ualug like a boss
* Jozza (de9b7013@gateway/web/freenode/ip.222.155.112.19) has joined
<Jozza> hi
<inkybutton> oh btw
<inkybutton> hi Jozza
<inkybutton> passcod, sysadmin emailed me asking if we still need VM
<Jozza> whats going on
<inkybutton> is it still possible to set up jekyll on it with our site?
<inkybutton> welcome to ualug Jozza
<passcod> yea
<Jozza> so all that is done is welcomes?
@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;
@jason-s13r
jason-s13r / console-jsfiddle.md
Last active December 12, 2015 02:58
When I use JS Fiddle, I find myself wanting console.log() stuff to show up in the output pane as well as the actual JavaScript console.

When I use JS Fiddle, I find myself wanting console.log() stuff to show up in the output pane as well as the actual JavaScript console.

  • console(...) is the real console.log(...)
  • console.log(...) is the output pane + real console.log(...)
  • console.clear() deletes everything in the ol/ul tag.
  • console._ is mapped to the original browser console.
console.log('hello', 'world')
 .clear()