Skip to content

Instantly share code, notes, and snippets.

View Ratstail91's full-sized avatar
💭
Back in my day, we didn't need no AI.

Kayne Ruse Ratstail91

💭
Back in my day, we didn't need no AI.
View GitHub Profile
const { roleLength } = require('utils');
const ROLE_NAME = 'scout';
function spawn(origin, max, roleName, type = 'small') {
if (roleLength(Game.creeps, roleName, origin) >= max) {
return;
}
//determine the size to use
#comments begin with a pound sign
#The script automatically calls the function "main" after loading it
#this is how you declare a function called "main"
START main:
#do stuff
END #all functions finish with END
#this is how you write a function with arguments
@Ratstail91
Ratstail91 / validate_token_credentials.js
Created June 24, 2019 14:15
Literally all of my functions look like this!
const validateTokenCredentials = (connection) => (fields) => new Promise( (resolve, reject) => {
const validateQuery = 'SELECT COUNT(*) AS total FROM sessions WHERE sessions.accountId = ? AND sessions.token = ?;';
return connection.query(validateQuery, [fields.id, fields.token])
.then(results => results[0].total > 0 ? resolve(fields) : reject({msg: 'Invalid password change credentials', extra: [fields.id, fields.token]}))
;
});
@Ratstail91
Ratstail91 / main.js
Last active July 4, 2019 12:03
A simple clicker game example written for a friend.
//constants
var SAVE_NAME = 'cookieCount.foodfare';
//the gameplay variables
var cookies = 0;
var cursors = 0;
var upgrades = 0;
//the display variables
var cookieNode = document.getElementById('cookies');
//environment variables
require('dotenv').config();
//libraries
let mysql = require('mysql');
//utilities
let { log } = require('./logging.js');
let connection;
//how to call the hitstun animation
StartCoroutine(TriggerHit(0.8f)); //0.8 seconds of invulnerability
IEnumerator TriggerHit(float delay) {
invulnerable = true; //allow for a window of time to get away
StartCoroutine(TriggerHitGraphic(0.1f, delay - 0.1f));
yield return new WaitForSeconds(delay);
invulnerable = false;
}
@Ratstail91
Ratstail91 / fake_ticker_code.jsx
Created June 18, 2019 07:24
I need to yeet this code, as the kids say.
if (this.state.tagline === 'marquee-loop') {
let triangleUpStyle = {
flex: '0 1 auto',
borderRight: '5px solid',
borderBottom: '5px solid',
width: '10px',
height: '10px',
marginLeft: '5px',
marginRight: '5px'
};
//save data sequentially
let counter = 0;
let fpath = path.join(__dirname, 'sampledata');
fs.writeFileSync(path.resolve(fpath, `${counter}.json`), 'utf8');
//get the filenames for concatenation as array
let filenames = fs.readdirSync(fpath);
filenames.forEach(fname => {
//concatenate the files
});
#new ladder expression
SELECT
username,
recruits,
soldiers,
gold,
(recruits + soldiers + scientists + spies) AS unitTotal,
(SELECT COUNT(*) FROM pastCombat WHERE (attackerId = accounts.id AND victor = 'attacker') OR (defenderId = accounts.id AND victor = 'defender')) AS successfulCombats,
(
(recruits + soldiers + scientists + spies) +
import React from 'react';
class ProgressiveRainbowText extends React.Component {
constructor(props) {
super(props);
this.state = {
colors: props.colors || ['red', 'orange', 'yellow', 'green', 'blue', 'violet', 'indigo'],
counter: 0,
unsubscribeKey: setInterval(() => this.setState({ counter: this.state.counter + 1}), 1000)