Skip to content

Instantly share code, notes, and snippets.

View chrisinajar's full-sized avatar

Chris Vickery chrisinajar

  • The Internet
  • Portland, OR
View GitHub Profile
@chrisinajar
chrisinajar / isash.js
Created June 6, 2018 01:32
Quick function to detect if an RWK item is ash or not
function isAsh (itemNumber) {
var itype = parseInt(itemNumber / 1000, 10) % 100;
var inum = parseInt(itemNumber, 10) % 1000;
var iench = parseInt(itemNumber / 100000, 10) % 100 - 1;
if (iench > 34) {
return false;
}
if (iench < 0) {
@chrisinajar
chrisinajar / faster_delay_bar.js
Last active June 8, 2018 02:19
RWK code snippet to make the delay bar perform infinitely better
replaceDelayBars();
function replaceDelayBars () {
const $ = top.main.document.querySelector.bind(top.main.document);
var purpleBar = $('#s_ActionDelay td').nextElementSibling;
var greyBar = purpleBar.nextElementSibling;
var subbut2Style = top.frames.main.s_subbut2.style;
var subbutStyle = top.frames.main.s_subbut.style;
var subbut2NOStyle = top.frames.main.s_subbut2NO.style;
@chrisinajar
chrisinajar / createChallenge.js
Last active March 16, 2017 18:47
Generate code that checks a password
function createChallenge (input, goal, hash) {
input = input.replace(/ /g, '');
var challengeLength = 16;
var challenge = hash(hash(input) + 'god damned internet').substr(0, challengeLength);
goal += challenge;
// after using input...
// right away just hash it, we never really want to work with the raw value
input = hash(input);
var outputLength = 0;
@chrisinajar
chrisinajar / battle.js
Last active July 3, 2016 02:18
Battle whitelist for screeps
var USERNAME_WHITELIST = ['chrisinajar', 'ho0ber', 'fractaloop', 'n7-anthony', 'overra', 'tyrel', 'fervens', 'devdaniel'];
module.exports = {
findEnemy: findEnemy,
run: run
};
/*
var target = findEnemy(creep);
*/
@chrisinajar
chrisinajar / index.js
Created May 19, 2016 18:11 — forked from bloodyKnuckles/index.js
requirebin sketch
var h = require('virtual-dom/h')
var diff = require('virtual-dom/diff')
var pv = require('virtual-dom-patch-viewer')
vdom1 = h('div', [
h('div', 'div stuff'),
h('script', {src: 'bundle.js', key: 1})
])
vdom2 = h('div', [
@chrisinajar
chrisinajar / gist:892885fac3af90819bb6
Last active August 29, 2015 14:14
queueSoundtrackSong for soundtrack.io
function queueSoundtrackSong(index) {
var trackData = $.extend({}, TralbumData, TralbumData.trackinfo[index || 0]);
$.ajax({url: "//soundtrack.io/playlist",
type: 'post',
xhrFields: {
withCredentials: true
},
data: {
source: 'bandcamp',
id: {
@chrisinajar
chrisinajar / gist:6558718
Last active December 23, 2015 01:09
Radiant and Dire bitmaps
function getBitmaps() {
var direBitmap = 0,
radiBitmap = 0,
i, cl, hero;
for (i = 0; i < server.clients.length; ++i) {
cl = server.clients[i];
if (!cl) { continue; }
if (cl.netprops.m_iTeamNum === dota.TEAM_DIRE) {
@chrisinajar
chrisinajar / fib,js
Created July 1, 2013 18:12
Calculate Fibonacci Sequence
// calculate up until e
function fibb(e) {
var i = 0;
(function(le) {
return (function(f) {
return f(f);
}(function(f) {
return le(function(x) {
return f(f)(x);
});
@chrisinajar
chrisinajar / gist:5379848
Created April 13, 2013 20:01
Plug.DJ chat logger and log reader
// Basid plug.dj logger. Sloppy, doens't unlisten to events
(function() {
var load = function(name) {
try {
return JSON.parse(localStorage["_log_" + name]);
} catch (e) {
return null;
}
}
var save = function(name, value) {
@chrisinajar
chrisinajar / gist:4556830
Last active December 11, 2015 06:08
bookmarklet to reload all CSS on a given page
javascript:(function() { $("link[rel='stylesheet']").each(function(i, node) {var map = {};$.each(node.attributes, function(i, node) {map[node.name.toLowerCase()] = node.value;});$("<link />", map).appendTo('head');$(node).remove();}) })()