Skip to content

Instantly share code, notes, and snippets.

Avatar
🍋
Hanging around.

Robert Lemon rlemon

🍋
Hanging around.
View GitHub Profile
View user-stars.es6.js
let io = undefined, found = [];
const addScript = url => {
return new Promise((resolve, reject) => {
let script = document.createElement('script');
script.onload = resolve;
script.onerror = reject;
script.src = url;
document.body.appendChild(script);
});
};
View scraper.js
var request = require('request'),
$ = require('cheerio');
var roomid = process.argv[2];
if (!roomid) {
throw new Error('you need to pass a roomid and a output file');
}
var outputfile = process.argv[3] || roomid;
var found = [];
var page = 1;
var start = Date.now();
View input fucker.js
[...document.querySelectorAll('input[type="text"],textarea')].forEach(el=>{
let fn = () => {
el.addEventListener('keyup', () => {
( Math.random()<.9 ) && ( return );
this.selectionEnd = this.selectionStart = Math.random()*this.value.length|0;
};
};
});
@rlemon
rlemon / gist:8745660
Created Jan 31, 2014
Bot Online Storage Proposal
View gist:8745660

Bot Online Storage Proposal.

Well I have been talking about this for some time now and I think there seems to be some confusion on how (I envision) it will work. Here is my breakdown of how I envision things ending up with the online storage.

The server will have a simple api. Pass it a key (will explain) and your command and it will either save the localStorage to the server, or load the localStorage from the server and update the browser before the bot reads the memory. If there is no key present the entire process will be ignored and the command not loaded, and the localStorage loaded like normal. (so minimal internal changes, and a !!saveMemory command that automatically triggers on an interval of your choice).

The keys will be generated and saved by the server. Admin access (logins can be discussed) will allow you to obtain keys to insert into your loading script. Again to be minimal we could just tell the users to include var MEMORY_KEY = key; in before the script is run and th

View LICENSE
RYAN KINAL ESQUIRE PUBLIC LICENSE
Version 1, February 2014
Copyright (C) 2014 Ryan Kinal <email@address.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed, it is not used for evil (If you have to ask yourself if it is being used for evil, it is probably being used for evil.), and you consider buying Ryan Kinal a beer(no cheap stuff... well okay).
RYAN KINAL ESQUIRE PUBLIC LICENSE
View poll.markdown

#poll

What do you prefer to read:

A:

function foo() { return 1; }

var foo = foo();
View auth.js
var passport = require('passport'),
LocalStrategy = require('passport-local').Strategy,
passwordHash = require('password-hash'),
pg = require('pg').native;
var connString = '';
var pgsql = new pg.Client(connString);
passport.use(new LocalStrategy(
@rlemon
rlemon / lum.js
Created Apr 14, 2014
getLuminance function - lum.js
View lum.js
// pass it an image resource (new Image() or HTMLImageElemenet) and it will
// return average lum over the image or given bounds between 0-255
function getLuminance(imgResource, /* following is optional */x1, y1, x2, y2) {
// create canvas and set the height/width to the image
var canvas = document.createElement('canvas'),
context = canvas.getContext('2d'),
height = canvas.height = imgResource.height,
width = canvas.width = imgResource.width,
// holding for the data, and average lum
@rlemon
rlemon / gist:10783047
Created Apr 15, 2014
midpoint 2d displacement in js
View gist:10783047
function midpoint(arr, p1, p2, max, jitter) {
var mid = Math.round((p1 + p2) / 2);
if (p2 - p1 <= 1 || p2 === mid || p1 === mid) {
return;
}
arr[mid] = ((arr[p1] + arr[p2]) / 2) + (max * (Math.random() * (jitter * 2) - jitter));
midpoint(arr, p1, mid, max / 2, jitter);
midpoint(arr, mid, p2, max / 2, jitter);
}
View smelly.user.js
// ==UserScript==
// @name Chat users smell
// @author Robert Lemon
// @version 0.01
// @namespace
// @description make people smelly
// @include http://chat.stackoverflow.com/rooms/*
// ==/UserScript==
function inject(str) {