Skip to content

Instantly share code, notes, and snippets.

View tbennett's full-sized avatar

tbennett tbennett

  • Diablo Valley College
  • San Francisco
View GitHub Profile
@tbennett
tbennett / css_grid_example.html
Last active November 1, 2022 08:23
Example of using CSS Grid with named template areas and a bit of flexbox for the internals of the grid areas.
<!doctype>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSS Grid and Flexbox Demo</title>
<meta name="Author" content="tb"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* These styles are the default for mobile and desktop */
// two ways to get a random integer between zero and another (e.g. between 0 and 100)
// method 1
// Math.trunc (new ES6) truncates the floating point, converting the value to an integer.
const maxVal = 100;
const randomInt = Math.trunc(maxVal * Math.random());
// method 2
// the left shift operator (<<)
@tbennett
tbennett / git_master_to_main
Created September 10, 2022 10:29
Reconfig git and GitHub master to main
# Setting Up to Use Git
Github > Settings > Branches > Default branch --> change to main
For your local Git install, there is a config option called init.DefaultBranch. Just set it and forget it.
__git config --global init.defaultBranch main__
You're good going forward!
@tbennett
tbennett / gist:416f91cb94933cbe759c4e2cce5431b1
Created December 12, 2023 01:09
Convert 24hr (Militarty) time to standard 12hr time
function convertMilitaryToStandard(militaryTime) {
let hours = militaryTime.substring(0,2);
let minutes = militaryTime.substring(3,5);
let meridian = (hours >= 12) ? "PM" : "AM";
let convertedTime = ((parseInt(hours) + 11) % 12 + 1) + ":" + minutes;
return convertedTime + " " + meridian;
};
@tbennett
tbennett / float_clear.css
Created November 5, 2024 21:19
A Legit Method for clearing floats. * Hack Free *
/* From MDN */
/*
* Clearing overlapping floats:
* To solve this problem is to use the value flow-root of the display property.
* This exists only to create a block formatting context (BFC) without using hacks —
* there will be no unintended consequences when you use it.
*/
.wrapper {