Skip to content

Instantly share code, notes, and snippets.

@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);
*/
@fguillen
fguillen / BezierCalculator.cs
Last active March 30, 2021 19:23
Bezier Point Calculator for Unity (c#)
// Draw the curve using a bezier curve tool like: https://www.desmos.com/calculator/d1ofwre0fr
// Get p0, p1, p2 and p3 from that tool
using UnityEngine;
using System;
public class BezierCalculator
{
Vector3 p0;
Vector3 p1;
@fguillen
fguillen / Trello_highlight_lists_on_IT_Board.js
Created August 7, 2019 12:08
Trello Board List colorized
// ==UserScript==
// @name Trello highlight lists on IT Board
// @description Highlight certain columns in Trello.
// @include https://trello.com/b/CdaXFAGQ/it-work-in-progress
// @require https://code.jquery.com/jquery-3.4.1.min.js
// @version 0.1
// @copyright 2014, Gareth J M Saunders
// @copyright 2019, Dalia Research GmbH
// ==/UserScript==
@fguillen
fguillen / Trello_highlight_lists_on_IT_Board.js
Created August 7, 2019 12:08
Trello Board List colorized
// ==UserScript==
// @name Trello highlight lists on IT Board
// @description Highlight certain columns in Trello.
// @include https://trello.com/b/CdaXFAGQ/it-work-in-progress
// @require https://code.jquery.com/jquery-3.4.1.min.js
// @version 0.1
// @copyright 2014, Gareth J M Saunders
// @copyright 2019, Dalia Research GmbH
// ==/UserScript==
@fguillen
fguillen / my_wrapper_creator.rb
Last active May 19, 2019 05:55
Providing an `around_action` like functionality in arbitrary Ruby classes
module MyWrapperCreator
def my_method_wrapper(method_name)
original_method = instance_method(method_name)
define_method(method_name) do |*args, &block|
puts "wrapper :: INI"
result = original_method.bind(self).call(*args, &block)
puts "wrapper :: END"
result
drop procedure if exists clone_table;
delimiter $$
create procedure clone_table ()
begin
declare n int;
set n := 0;
while n < 20 do
insert destiny_table select
field_1,
watch -t -n 30 "(date '+%Y-%m-%d %H:%M:%S,' | tr -d '\n'; curl -o /dev/null -s -w %{time_total} http://myweb.com; echo) | tee -a /tmp/my_web.log"