Skip to content

Instantly share code, notes, and snippets.

View DaveAldon's full-sized avatar
📱
Working on the next great mobile app!

David Crawford DaveAldon

📱
Working on the next great mobile app!
View GitHub Profile
@DaveAldon
DaveAldon / CharacterController2D.cs
Created November 26, 2016 05:30
Dead simple 2D controller for Unity
using UnityEngine;
public class CharacterController2D : MonoBehaviour
{
public Vector2 temp; //Temporary Vector2 variable, as you cannot modify this information directly
public float X = 10; //Initial speed
void Start ()
temp = transform.position; //At the initialization of this script, set the temp's values equal to the attached object
}
using System;
using UnityEngine;
using UnityEngine.Networking;
using UnityStandardAssets.CrossPlatformInput;
namespace UnityStandardAssets.Characters.ThirdPerson
{
[RequireComponent(typeof (ThirdPersonCharacter))]
public class ThirdPersonUserControl : NetworkBehaviour
{
public class NetworkSyncAnimation : MonoBehaviour {
//enum must stand for enumeration, so I believe this variable stores an array of integers
public enum AniStates
{
walk = 0,
run,
kick,
punch,
@DaveAldon
DaveAldon / Network Lobby.cs
Last active May 18, 2017 13:49
Unity lobby with username handling
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class NetworkManager : MonoBehaviour {
public const string typeName = "102398471982374987";
public const string gameName = "RoomName";
public GameObject playerPrefab;
public GameObject MainMenuCanvas;
@DaveAldon
DaveAldon / doorAnim.cs
Created February 12, 2017 05:22
Activating animations and reversing them the proper way
using UnityEngine;
public class doorAnim : MonoBehaviour {
public void playOpen() {
GetComponent<Animation>()["OpenDoor"].speed = 1;
GetComponent<Animation>().Play("OpenDoor");
}
public void playClose() {
@DaveAldon
DaveAldon / doorAnim.cs
Last active February 19, 2017 22:23
Reversing animation and playing sound for as long as animation
using UnityEngine;
using System.Collections;
public class doorAnim : MonoBehaviour {
public float lengthOfAnim;
public AnimationState anim;
public string animName = "Open Door Up";
bool open = false;
float animTime;
@DaveAldon
DaveAldon / ls.py
Created August 9, 2017 17:35
Format ls output on Windows to look like Unix.
def ls(path):
s = subprocess.Popen(["dir", path], shell=True, stdout=subprocess.PIPE).stdout
service_state = s.read().splitlines()
temp_li = []
li = []
for i in service_state:
temp_li.append(i.decode('ascii'))
for i in temp_li[7:-2]:
li.append(i.split()[4])
@DaveAldon
DaveAldon / dataframe_regex.py
Created August 17, 2017 18:03
Regex function for retrieving an XML attribute from a dataframe without needing to convert any objects for modules like ElementTree
# David Crawford
# Regex function for retrieving an XML attribute from a dataframe without needing to convert any objects for modules like ElementTree
import re
# Returns the first occurance of an attribute's value
def reg(data):
pattern = '(?<=ATTRIBUTE_NAME=").*?(?=")'
x = re.findall(pattern, data)
@DaveAldon
DaveAldon / javascript_snippets.js
Last active September 18, 2017 18:25
Javascript snippets from CIS 731
window['var_name'] // Call global var name programatically
// Dynamically change page title based on user input
var imp = document.getElementByID('myinout');
var currentText = '';
imp.addEventListener('keydown', ev => {
console.log(ev);
currentText += ev.key.toString();
document.title = currentText;
console.log(currentText);
@DaveAldon
DaveAldon / dynamicSqlIndirection.cls
Created April 19, 2018 19:07
Indirection for iterating over dynamic sql and setting dynamic object properties
set tResults = []
WHILE rSet.%Next() {
// Init object for holding the values
set tRow = {}
// The following iterates over the dynamic sql object and dynamically sets values using indirection
set tMetadata = rSet.%GetMetadata()
// Get size of returned object
set tColumnCount = tMetadata.columns.Count()
// Loop through the count
for x=1:1:tColumnCount {