Skip to content

Instantly share code, notes, and snippets.

View the-vampiire's full-sized avatar
💭
ive lost a shade of color in my life. rest in peace.

the-vampiire

💭
ive lost a shade of color in my life. rest in peace.
View GitHub Profile
@the-vampiire
the-vampiire / tictactoe.js
Last active May 13, 2017 08:52
Final iteration (Unbeatable?)
/**
* Created by Vampiire on 5/11/17.
* Refactored for undefeatable AI at 4 am 5/13. X's and O's, Jack.
Everything written from scratch, no guides, external help, or codes were copied unlike some others.
*/
// jQuery shortcuts
var square = $('.square'), center = $('#square_5'), modal = $('.modal'), winnerOutput = $('#winnerOutput');
// global variables
@the-vampiire
the-vampiire / simon.js
Created May 16, 2017 06:45
Vampiire Simon
/**
* Created by Vampiire on 5/14/17.
*/
// jQuery shorcuts
var touch = $('.touch'), screen = $('#screen'),
door_creek = $('#door_creek'), power_button = $('#power'), power_icon = $('#power_icon'), strict_button = $("#strict");
// global variables
@the-vampiire
the-vampiire / truncate.js
Last active May 18, 2017 23:15
Number Shortener
/**
* Created by Vampiire on 5/18/17.
*/
function shortenNum(num, decimals){
if(num.toString()[decimals+2] === "5"){
return Number(Number(num.toString().slice(0, decimals+2) + 6).toFixed(decimals));
}
return Number(num.toFixed(decimals));
@the-vampiire
the-vampiire / the_truncanator.js
Created May 19, 2017 16:33
Number Shortener - Refactored
/**
* Refactored by Vampiire on 5/19/17.
* Now will correctly truncate regardless of how many integer digits are in place
* (previously only worked for 1 integer digit)
*
* Looks for the index value of the decimal and treats this as the start of the slice
* Seeks beyond the decimal point (+1) to the number of decimals specified by the user
* Adds a 6 at this point so it will round up correctly to the number of decimals requested
*
*/
@the-vampiire
the-vampiire / weatherv3.js
Created June 13, 2017 06:15
weather v3 code
$(function() {
// Media query to determine if mobile is present
var mobile;
mobile = !window.matchMedia("(min-width: 420px)").matches;
// JQuery shortcuts
// Switches
var
@the-vampiire
the-vampiire / test.html
Created June 28, 2017 22:15
Caleb Notes
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<body>
<div id="test">
@the-vampiire
the-vampiire / respond.js
Last active August 4, 2017 00:33
General Help response for /update command
// Excerpt from respond.js pertaining to the help responses for the /update command
helpResponse = (type) => {
let help =
`*How to use the \`/update\` command:* \n\nUpdating works like git in stringing together mandatory and/or optional [-flag] [data] pairs to build your update command\nGeneral form: \`/update [profile item to update] [[-flag] [data]]\`
\n*Available profile items and associated flags*:
*Updating GitHub, Blog, or Portfolio URLs*
\t*Item(s)*
\t\t[\`git\`]: your github profile url
@the-vampiire
the-vampiire / controller.js
Created August 4, 2017 00:35
/update command route code
// Excerpt from controller.js focusing on the /update route that Slack sends all /update requests to
router.post('/update', (req, res) => {
const respond = require('./tools/respond');
const body = req.body;
const arguments = body.text;
if(tools.verify.slash(body.token)){
if(~arguments.indexOf(' ')){
@the-vampiire
the-vampiire / valueStringer.js
Created August 4, 2017 02:02
errorScan and verifyKeys functions from valStringer
// scans a custom attachment object for errors
errorScan = (type, customAttachment) => {
const expectedKeys = ['text', 'callback_id', 'actions'];
const expectedSubKeys = type === 'menu' ? ['name', 'type', 'data_source'] : ['text', 'name', 'type'];
const keysError = verifyKeys(customAttachment, expectedKeys, 'outer attachment properties');
if(keysError){
return keysError;
}
@the-vampiire
the-vampiire / update.js
Last active August 4, 2017 03:50
argumentParser / argumentSplitter
argumentParser = arguments => {
const output = argumentSplitter(arguments);
const item = output.item;
const pairsArray = output.pairsArray;
let flagDataPairs = {};
pairsArray.forEach( pairString => {
let flag = pairString.slice(0, pairString.indexOf(' '));
let data = pairString.slice(pairString.indexOf(' ')+1);