Skip to content

Instantly share code, notes, and snippets.

View andybak's full-sized avatar

Andy Baker andybak

View GitHub Profile
@andybak
andybak / MaterialGradientDrawer.cs
Created March 8, 2021 08:47 — forked from totallyRonja/MaterialGradientDrawer.cs
A Material Property Drawer for the [Gradient] attribute which lets you edit gradients and adds them to the shader as textures. More information here: https://twitter.com/totallyRonja/status/1368704187580682240
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
public class MaterialGradientDrawer : MaterialPropertyDrawer {
private static Dictionary<(int, string), Gradient> knownGradients = new Dictionary<(int, string), Gradient>();
@andybak
andybak / LightweightPipelineTemplateShader.shader
Created August 5, 2018 14:40 — forked from phi-lira/UniversalPipelineTemplateShader.shader
Template shader to use as guide to create Lightweight Pipeline ready shaders.
// When creating shaders for Lightweight Pipeline you can you the ShaderGraph which is super AWESOME!
// However, if you want to author shaders in shading language you can use this simplified version as a base.
// Please not this should be only use for reference only.
// It doesn't match neither performance not feature completeness of Lightweight Pipeline Standard shader.
Shader "LightweightPipeline/Physically Based Example"
{
Properties
{
// Specular vs Metallic workflow
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
@andybak
andybak / TriplanarWorld.shader
Created June 20, 2018 20:09 — forked from radiatoryang/TriplanarWorld.shader
a triplanar / procedural UV / world space UV shader for Unity, cobbled together bits from @quickfingerz and @Farfarer
Shader "Tri-Planar World" {
Properties {
_Side("Side", 2D) = "white" {}
_Top("Top", 2D) = "white" {}
_Bottom("Bottom", 2D) = "white" {}
_SideScale("Side Scale", Float) = 2
_TopScale("Top Scale", Float) = 2
_BottomScale ("Bottom Scale", Float) = 2
}
@andybak
andybak / runAndroid.sh
Created May 27, 2018 11:25 — forked from fadookie/runAndroid.sh
Script to install, run, and open logcat for a Unity Android App
#!/bin/sh
# Script to install, run, and open logcat for a Unity Android App.
# I needed this as one of my libraries has a critical post-build script so I can't use "Build and Run" anymore - this is the "and Run" part.
# Be sure to update these variables to match your app's publishing/build settings:
APK_PATH='builds/android/basecode.apk'
BUNDLE_ID='com.eliotlash.basecode'
alias unilogcat='adb logcat|egrep "Unity"'
adb install -r "${APK_PATH}" && adb logcat -c && adb shell am start -n "${BUNDLE_ID}/com.unity3d.player.UnityPlayerNativeActivity" && echo 'DONE, LOG:' && unilogcat
#!/usr/bin/python
import re, urllib, urllib2
class Spreadsheet(object):
def __init__(self, key):
super(Spreadsheet, self).__init__()
self.key = key
class Client(object):
"""
adminreverse from here http://djangosnippets.org/snippets/2032/
changed for working with ForeignKeys
Partially Fixed for Django 1.6 by @andybak
Fully Fixed for Django 1.6 by @luto
Fieldset support added by @andybak
reverseadmin
============
Module that makes django admin handle OneToOneFields in a better way.
@andybak
andybak / models.py
Created April 10, 2014 17:27 — forked from anonymous/models.py
DRF, Getters Setters, PolymorphicModel
class MyModel(PolymorphicModel):
@property
def driver(self):
if self.is_departure: return self.delivery_driver
else: return self.collection_driver
@driver.setter
def driver(self, value):
if self.is_departure: self.delivery_driver = value
else self.collection_driver = value
@andybak
andybak / a-rectangle-by-google
Last active December 24, 2015 07:59 — forked from JacksonGariety/a-rectangle-by-google
reformat the javascript
<!DOCTYPE html>
<html>
<head data-gwd-animation-mode="quickMode">
<title>Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="Google Web Designer 1.0.0.924">
<style type="text/css">
html, body {
width: 100%;
@andybak
andybak / django-1.2.5-lookup_allowed-example.py
Created May 16, 2011 09:39 — forked from acdha/django-1.2.5-lookup_allowed-example.py
How to whitelist other admin lookups with Django 1.2.5
class FooAdmin(ModelAdmin):
def lookup_allowed(self, key, value):
# NOTE: Django 1.2.5 changed the call signature to add the value
# Django 1.2.4 restricted the list of allowed lookups to only those
# specified in list_filter or date_hierarchy, which doesn't help when
# we need to filter on a list with thousands of options. We'll
# override that to allow the few which we actually use:
if key in ('related__pk', 'related__custom_field'):
return True