Skip to content

Instantly share code, notes, and snippets.

Avatar

Eric Banisadr ebanisadr

View GitHub Profile
@ebanisadr
ebanisadr / build-site.js
Created May 25, 2020
Simple Javascript SSG
View build-site.js
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const compile = require('./compiler');
const inputDir = 'content';
const outputDir = 'stage';
View LongestPalindrome.java
public class LongestPalindrome {
public static String getLongestPalindrome(final String input) {
int rightIndex = 0, leftIndex = 0;
String currentPalindrome = "", longestPalindrome = "";
for (int centerIndex = 1; centerIndex < input.length() - 1; centerIndex++) {
leftIndex = centerIndex - 1; rightIndex = centerIndex + 1;
while (leftIndex >= 0 && rightIndex < input.length()) {
if (input.charAt(leftIndex) != input.charAt(rightIndex)) {
break;
}
View DeletionsEasy.java
import java.util.Scanner;
public class DeletionsEasy {
public static void main(String[] args) {
String in = parseLine();
int count = deletionGame(in);
System.out.println(count);
}
static String parseLine() {
@ebanisadr
ebanisadr / KarelDriver.java
Last active Jun 6, 2017
Karel KeyListener
View KarelDriver.java
//Add these lines to the top of your main method to make the key listener work
//implement the variable listener however you want, this anonymous one is just a sample
KeyListener listener = new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
//using e.getChar() is not always a reliable way to find out what key is pressed
//I think you're supposed to use e.getKeyCode which will return an int representing a VK_ (virtual key) value
System.out.println("pressed " + e.getKeyChar());
}
View ServerCharacterPredictionSystem.java
/*
* Copyright 2016 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software