Skip to content

Instantly share code, notes, and snippets.

@fguillen
fguillen / code_style.gd
Last active March 28, 2025 14:39
Godot GD script template with the order of the code sections
# meta-name: Code style template
# meta-description: Empty script with the order of the code sections
# -- 01 @tool
# -- 02 class_name
# -- 03 extends
extends _BASE_
# -- 04 # docstring
#
@fguillen
fguillen / letsencrypt_cert_creation.md
Last active August 3, 2022 22:10
Create SSL certificate using letsencrypt.org

How to create a ssl certificate using letsencrypt in your mac for your own domain

Install certbot

brew install certbot

Generate the certificate

using System;
using System.Linq;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
/// <summary>
/// Helper class to define a Tile and the associated treshold value on the perlin noise
/// </summary>
[Serializable]
@fguillen
fguillen / SingletonScriptableObject.cs
Last active February 18, 2022 12:21
Singleton Scriptable Object for Unity
using UnityEngine;
// From here: https://www.youtube.com/watch?v=6kWUGEQiMUI&ab_channel=whateep
// Use it:
// 1) Create a subclass:
// public class MySingletonSO : SingletonScriptableObject<MySingletonSO> {}
// 2) Create the new Asset into the /Assets/Resources folder
// 3) Access to it:
// MySingletonSO.Instance
//
@fguillen
fguillen / Utils.cs
Created December 16, 2021 21:09
Utils library for Unity projects
using UnityEngine;
public class Utils
{
public static float AddNoise(float value)
{
return AddNoise(value, value / 2.0f);
}
public static float AddNoise(float value, float delta)
@fguillen
fguillen / Rails_Implementing_Invitation_Code_mechanism.diff
Last active October 1, 2021 15:03
Rails - Implementing Invitation Code mechanism
commit a656816e7d9498d32b52c6c9455e535466623ad9
Author: Fernando
Date: Fri Oct 1 12:23:37 2021 +0200
Invitation workflow
diff --git a/app/controllers/admin/invitations_controller.rb b/app/controllers/admin/invitations_controller.rb
new file mode 100644
index 0000000..93652c0
--- /dev/null
@fguillen
fguillen / RandomPointInCollider.cs
Last active August 1, 2022 07:11
Unity, generate a random point into a Polygon
using System;
using UnityEngine;
public class RandomPointInCollider
{
Collider2D collider;
Vector3 minBound;
Vector3 maxBound;
int maxAttempts;
@fguillen
fguillen / Draggable.cs
Created July 5, 2021 14:00
Unity Click and Drag script. Add this script and a Collider to an Object.
using UnityEngine;
public class Draggable : MonoBehaviour
{
Vector3 offset;
void OnMouseDown()
{
offset = transform.position - Camera.main.ScreenToWorldPoint(Input.mousePosition);
}
/*
Convert from one magnitude to another.
Example:
LinearProportionConverter collisionToVolume = new LinearProportionConverter(soundVolumeLimits.x, soundVolumeLimits.y, collisionMagnitudeLimits.x, collisionMagnitudeLimits.y);
float volume = collisionToVolume.CalculateDimension1Value(collisionMagnitude);
audioSource.PlayOneShot(clip, volume);
*/