Skip to content

Instantly share code, notes, and snippets.

View andyman's full-sized avatar

Andrew Wang andyman

View GitHub Profile
@andyman
andyman / TiltSingleBehaviour.cs
Created January 20, 2017 22:18
Simple state machine behaviour to randomize an animator parameter at interval.
using UnityEngine;
using System.Collections;
public class TiltSingleBehaviour : StateMachineBehaviour {
public string xParameter = "tiltX";
public float minInterval = 1.0f;
public float maxInterval = 4.0f;
public float minValue = -1f;
@andyman
andyman / TiltBehaviour.cs
Created January 20, 2017 22:16
A simple state machine behaviour to randomly set two animator parameters at interval.
using UnityEngine;
using System.Collections;
public class TiltBehaviour : StateMachineBehaviour {
public string xParameter = "tiltX";
public string yParameter = "tiltY";
public float minInterval = 1.0f;
public float maxInterval = 4.0f;
@andyman
andyman / LayerMaskUtil.cs
Created January 20, 2017 22:15
A simple Layer Mask Utility class for Unity for checking whether a layer is in a layermask
using UnityEngine;
using System.Collections;
public class LayerMaskUtil {
public static bool CheckLayer(int layer, LayerMask layerMask)
{
return (layerMask.value & (1 << layer)) != 0;
}
}
@andyman
andyman / convert_to_gif.sh
Created September 12, 2015 18:16
Converts a video file to a gif. Needs ffmpeg.
#!/bin/bash
echo "USAGE"
echo "convert_to_gif.sh <video_file_name> <frames_per_second> <width> <start_second> <duration>"
echo "--------------------"
# from here:
# http://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality
INPUT_FILE=$1
@andyman
andyman / convert_to_gif.sh
Last active August 29, 2015 14:21
Bash script for converting a video file to a small animated gif. Requires ffmpeg and imagemagick to be installed and accessible.
#!/bin/bash
echo "USAGE"
echo "convert_to_gif.sh <video_file_name> <frames_per_second>"
echo "--------------------"
# from here:
# http://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality
# add the "-ss 2 -t 6" arguments after the ffmpeg to skip 2 seconds and have a duration of 6 secs
<color="yellow">SAMPLE END CREDITS</color>
<color="cyan">DESIGNED AND CREATED BY</color>
Alan Aardvark
Betty Beetle
Charlie Clownfish
<color="cyan">PROGRAMMING</color>
Daniel Dolphin
Ellen Eagle
@andyman
andyman / ShowScreenArrow.cs
Created September 16, 2014 20:24
ShowScreenArrow.cs
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ShowScreenArrow : MonoBehaviour {
public Transform target;
RectTransform rect;
Image image;
@andyman
andyman / killmail.sh
Created May 15, 2014 21:12
Kills Mail.app on Mac OS X for a minute, every 5 seconds. Schedule this as a cron job to run every minute during your focus hours. You'll open up Mail, and it will quickly close it for you.
#!/bin/bash
# how many seconds to sleep for between quits
SLEEPTIME=5
for((i=0;i<60;i+=SLEEPTIME))
do
osascript -e 'tell application "Mail" to quit' > /dev/null 2>&1
sleep $SLEEPTIME
done