Skip to content

Instantly share code, notes, and snippets.

View LinearProportionConverter.cs
/*
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 Mar 30, 2021
Bezier Point Calculator for Unity (c#)
View BezierCalculator.cs
// 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;
View Trello_highlight_lists_on_IT_Board.js
// ==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==
View Trello_highlight_lists_on_IT_Board.js
// ==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
Providing an `around_action` like functionality in arbitrary Ruby classes
View my_wrapper_creator.rb
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
View clone_table.sql
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,
View watch_to_file.sh
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"
@fguillen
fguillen / beer_time.rb
Last active Jan 19, 2018
Announce the beer time
View beer_time.rb
# Simple but necessary script (for Mac) to announce when the beer time is comming
# You can configure your crontab like this
# 0 17 * * 5 ruby $HOME/scripts/beer_time.rb >> /var/log/beer_time.log 2>&1
beer_hour = ARGV[0] || 18
def say(message)
`afplay /System/Library/Sounds/Hero.aiff`
`afplay /System/Library/Sounds/Hero.aiff`
`say "#{message}"`
@fguillen
fguillen / rails_log_query_select_scraper.rb
Created Sep 8, 2016
Script to extract, from a Rails log, all the SELECT queries and the duration of each one in a csv format
View rails_log_query_select_scraper.rb
require "csv"
module Script
def self.run(input_path, output_path)
log = File.read(input_path)
lines_count = log.lines.count
index = 0
File.open(output_path, "w") do |output_file|