Skip to content

Instantly share code, notes, and snippets.

View andyman's full-sized avatar

Andrew Wang andyman

View GitHub Profile
@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 / WebLocationChecker.cs
Created March 25, 2016 14:12
WebLocationChecker.cs
using UnityEngine;
using System.Collections;
using System.Text;
/**
* WebLocationChecker by @andyman404
* Licensed under Creative Commons Zero (do with it as you want, no credit needed)
* https://creativecommons.org/publicdomain/zero/1.0/
*
* This script site-locks your Unity Webplayer/WebGL build.
@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
@andyman
andyman / WebLocationChecker.cs
Created January 1, 2015 20:27
Simple script for Unity to check the domain that the web player is hosted on, and redirect it to the proper location if it is not in the list of domains. It does nothing if it is not a web player build.
using UnityEngine;
using System.Collections;
using System.Text;
/** Add this script to an object in the first scene of your game.
* It doesn't do anything for non-webplayer builds. For webplayer
* builds, it checks the domain to make sure it contains at least
* one of the strings, or it will redirect the page to the proper
* URL for the game.
*/
<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