Skip to content

Instantly share code, notes, and snippets.

Avatar
😁
Successfully deployed dolittle!

John madigan

😁
Successfully deployed dolittle!
View GitHub Profile
@madigan
madigan / Application.java
Created Feb 26, 2018
Starter Template for a Java/Spring based Microservice
View Application.java
package tech.otter.servicename;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class Application {
@madigan
madigan / PlayerController.cs
Created Dec 16, 2017
Simple controller script for Unity3D (5.x)
View PlayerController.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
// Update is called once per frame
void Update () {
this.transform.Translate(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")) * Time.deltaTime);
}
}
View customize-git.sh
# Turn unfortunate typos into dad joke opportunities, courtesy of @GonzoHacker
git config --global alias.dad '!curl -w "\n" https://icanhazdadjoke.com/ && git add'
@madigan
madigan / roll.js
Created Jan 21, 2017
JavaScript used to simulate a die roll
View roll.js
/**
* Expects input in the standard format- 1d6+2 or 1d12-1 or 4d4
*/
function roll(dieCode) {
var total = 0;
var results = dieCode.match(/([0-9]+)d([0-9]+)([\-\+][0-9]+)?/);
if(results !== null) {
for(var i = 0; i < parseInt(results[1]); i++) {
total += Math.floor(Math.random() * parseInt(results[2])) + 1;
View MainMenuScreen.java
package tech.otter.merchant.view;
import com.badlogic.gdx.Application.ApplicationType;
import com.badlogic.gdx.Gdx;
import com.kotcrab.vis.ui.widget.VisTable;
import com.kotcrab.vis.ui.widget.VisTextButton;
import tech.otter.merchant.controller.Controller;
import tech.otter.merchant.model.Model;
@madigan
madigan / CargoScreen.java
Last active Dec 27, 2016
A basic screen using MVC, illustrating activities which are delegated to the base class.
View CargoScreen.java
public class CargoScreen extends View {
private VisList<ItemEntry> lstItems;
private VisImage imgItem;
private VisTextArea txtDescription;
private VisTextButton btnBack;
public CargoScreen(Controller parent, Model model) {
super(parent, model);
// Initialize the image
@madigan
madigan / .gitignore
Created Oct 8, 2016
Customized .gitignore file for libGDX on Linux
View .gitignore
## Java
*.class
*.war
*.ear
hs_err_pid*
## Robovm
robovm-build/
@madigan
madigan / drawBackground.java
Created Dec 21, 2015
Infinite tiles in libGDX
View drawBackground.java
// Draw a background
private void drawBackground() {
// To simplify the code a little, do these calculations ahead of time
// To speed things up, we might optimize this.
float cameraLeft = camera.position.x - camera.viewportWidth / 2f;
float cameraRight = camera.position.x + camera.viewportWidth / 2f;
float cameraTop = camera.position.y + camera.viewportHeight / 2f;
float cameraBottom = camera.position.y - camera.viewportHeight / 2f;
float width = background.getWidth();