Skip to content

Instantly share code, notes, and snippets.

View TravisL12's full-sized avatar
🪲
Smokes if you got'em.

Travis Lawrence TravisL12

🪲
Smokes if you got'em.
View GitHub Profile
@TravisL12
TravisL12 / primes_sum_twoM_TRL.rb
Last active December 25, 2015 15:59
Solutions to Project Euler #10 (http://projecteuler.net/problem=10) "Find the sum of all the primes below two million"
def primesTRL(num)
ceiling = num
number_set = 2.upto(ceiling).map(&:to_i)
non_primes = {}
number_set.each do |prime|
next unless non_primes[prime].nil?
max_val = ceiling / prime
break if max_val < prime
@TravisL12
TravisL12 / word_parse.rb
Created November 12, 2013 07:00
Used this to cut up every word in a CSV to count any common places where I made purchases. Such as a certain gas station or how many times at an ATM.
require 'csv'
class String
def titleize
split(/(\W)/).map(&:capitalize).join
end
end
def separate_word(word)
word.gsub(/[0-9\-\/\\\*\#()&'.]/,"").titleize.split(" ")
@TravisL12
TravisL12 / application.css
Last active August 29, 2015 14:00
Strava Demo stuff
body {
font-family: Helvetica; }
.container {
margin: 20px auto;
width: auto;
background: #f00;
padding: 20px; }
.container ul {
margin: 0;
@TravisL12
TravisL12 / application.css
Created March 12, 2018 22:42
Javascript Forrest!
body {
margin: 0;
}
#forrest {
position: relative;
width: 100vw;
height: 100vh;
background-color: lightblue;
}
@TravisL12
TravisL12 / index.html
Created February 3, 2020 15:07
Cave Forest Game
<html>
<link href="css/styles.css" type="text/css" rel="stylesheet" />
<body>
<div class="content">
<div class="half-container">
<h3>
<span id="top-label">What Awaits? :</span
><span id="top-message"></span>
</h3>
@TravisL12
TravisL12 / html_generate.sh
Created February 7, 2020 17:36
Generate simple HTML/CSS/JS folder structure
#!/bin/bash
NEW_DIR=$1 # define folder/project name as command line argument
if [[ -z $NEW_DIR ]]; then # if no CLI argument provided then prompt for project name
echo "Give a directory name to create:"
read NEW_DIR
fi
ORIG_DIR=$(pwd)
[[ -d $NEW_DIR ]] && echo $NEW_DIR already exists, aborting && exit
@TravisL12
TravisL12 / multipleReGroups.js
Created September 21, 2020 19:16
Loop through text to group variables and values
function groupThese(text) {
let idx = 0;
let count = 0;
const groups = {}
const re = new RegExp(/(?<=const |var |let )([^\s=]+)\s?=\s?["']?(#\w*)["']?/,"i");
while (count < 10 && idx >= 0) {
const match = text.slice(idx).match(re)
if (match?.index) {
groups[match[1]] = match[2]
@TravisL12
TravisL12 / README.md
Last active February 24, 2021 17:54
Node Script to crop out images from Super Mega Baseball Card image

Download all the results from : https://drive.google.com/drive/u/0/folders/1RtlftwSAvzLRdTmpspko-ejrwEhGO6Rl

The group team photos I used are from: https://drive.google.com/drive/folders/12hVarUZZ0vGPNSmyXAUcjealuxE4EK4S

The team logos are available from Metalhead: https://www.dropbox.com/sh/47d8tahwogx9qcn/AAC8nU1NF5_hVSBeF9MzRzIza/Logos?dl=0&subfolder_nav_tracking=1

I had to take two photos of each team because one player is always highlighted which makes their image bigger. So for my script you have to separate these two team photos into a ./teams and a ./first_players folders.

Make sure a ./updated directory als exists for the final images.

@TravisL12
TravisL12 / calculator.js
Last active December 22, 2020 21:59
Calculator function for handling multiple inputs
function operate(num1, num2, operand) {
switch (operand) {
case '-':
return num1 - num2;
case '*':
return num1 * num2;
case '/':
return num1 / num2;
default:
return num1 + num2;
@TravisL12
TravisL12 / application.js
Created February 18, 2022 06:51
Beginner Skeleton project
console.log("hey there!");