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 / placeholder.py
Created April 18, 2019 12:31
Locust.io post file
from locust import TaskSet, task
class UserBehaviour(TaskSet):
@task
def someTask(self):
filename="some/file.jpg"
with open(filename, 'rb') as img:
self.client.post(
"/some/url",
data={
@DataGreed
DataGreed / ReraiseTriggerEnterEvent.cs
Last active April 8, 2019 16:58
Unity: custom event in editor with one parameter passed through
using UnityEngine;
using UnityEngine.Events;
[System.Serializable]
public class TriggerEntered2dReraised : UnityEvent<Collider2D>
{
}
public class ReraiseTriggerEnterEvent : MonoBehaviour
{
@DataGreed
DataGreed / placeholder.sh
Created March 28, 2019 16:42
Unity debug log for Android
adb logcat -s Unity PackageManager dalvikvm DEBUG
@DataGreed
DataGreed / placeholder.html
Created March 14, 2019 17:24
scale down the responsive web page on mobile devices
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@DataGreed
DataGreed / placeholder.cs
Created March 10, 2019 15:05
C# Time since the beginning of Epoch
int epoch = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
@DataGreed
DataGreed / placeholder.cs
Created March 10, 2019 13:25
Unity: Custom Event handler in script editor panel
using UnityEngine.Events;
//will be displayed in editor
public UnityEvent yourCustomEvent;
public void Foo() {
// Trigger the event!
yourCustomEvent.Invoke();
}
@DataGreed
DataGreed / placeholder.cs
Created March 9, 2019 21:08
Unity Send Email (supports mobile)
using UnityEngine.Networking;
/// <summary>
/// Opens external application to send an email
/// </summary>
/// <param name="email">Email address</param>
/// <param name="subject">Subject.</param>
/// <param name="body">Body. E.g "My Body\r\nFull of non-escaped chars"</param>
void SendEmail(string email, string subject, string body)
{
@DataGreed
DataGreed / gist:e152dc76eb4a13bb5db587c76867a75e
Created January 31, 2019 20:33
disable logging in unity of the project is run in external player (not editor)
#if UNITY_EDITOR
Debug.unityLogger.logEnabled = true;
#else
Debug.unityLogger.logEnabled = false;
#endif
@DataGreed
DataGreed / WeightedRandomBag.cs
Created January 31, 2019 02:25
Weighted random choice - C# implementation
using System;
using System.Collections.Generic;
class WeightedRandomBag<T> {
private struct Entry {
public double accumulatedWeight;
public T item;
}
@DataGreed
DataGreed / OverrideSortingLayer.cs
Created January 22, 2019 02:42
Simple script to correct sorting z-sorting for Unity games using both 2d SPrites and 3D-meshes. Adds a property for the mesh that lets you specify its sorting layer
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Used to set Sorting Layer for 3D meshes, so they can Z-sort
/// correctly when used with 2D Sprites.
/// </summary>
public class OverrideSortingLayer : MonoBehaviour
{