Skip to content

Instantly share code, notes, and snippets.

View Problematic's full-sized avatar

Derek Stobbe Problematic

View GitHub Profile
using UnityEngine;
using System.Collections;
public class EventConsumer : MonoBehaviour
{
EventProvider ep;
void Awake ()
{
ep = GetComponent<EventProvider>();
@Problematic
Problematic / dialogBox.js
Last active August 29, 2015 14:02
Quick and easy Angular dialog box
angular.module('dialogBox', [])
.factory('DialogBox', function ($q) {
var instances = {};
function DialogBox (name) {
if (!instances[name]) {
instances[name] = $q.defer();
}
instances[name].resolve(this);
@Problematic
Problematic / Vagrantfile
Created April 14, 2014 00:56
Vagrantfile to set up postgres, redis, ruby, and rails (uses docker)
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "hashicorp/precise64"
config.vm.provision "docker" do |d|
describe('$resource', function () {
var $httpBackend,
$rootScope,
Tasks;
beforeEach(module('ngResource'));
beforeEach(inject(function (_$httpBackend_, _$rootScope_) {
$httpBackend = _$httpBackend_;
$rootScope = _$rootScope_;
@Problematic
Problematic / AimingCircle.cs
Created March 7, 2014 23:46
Get the position on a circle for the direction you're aiming in Unity
Vector2 mousePos = _camera.ScreenToWorldPoint(Input.mousePosition);
Vector2 aimDirection = mousePos - (Vector2)_transform.position;
float aimAngle = Vector2.Angle(_transform.up, aimDirection);
if (Vector3.Cross(_transform.up, aimDirection).z > 0)
{
aimAngle = 360 - aimAngle;
}
Vector3 newPos = new Vector3(_transform.position.x + bulletSpawnRadius * Mathf.Sin(aimAngle * Mathf.Deg2Rad),
_transform.position.y + bulletSpawnRadius * Mathf.Cos(aimAngle * Mathf.Deg2Rad),
@Problematic
Problematic / Flashlight.cs
Created January 28, 2014 17:46
Code used in "Creating a Flashlight GameObject in Unity3D" (https://www.youtube.com/watch?v=uPLahFRlmVA)
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(Light))]
public class Flashlight : MonoBehaviour {
public GameObject source;
public AudioClip toggleSound;
Light _light;
// Use this for initialization
@Problematic
Problematic / sort_object.py
Last active December 16, 2015 13:59
Getters make this more complicated
class SomeObject(object):
def __init__(self, foo, bar):
self.foo = foo
self.bar = bar
def get_foo(self):
return self.foo
def get_bar(self):
return self.bar
@Problematic
Problematic / nginx.conf
Last active December 15, 2015 17:29
simple nginx conf for django under foreman
#user nobody;
worker_processes 1;
pid /tmp/nginx.pid;
events {
worker_connections 1024;
}
@Problematic
Problematic / player.rb
Created March 1, 2013 18:27
rubywarrior
class Player
def initialize
@directions = [:forward, :right, :backward, :left]
@initialized = false
@state = :exploring
@explored = Set.new
@unexplored = Set.new
end
def damaged_last_turn?
@Problematic
Problematic / ComboBreaker.js
Created November 9, 2012 21:15
Simple key-combo detector. Uses jQuery
/*jslint browser: true, plusplus: true */
(function ($) {
"use strict";
var ComboBreaker = function (combo, callback, options) {
var index = 0, timeout = null;
if (!(this instanceof ComboBreaker)) { return new ComboBreaker(combo, callback, options); }
this.options = $.extend({}, {