Skip to content

Instantly share code, notes, and snippets.

export const isPalindrome = string =>
string.split('').reverse().join('') === string;
@jeremyckahn
jeremyckahn / delete-random-lines.js
Created February 14, 2017 20:48
delete-random-lines.js
// Usage:
// node delete-random-lines.js some-file.txt
require('fs').readFile(process.argv[2], 'utf-8', (err, file) => {
const lines = file.split('\n');
const linesToDelete = Math.round(lines.length * 0.1);
for (let i = 0; i < linesToDelete; i++)
lines.splice(
Math.floor(Math.random() * lines.length),
@jeremyckahn
jeremyckahn / delete-random-lines.js
Created February 14, 2017 20:24
Delete random lines in a file
// Usage:
// node delete-random-lines.js some-file.txt
const fs = require('fs');
const lines = fs.readFileSync(process.argv[2], 'utf-8').split('\n');
const lineToDelete = Math.round(lines.length * 0.1);
for (let i = 0; i < lineToDelete; i++) {
lines.splice(
@jeremyckahn
jeremyckahn / AutoloadGame.js
Created November 8, 2015 01:25
RPG Maker MV plugin to autoload a saved game when the game boots
/* globals PluginManager, SceneManager, Scene_Load, DataManager */
/*:
* @plugindesc Autoload a saved game when the game boots
* @param File ID
* @desc The 1-based index of the file to load
* @default 1
* @author Jeremy Kahn
*/
(function () {
'use strict';
@jeremyckahn
jeremyckahn / AutoStartNewGame.js
Last active September 14, 2016 21:20
RPG Maker MV plugin to auto start a new game when the game boots
/* globals SceneManager */
/*:
* @plugindesc Auto start a new game when the game boots
* @author Jeremy Kahn
*/
(function () {
function poll () {
if (SceneManager._scene && SceneManager._scene.commandNewGame) {
SceneManager._scene.commandNewGame();
} else {
@jeremyckahn
jeremyckahn / ExecScript.js
Created November 6, 2015 02:20
An RPG Maker MV plugin for easily calling JavaScript files from events
/*:
* @plugindesc A utility for easily calling JavaScript files from events
* @author Jeremy Kahn
*
* @help API: exec('path/to/script', arg1, arg2, ...);
*
* * You may add on as many arguments as you need.
* * The path is relative to project-root/js
* * Loaded files must be AMD modules that looks like so:
*
@jeremyckahn
jeremyckahn / convert_all_scss_to_sass.sh
Last active August 29, 2015 14:17
Convert all SCSS files to SASS.
for FILE in `ls`; do sass-convert $FILE > `echo $FILE | sed s/scss/sass/`; done
@jeremyckahn
jeremyckahn / fix-lateralus-file-names.sh
Created February 10, 2015 21:31
Rename Lateralus component files to reference the component to which they belong.
#!/bin/bash
COMPONENTS_PATH="app/scripts/components"
TEMP_FILE="/tmp/temp.js"
for COMPONENT in `ls $COMPONENTS_PATH`; do
COMPONENT_PATH="$COMPONENTS_PATH/$COMPONENT"
git mv $COMPONENT_PATH/main.js $COMPONENT_PATH/$COMPONENT.js
git mv $COMPONENT_PATH/view.js $COMPONENT_PATH/$COMPONENT-view.js
git mv $COMPONENT_PATH/template.mustache $COMPONENT_PATH/$COMPONENT-template.mustache
@jeremyckahn
jeremyckahn / stylie-data-format.json
Last active August 29, 2015 14:12
The JSON format for Stylie localStorage data.
{
"savedAnimations": {
"__transientAnimation": {
"actorModel": {
"transformPropertyCollection": [
{
"x": 50,
"y": 489,
"millisecond": 0,
"isCentered": true,
/* global console: true */
var module = (function () {
function privateFn () {
console.log('I am a private function!');
return 8;
}
var privateVar;
return {