Skip to content

Instantly share code, notes, and snippets.

View digiguru's full-sized avatar

digiguru

View GitHub Profile
@phobeo
phobeo / javascript aspect ratio calculation (with GCD)
Created January 24, 2011 15:02
javascript aspect ratio calculation algorithm (take the GCD and divide both elements of resolution)
/* euclidean GCD (feel free to use any other) */
function gcd(a,b) {if(b>a) {temp = a; a = b; b = temp} while(b!=0) {m=a%b; a=b; b=m;} return a;}
/* ratio is to get the gcd and divide each component by the gcd, then return a string with the typical colon-separated value */
function ratio(x,y) {c=gcd(x,y); return ""+(x/c)+":"+(y/c)}
/* eg:
> ratio(320,240)
"4:3"
> ratio(360,240)
@richardneililagan
richardneililagan / CorsEnabledAttribute.cs
Last active March 3, 2016 07:49
A bunch of classes for enabling CORS support for MVC 4 Web API, based off of Carlos Figueira's work. https://gist.github.com/richardneililagan/5091035/#comment-791095
namespace Mvc.Cors
{
using System.Linq;
using System.Web.Http.Filters;
public class CorsEnabledAttribute : ActionFilterAttribute
{
private string[] allowedDomains;
public CorsEnabledAttribute()
@danlec
danlec / trello_embeds.md
Created July 31, 2013 18:52
Examples of embedding images of public trello boards/cards in GitHub markdown

A Trello Board

[![Trello Development Board](https://trello.com/b/nC8QJJoZ.png)](https://trello.com/b/nC8QJJoZ)

Trello Development Board

A Trello Card