Skip to content

Instantly share code, notes, and snippets.

View DataGreed's full-sized avatar
👾
practicing magic

Alexey Strelkov DataGreed

👾
practicing magic
View GitHub Profile
@DataGreed
DataGreed / ColliderToFit.cs
Last active June 3, 2019 13:12
#Unity adjust box collider to children object bounds
using UnityEngine;
using UnityEditor;
using System.Collections;
public class ColliderToFit : MonoBehaviour {
[MenuItem("My Tools/BoxCollider/Fit to Children")]
static void FitToChildren() {
foreach (GameObject rootGameObject in Selection.gameObjects) {
if (!(rootGameObject.collider is BoxCollider))
@DataGreed
DataGreed / CustomPrefabImporterEditor.cs
Created June 5, 2019 18:08 — forked from TJHeuvel/CustomPrefabImporterEditor.cs
Custom inspector window for Unity prefabs that allows you to (multi) edit them.
using UnityEditor;
using UnityEditor.Experimental.AssetImporters;
using UnityEngine;
using System.Reflection;
using System;
using System.Collections;
using System.Linq;
using Object = UnityEngine.Object;
using System.Collections.Generic;
@DataGreed
DataGreed / paddedTime.js
Created June 26, 2019 15:42
Local time with leading zeroes (string padding)
var someDate = new Date("Wed Jun 26 2019 09:08:32 GMT+0100")
result = `${String(someDate.getHours()).padStart(2,"0")}:${String(someDate.getMinutes()).padStart(2,"0")}` // returns "09:08"
adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG
@DataGreed
DataGreed / JoystickTester.cs
Created July 6, 2019 21:40
find out gamepad thumbstick and button mapping in Unity on your platform
// Arowx.com 2013 - free to use and improve!
using UnityEngine;
using System.Collections;
public class JoystickTester : MonoBehaviour {
public TextMesh joysticks;
public TextMesh[] inputText;
public TextMesh[] buttonText;
@DataGreed
DataGreed / port.sh
Created July 30, 2019 13:32
Find out what process listens to the port on OSX/nix
lsof -n -i4TCP:8080 | grep LISTEN
# example of threads working on a queue
from Queue import Queue
from threading import Thread
num_worker_threads = 10
# items to work on
def source():
return xrange(400)
@DataGreed
DataGreed / JoystickDeadZone.cs
Created September 18, 2019 12:52
Implements proper deadzones for joystick or gamepad sticks for Unity
using UnityEngine;
namespace datagreed.input
{
/// <summary>
/// Implements proper deadzones for joystick or gamepad sticks.
/// Based on http://www.third-helix.com/2013/04/12/doing-thumbstick-dead-zones-right.html
///
/// Example usage:
///
@DataGreed
DataGreed / filters.py
Created November 30, 2019 02:35
Simple customized filter names for django-rest-framework (DRF)
from django.template import loader, Template, Context
from rest_framework.filters import SearchFilter
browsable_api_filter_template = """{% load i18n %}
<h2>{{ title }}</h2>
<p>{{description}}</p>
<form class="form-inline">
<div class="form-group">
<div class="input-group">
@DataGreed
DataGreed / swagger-ui.html
Created November 30, 2019 03:07
Swagger-UI for django-rest-framework (DRF) with CSRF and log in/log out support
{% load rest_framework %}
<!DOCTYPE html>
<html>
<head>
<title>Swagger</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="//unpkg.com/swagger-ui-dist@3/swagger-ui.css" />
<style>