Skip to content

Instantly share code, notes, and snippets.

View theoperatore's full-sized avatar

Alex Petersen theoperatore

View GitHub Profile
@theoperatore
theoperatore / hooks.ts
Created January 28, 2019 14:02
two custom hooks; 1 for appending a DOM node to the document for use in a Portal. Another for conditionally adding an event listener to handle outside of flyout menu clicks (so it can close)
const useDOMDiv = (changeToUpdate: number = 1) => {
const nodeRef = React.useRef(document.createElement('div'));
React.useEffect(() => {
document.body.appendChild(nodeRef.current);
return () => document.body.removeChild(nodeRef.current);
}, [changeToUpdate]);
return nodeRef.current;
};
@theoperatore
theoperatore / bash_profile
Last active August 26, 2023 18:53
bash_profile, zshrc, and some tips for starting a new computer and installing a good env
export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
PS1='\[\033[01;35m\]\u\[\033[01;33m\]:\[\033[01;34m\]\W\[\033[00;31m\]:$git_branch \[\033[00m\]> '
@theoperatore
theoperatore / gameSaga.js
Last active April 3, 2018 02:16
Learning sagas by building pong!
import { createStore, applyMiddleware } from 'redux';
import createSagaMiddleware from 'redux-saga';
import { put, take, select } from 'redux-saga/effects';
import './index.css';
const initialGameState = {
// meta
game_on: false,
screen_h: 480,
@theoperatore
theoperatore / TrappableElements.md
Created March 5, 2018 13:25
List of trappable elements and which enemies to find them on for Chrono Cross on PSX

HolyLight

  1. Use HolyLight(trap) on Cupoid [Terra Tower]
  2. Use HolyLight(trap) on Sun-of-a-Gun [Boss, Fort Dragonia]
  3. Use HolyLight(trap) on Miguel [Boss, Dead Sea
  4. Use HolyLight(trap) on Luxator [Boss, Terra Tower]
  5. Use HolyLight(trap) on TimeDevourer (Fused Dragon)(6) [Boss, Terra Tower]

Ultranova

  1. Use Ultranova(trap) on MegaStarky [Boss, Sky Dragon Isle]
  2. Use Ultranova(trap) on Sky Dragon [Boss, Sky Dragon Isle]
{
"Response": {
"themeCollection": [
{
"themeId": "Guardian",
"themeName": "Guardian",
"normalResolution": {
"image": {
"rect": {
"x": 0,
@theoperatore
theoperatore / findRandomGame.js
Last active March 3, 2019 06:37
Get random game metadata via giant-bomb api for any platform
// depends on fetch, async/await (node 8.2.1+)
require('isomorphic-fetch');
const getAllPlatforms = async apiKey => {
const rawResponse = await fetch(`http://www.giantbomb.com/api/platforms?api_key=${apiKey}&format=json&field_list=name,id`);
const response = await rawResponse.json();
// check response.error === "OK" && repsonse.status_code === 1
return response.results;
}
@theoperatore
theoperatore / ping.js
Created May 8, 2015 04:43
Ping a Heroku web app to keep it from sleeping.
var request = require('request');
var CronJob = require('cron').CronJob;
var URL = "https://your-heroku-name-web-app.com/";
var CRONTIME = "0 25,55 * * * *";
var job;
function ping() {
request(URL, function(err, response, body) {
@theoperatore
theoperatore / login.js
Last active January 20, 2016 17:00
Node.js Destiny API Authentication
var request = require('request');
var Promise = require('es6-promise').Promise;
var cjar = request.jar();
var PSN_OAUTH_URI = "https://auth.api.sonyentertainmentnetwork.com/login.do";
var BUNGIE_SIGNIN_URI = "https://www.bungie.net/en/User/SignIn/Psnid";
// Returns a promise fullfilled with the response of the
// request, or rejected with the error
@theoperatore
theoperatore / keybase.md
Created October 26, 2014 05:50
Keybase.io public verification

Keybase proof

I hereby claim:

  • I am theoperatore on github.
  • I am theoperatore (https://keybase.io/theoperatore) on keybase.
  • I have a public key whose fingerprint is DFF1 D15A 7DFE E471 E0DA 5D34 A681 841E 8617 64C8

To claim this, I am signing this object:

@theoperatore
theoperatore / pixelSwap.js
Last active November 14, 2016 01:10
pixel swapping via RGB distance checking
var canvas = document.createElement('canvas'),
ctx = canvas.getContext('2d');
document.body.appendChild(canvas);
var dest_src = "./images/american-gothic.png",
palette_src = "./images/starry-night.png",
anim, palette, dest,
ITERATIONS = 8000;
(function init() {