Skip to content

Instantly share code, notes, and snippets.

@Catsync
Catsync / machine.js
Last active May 15, 2020 14:50
Generated by XState Viz: https://xstate.js.org/viz
const door = Machine({
id: 'door',
initial: 'locked',
states: {
locked: {
id: 'locked',
on: { UNLOCK: 'unlocked' }
},
unlocked: {
initial: 'closed',
@Catsync
Catsync / coco-levels-need-hero.js
Last active September 30, 2016 18:42
mongo script to find levels that still need converting to hero
// Search for this/self in level code / solutions
// Prints the level slug if this or self is still present.
// NOTE: add/change this campaign slug array as needed
var campaignSlug = ['intro','course-2','course-3','course-4'];
print("Levels that still need converting to hero:");
campaignSlug.forEach(function(slug) {
print("*** " + slug + " ***");
@Catsync
Catsync / coco-level-code-hero-replace.js
Last active April 22, 2016 20:35
Chrome Snippet script to automate updating a Code Combat level's code
(function(currentView) {
var thangs = currentView.level.get('thangs');
// **** Change sample code and solutions **** //
// Search level thangs
for(var i=0; i < thangs.length; i++) {
var thang = thangs[i];
// Search thang components
if(thang.components) {
for(var j=0; j < thang.components.length; j++) {
var component = thang.components[j];
@Catsync
Catsync / CoCoDisableRef.js
Created June 6, 2015 17:20
Put this in the chrome dev tools under Sources -> Snippets. Use when your referee's setUpLevel code prevents loading your level in the editor. It'll add "{}" to the end of your referee's extraCode, which you can remove after you've fixed it.
(function(currentView) {
var thangs = currentView.level.get('thangs');
var refereeThang = null;
for(var i=0; i < thangs.length; i++) {
var thang = thangs[i];
if(thang.components) {
for(var j=0; j < thang.components.length; j++) {
var component = thang.components[j];
if(component.config && component.config.extraCode) {
refereeThang = thang;
// Node script to download the Code Combat systems source
var http = require('http');
var fs = require('fs');
var componentDir = __dirname+'/systems';
// Make sure the components directory exists
try {
fs.mkdirSync(componentDir);
} catch(e) {
// Node script to download the Code Combat component source
var https = require('https');
var fs = require('fs');
var componentDir = __dirname+'/components';
// Make sure the components directory exists
try {
fs.mkdirSync(componentDir);
} catch(e) {