Skip to content

Instantly share code, notes, and snippets.

@minism
minism / MapOutputNodeView.cs
Created October 10, 2021 00:44
NodeGraphProcessor - NodeView with texture preview example
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEditor.Experimental.GraphView;
using UnityEngine.UIElements;
using GraphProcessor;
[NodeCustomEditor(typeof(MapOutputNode))]
SRCS=$(wildcard *.c)
OUTDIR=dist
TARGET=$(OUTDIR)/app
all: $(TARGET) $(TARGET).exe
clean:
rm -f $(OUTDIR)
$(OUTDIR):
@minism
minism / gist:0e8cf6a653bed32bf887ed57a59a7971
Created April 25, 2020 08:22
Simple https nginx config to route to docker containers by subdomain
upstream foo {
server foo-container:80;
}
upstream bar {
server bar-container:3000;
}
map $subdomain $container {
foo foo;
@minism
minism / type_checking.py
Created October 31, 2013 00:39
Python runtime type checking concept
# Runtime type checking concept
from functools import wraps
def signature(*types):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
for i, t in enumerate(types):
if i >= len(args):
import random
import pprint
import sys
# 7 Prisoners, 1 designated counter
prisoners = [
{"seen": False, "is_counter": False, "messaged": False},
{"seen": False, "is_counter": False, "messaged": False},
{"seen": False, "is_counter": False, "messaged": False},
@minism
minism / truncate_auto_tables.sql
Created February 12, 2013 20:38
Truncate autopopulated django tables to prepare loaddata
SET FOREIGN_KEY_CHECKS=0;
truncate table `auth_user_user_permissions`;
truncate table `auth_permission`;
truncate table `django_content_type`;
SET FOREIGN_KEY_CHECKS=1;
@minism
minism / .bashrc
Last active December 11, 2015 04:59
# Returns "*" if the current git branch is dirty.
_parse_git_dirty()
{
[[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] && echo "*"
}
# Get the current git branch name (if available)
_git_prompt()
{
local ref=$(git symbolic-ref HEAD 2>/dev/null | cut -d'/' -f3)
# Standard django choices style
CHOICE_APPLE = 'apple'
CHOICE_BANANA = 'banana'
CHOICE_ORANGE = 'orange'
FRUIT_CHOICES = (
(CHOICE_APPLE, 'Apple'),
(CHOICE_BANANA, 'Banana'),
(CHOICE_ORANGE, 'Orange'),
)
@minism
minism / decorators.py
Last active December 10, 2015 14:38
Cached method by related model save
from django.db import models
from django.db.models.signals import post_save
from django.db.models.loading import get_model
from cachemodel.decorators import cached_method
def model2label(obj):
return ("%s.%s" % (obj._meta.app_label, obj._meta.object_name))
@minism
minism / forms.py
Created November 27, 2012 18:51
Tastypie ModelForm validation that only validates submitted fields on PUT requests
from tastypie.validation import CleanedDataFormValidation
def pick(d, keys):
"""Based on http://underscorejs.org/#pick"""
return dict((key, val) for key, val in d.items() if key in keys)
class BaseFormValidation(CleanedDataFormValidation):
"""