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 / 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 / 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 / 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 / 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()
@jason-s13r
jason-s13r / queue.js
Last active December 14, 2015 23:19
I only just noticed how Google Analytics sets up gaq = gaq || [] and the ndoes gaq.push([], ...) and stuff for commands. So I wondered how I might be able to make a similar queue thing. Felt like being silly a bit too...
var j = j || [];
j.push('first');
j.push('second.1', 'second.2');
j = (function(q){
function J() {
var self = this;
self.queue = [];
var secretKey = ((Math.random()*10e16) + new Date().getTime()).toString(36);
* You are now known as JSON|work
<JSON|work> More than 50 long-serving TAB workers look set to lose their jobs as the agency prepares to close its Auckland phone betting centre at Ellerslie.
<JSON|work> The workers have put in a submission through the Service and Food Workers Union asking the agency to keep the 27 Auckland employees who want to stay on, instead of hiring 25 new staff to replace them in the two remaining phone betting centres in Wellington and Christchurch.
<JSON|work> But the Racing Board, which owns the TAB, says it will save $1 million a year by selling its Ellerslie building for about $3 million, closing the Auckland phone operation and hiring half as many extra staff within existing facilities in the other two centres.
<JSON|work> Board media manager John Mitchell said the board would pay relocation costs for any Auckland staff willing to move south.
<JSON|work> But he said 22 of the 54 Auckland staff were aged 65 or over. Most others have worked at Ellerslie for many years and can't move