Skip to content

Instantly share code, notes, and snippets.

View bmansk8's full-sized avatar
🏠
Working from home

Barron V Brock bmansk8

🏠
Working from home
View GitHub Profile
@bmansk8
bmansk8 / fileToString.js
Created June 15, 2023 22:42
a simple function that can take a file, and convert it's contents to a string
async function convertFileToString(filepath) {
return await fetch(filepath)
.then((response) => {
return response.text();
})
.then((data) => {
return data;
});
}
@bmansk8
bmansk8 / game.py
Created March 3, 2023 21:21
Rock Paper Scissors game
from random import randint
import re
def player_win_outcome(player_value,computer_value,):
print("you win!",player_value, "beats", computer_value, "!")
def player_loss_outcome(player_value,computer_value,):
print("you lose!",player_value, "loses to", computer_value, "!")
def tie():
@bmansk8
bmansk8 / styles.less
Last active October 29, 2020 15:53
A less css playground
/*
So these are the things that jumped out to me when it comes to using lesscss.
Obvoiusly there are others, but these features are reason enough for me to want to use less.
Please check them out at http://lesscss.org/
If you want to see it running simply clone this repo https://github.com/bmansk8/learning-Less
My blogpost about this https://www.barronvbrock.net/blog
*/
@color: red;
@selector: h1;
@bmansk8
bmansk8 / Theme Swapper.md
Last active December 3, 2020 14:47
A simple theme swapper
@bmansk8
bmansk8 / ZeroToHero.spec.js
Created September 8, 2020 15:57
Learning to use jest!
import pizzas from '../data.json';
test('pizza data is correct ', () => {
expect(pizzas).toMatchSnapshot();
expect(pizzas).toHaveLength(4);
expect(pizzas.map(pizza => pizza.name)).toEqual([
'Chicago Pizza',
'Neapolitan Pizza',
'New York Pizza',
'Sicilian Pizza'
@bmansk8
bmansk8 / discordBot.js
Last active December 2, 2019 17:35
A simple discord bot.
//if you use vs code
//node . starts app
//ctrl c closes bot
//ctrl ` opens console
//make sure to install node
var configObj = {
quotes: [
"put",
"your",
@bmansk8
bmansk8 / change_project.js
Last active April 15, 2019 16:11
My change drawer project
// Create an array of objects which hold the denominations and their values
var denom = [
{ name: 'ONE HUNDRED', val: 100.00},
{ name: 'TWENTY', val: 20.00},
{ name: 'TEN', val: 10.00},
{ name: 'FIVE', val: 5.00},
{ name: 'ONE', val: 1.00},
{ name: 'QUARTER', val: 0.25},
{ name: 'DIME', val: 0.10},
{ name: 'NICKEL', val: 0.05},
function telephoneCheck(str) {
// Good luck!
var regex = /^(1\s?)?(\(\d{3}\)|\d{3})[\s\-]?\d{3}[\s\-]?\d{4}$/;
return regex.test(str);
}
telephoneCheck("555-555-5555");
function rot13(str) { // LBH QVQ VG!
var codeArr = str.split("");
var decodedArr=[];
var alphabet=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C","D","E","F","G","H","I","J","K","L","M"];
for(var i=0;i<codeArr.length;i++){
if(alphabet.indexOf(codeArr[i])===-1){
decodedArr.push(codeArr[i]);
function convertToRoman(num) {
var roman="";
var romanNumeral=['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'];
var numbers=[1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
for(var i=0;i<numbers.length;i++){
while(num>=numbers[i]){
roman = roman + romanNumeral[i];
num = num - numbers[i];
}