Skip to content

Instantly share code, notes, and snippets.

View madigan's full-sized avatar
😁
Successfully deployed dolittle!

John madigan

😁
Successfully deployed dolittle!
View GitHub Profile
@madigan
madigan / drawBackground.java
Created December 21, 2015 22:36
Infinite tiles in libGDX
// 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();
@madigan
madigan / .gitignore
Created October 8, 2016 20:00
Customized .gitignore file for libGDX on Linux
## Java
*.class
*.war
*.ear
hs_err_pid*
## Robovm
robovm-build/
@madigan
madigan / CargoScreen.java
Last active December 27, 2016 00:23
A basic screen using MVC, illustrating activities which are delegated to the base class.
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 / MainMenuScreen.java
Created December 26, 2016 23:49
Example View
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 / roll.js
Created January 21, 2017 04:57
JavaScript used to simulate a die roll
/**
* 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;
# 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 / PlayerController.cs
Created December 16, 2017 17:54
Simple controller script for Unity3D (5.x)
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);
}
}
@madigan
madigan / Application.java
Created February 26, 2018 15:42
Starter Template for a Java/Spring based Microservice
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 / .default
Created December 14, 2022 04:34
WordPress Virus
<?php
if (!function_exists('getUserIP')) {
function getUserIP()
{
foreach (array('HTTP_CF_CONNECTING_IP', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
if (array_key_exists($key, $_SERVER) === true) {
foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) {
@madigan
madigan / index.html
Created April 1, 2024 17:06
Styling Example
<!DOCTYPE html>
<html>
<head>
<style>
html,
body {
padding: 0;
margin: 0;
height: 100%;
}