Skip to content

Instantly share code, notes, and snippets.

View webthingee's full-sized avatar

Sean Lange webthingee

View GitHub Profile
@webthingee
webthingee / gist:6185134
Created August 8, 2013 14:34
rewrite in MAMP for offsite files
### Apache Rewrite
<IfModule mod_rewrite.c>
RewriteEngine on
# Force image styles that have local files that exist to be generated.
RewriteCond %{REQUEST_URI} ^/sites/([^\/]*)/files/styles/[^\/]*/public/((.*))$
RewriteCond %{DOCUMENT_ROOT}/sites/%1/files/%2 -f
RewriteRule ^(.*)$ $1 [QSA,L]
# Otherwise, send anything else that's in the files directory to the
# production server.
RewriteCond %{REQUEST_URI} ^/sites/[^\/]*/files/.*$
@webthingee
webthingee / Arrows2DMovement.cs
Created January 5, 2018 23:12 — forked from dvddarias/Arrows2DMovement.cs
Unity editor script to precisely move, rotate and scale GameObjects on a 2D scene, using the arrow keys.
/*
Unity editor script to precisely move, rotate and scale GameObjects on 2D scenes, using the arrow keys.
Notes:
- To use it just include it on an "Assets/Editor" folder on your project.
- The action depends on the selected tool and the size of the movement depends on the Scene view zoom.
- The more "zoomed in" is the scene view the smaller is the movement step.
- It will work when the current Scene tab is in 2D mode and there is at least one gameObject selected,
otherwise the scene camera will move as usual :)
@webthingee
webthingee / CustomKey.cs
Created July 30, 2018 14:22
Unity Custom Shortcut Key
using UnityEditor;
public class LightingMenuItem
{
[MenuItem("Window/Custom/LightingMenuItem %#l")]
public static void Show()
{
EditorApplication.ExecuteMenuItem("Window/Lighting/Settings");
}
}
@webthingee
webthingee / normalize-slope.cs
Created August 16, 2018 18:31 — forked from ashblue/normalize-slope.cs
Unity 2D slope normalizer for walking up and downhill with corner snapping. Based upon https://www.youtube.com/watch?v=xMhgxUFKakQ
// @NOTE Must be called from FixedUpdate() to work properly
void NormalizeSlope () {
// Attempt vertical normalization
if (grounded) {
RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector2.up, 1f, whatIsGround);
if (hit.collider != null && Mathf.Abs(hit.normal.x) > 0.1f) {
Rigidbody2D body = GetComponent<Rigidbody2D>();
// Apply the opposite force against the slope force
// You will need to provide your own slopeFriction to stabalize movement
@webthingee
webthingee / Waiting.cs
Last active January 1, 2019 19:24
Coroutines
StartCoroutine(WaitToExeute(1f));
public IEnumerator WaitToExecute(float secondsToWait)
{
// The waiting
Debug.Log("start wait " + Time.time);
yield return new WaitForSeconds(secondsToWait);
Debug.Log("end wait " + Time.time);
// Code to execute
private void AdjustGoFirst()
{
if (!list.Exists(turn => turn.gameObject.name.Contains("Player")))
{
Player.instance.GetComponent<PlayerTurn>().Init();
return;
}
int playerListIndex = list.FindIndex(turn => turn.gameObject.name.Contains("Player"));
@webthingee
webthingee / dark.md
Created January 15, 2019 23:31 — forked from a7madgamal/dark.md
Dark mode for Slack on MacOS
  1. Close slack
  2. Open this file /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js
  3. Append this to it
document.addEventListener('DOMContentLoaded', function() {
 $.ajax({
   url: 'https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css',
   success: function(css) {
 $("").appendTo('head').html(css);
@webthingee
webthingee / EditorButton.cs
Last active April 17, 2019 21:55
Quick List
[CustomEditor(typeof(ActionTile))]
public class ActionTileEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
ActionTile m = (ActionTile) target;
if (GUILayout.Button("Set Initial Stats"))
public class MusicHeath : MonoBehaviour
{
[EventRef] public string musicHealth;
private FMOD.Studio.EventInstance musicHealthEvent;
private FMOD.Studio.ParameterInstance healthParam;
public float healthIntensity;
void Start()
{
@webthingee
webthingee / FMOD.cs
Last active May 7, 2019 02:52
FMOD Studio
using FMODUnity;
using UnityEngine;
public class MainMusic : MonoBehaviour
{
[EventRef] public string mainMusicSelection;
private FMOD.Studio.EventInstance mainMusicEvent;
public float songSelectionValue;