Skip to content

Instantly share code, notes, and snippets.


Mario Castro Squella MarcAstr0

View GitHub Profile

Keybase proof

I hereby claim:

  • I am marcastr0 on github.
  • I am marcastr0 ( on keybase.
  • I have a public key ASCV0TzqAn9-ZDAaO4WWc2OSpakvaITR3EgvldAtkFk9UAo

To claim this, I am signing this object:

MarcAstr0 / temperature.c
Created Nov 27, 2017
Simple library for converting temperatures from Celsius to Fahrenheit and vice versa.
View temperature.c
#include "temperature.h"
#include <math.h>
float to_fahrenheit(float celsius) {
float fahrenheit;
fahrenheit = roundf( ( (celsius * (9.00f/5.00f)) + 32.00f ) * 100.00f ) / 100.00f;
return fahrenheit;
MarcAstr0 /
Created Nov 7, 2017
Prolog code to calculate the Bacon Number (or the "Six Degrees of Kevin Bacon" game)
%% Kevin Bacon movies
cast(['Kevin Bacon', 'Lori Singer', 'John Lithgow', 'Dianne Wiest']). %% Footloose (1984)
cast(['Tom Cruise', 'Jack Nicholson', 'Demi Moore', 'Kevin Bacon']). %% A Few Good Men (1992)
cast(['Tom Hanks', 'Bill Paxton', 'Kevin Bacon', 'Gary Sinise']). %% Apollo 13 (1995)
%% Tom Cruise movies
cast(['Tom Cruise', 'Kelly McGillis', 'Val Kilmer', 'Anthony Edwards']). %% Top Gun (1985)
cast(['Tom Cruise', 'Cuba Gooding Jr.', 'Renée Zellweger', 'Kelly Preston']). %% Jerry Maguire (1996)
cast(['Tom Cruise', 'Rebecca De Mornay', 'Joe Pantoliano', 'Richard Masur']). %% Risky Business (1983)
MarcAstr0 / checkRut.js
Last active Aug 24, 2017
JavaScript function to check whether a string is a valid Chilean ID number, also known as RUT (Rol Único Tributario) or RUN (Rol Único Nacional)
View checkRut.js
function checkRut(rut) {
var cleanRut = rut.replace(/[\.|-]/g, '');
var dv = cleanRut.substr(-1);
var rest = cleanRut.substr(0, cleanRut.length-1);
var digits = rest.split('').reverse().map(function(d, i) { return [(i%6)+2, parseInt(d)]; });
var sum = { return x[0]*x[1]; }).reduce(function(x, y) { return x+y; });
var result = 11 - (sum % 11);
switch(result) {
case 11:
return (0 === dv);