Skip to content

Instantly share code, notes, and snippets.

View marcosrocha85's full-sized avatar
🤓

Marcos Rocha marcosrocha85

🤓
View GitHub Profile
@marcosrocha85
marcosrocha85 / main.ts
Created February 9, 2026 00:58
Super Bowl - Predictions
const NFL_GAME_VARIANCE = 5; // typical point deviation in NFL games
function predictSuperBowlWinner(
favorite: string,
underdog: string,
spread: number
): string {
// Simulates realistic noise: ±5 points around the spread
const randomFactor = Math.random() * (NFL_GAME_VARIANCE * 2) - NFL_GAME_VARIANCE;
@marcosrocha85
marcosrocha85 / main.ts
Created February 9, 2026 00:43
Super Bowl - Current Score Tracker
const axios = require('axios');
async function getSuperBowlScore() {
try {
const response = await axios.get('https://api.sportsdata.io/v3/nfl/scores/json/CurrentScore'); // API Key Needed
console.log(`Score: ${response.data.AwayTeam} ${response.data.AwayScore} x ${response.data.HomeScore} ${response.data.HomeTeam}`);
} catch (error) {
console.error('Fetch error:', error);
}
}
@marcosrocha85
marcosrocha85 / .bash_aliases
Created November 28, 2025 12:51
Intelligent alias for npm that auto-adds "run" when necessary for npm
# Intelligent alias for npm that auto-adds "run" when necessary
npm() {
# If no arguments, run npm normally
if [ $# -eq 0 ]; then
command npm
return
fi
local first_arg="$1"
@marcosrocha85
marcosrocha85 / AssociatedProtocol.swift
Created October 19, 2021 19:31 — forked from benrudhart/AssociatedProtocol
A Swift protocol that is using an enum with a generic associated type
import Foundation
import UIKit
//: # The problem: Protocol that is using an enum with generic associated type
enum GenericEnum<T> {
case Unassociated
case Associated(T)
}
@marcosrocha85
marcosrocha85 / RobotEntertainerMiddleware.php
Created December 5, 2019 02:29
Laravel Robot Entertainer
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Arr;
class RobotEntertainerMiddleware
{
const prohibitedRoutes = [
@marcosrocha85
marcosrocha85 / HttpCodes.php
Created April 10, 2019 16:58
PHP Response Codes for API Implementation
<?php
/**
* This class is used in a Laravel/Lumen project. But it may be fit in any project as well
* User: marcosrocha85
* Date: 2019-04-10
* Time: 11:51
*/
namespace App\Exceptions;
@marcosrocha85
marcosrocha85 / form_pretty_checkbox.php
Last active September 24, 2018 18:48
CodeIgniter form_pretty_checkbox
/**
* Pretty Checkbox Field for CodeIgniter and pretty-checkbox-vue from @hamed-ehtesham
*
* @access public
* @param mixed
* @param string
* @param bool
* @param string
* @return string
*/
@marcosrocha85
marcosrocha85 / AutoResizeTextView.java
Created December 19, 2016 13:05
Android: Auto Scale TextView
package com.example.AutoResizeTextView;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.RectF;
import android.os.Build;
import android.text.Layout.Alignment;
import android.text.StaticLayout;
import android.text.TextPaint;