Skip to content

Instantly share code, notes, and snippets.

View Karlina-Bytes's full-sized avatar

Karlina Beringer Karlina-Bytes

  • San Francisco Bay Area
View GitHub Profile
@Karlina-Bytes
Karlina-Bytes / gist:c2d465176caccded6ef8
Last active August 29, 2015 14:05
HTML for a simple web page.
<!-- This is a comment -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> Hello World </title>
</head>
<body>
<h1> This is a Large Heading </h1>
<h2> This is a Medium Heading </h2>
@Karlina-Bytes
Karlina-Bytes / binToDecConvert.html
Last active August 29, 2015 14:07
The web interface for a Binary-to-Decimal converter.
<!--*********************************************************
* Converts from binary to decimal (and vice versa).
* Note: uses Bootstrap for the "well" class.
* Copy-paste this code below into your HTML file.
* This code will generate the user interface.
**********************************************************
-->
<!-- Start of yellow-green container -->
<div class="well" style="background-color:#99FF00">
@Karlina-Bytes
Karlina-Bytes / binToDecConvert.js
Last active August 29, 2015 14:07
For use with binToDecConvert.html. This JavaScript code responds to the button click.
/*********************************************************
* Responds to the "Convert!" button click.
* (This could be thought of as the "main" function).
* Step 1: Validates the text field input.
* Step 2: Determines which conversion to perform.
* Step 3: Performs the appropriate calculation.
* Step 4: Displays the result on the web page.
********************************************************/
function buttonClick() {
@Karlina-Bytes
Karlina-Bytes / removeSpaces.js
Created October 16, 2014 23:16
A JavaScript function for removing spaces in a string.
/*********************************************************
* Removes space characters from the input string.
* @param {String} inputString
* @return {String} "cleaned up" inputString.
*********************************************************/
function removeSpaces( inputString ) {
// If the inputString is empty, return an error.
if (!inputString) return "Error";
@Karlina-Bytes
Karlina-Bytes / binOrDecCheck.js
Last active August 29, 2015 14:07
A JavaScript function for validating whether a given string of characters represents a number of the given base (binary or decimal).
/*********************************************************
* Checks whether a given string represents a number of
* the given base. For example, 1101 is base 2.
* @param {String} digitString
* @param {String} base
* @return {Boolean} true if digitString matches base
********************************************************/
function validateInput( digitString, base ) {
// Determine the cardinality of the digitSet.
@Karlina-Bytes
Karlina-Bytes / binToDecResult.js
Created October 16, 2014 23:25
For use with binToDecConvert.html. This function print the result of the binary-to-decimal conversion to the web page.
/*********************************************************
* Displays an output message on the webpage.
* @param {String} message to display
********************************************************/
function displayResult( message ) {
var resultArea = document.getElementById("resultArea");
var content = ("<h4><em>" + message + "</em></h4>");
resultArea.innerHTML = content;
esultArea.style.display = "block";
}
@Karlina-Bytes
Karlina-Bytes / binaryToDecimal.js
Last active August 29, 2015 14:07
A JavaScript function for converting a number from binary to decimal.
/*********************************************************
* Converts a positive integer from binary to decimal.
* @param {Number} binaryNumber (e.g. 1101)
* @return {Number} decimalNumber (e.g. 13)
********************************************************/
function binaryToDecimal( binaryNumber ) {
// decimalNumber represents a summation of digit values.
var decimalNumber = 0;
@Karlina-Bytes
Karlina-Bytes / decimalToBinary.js
Last active August 29, 2015 14:07
A JavaScript function for converting a number from decimal to binary.
/*********************************************************
* Converts a positive integer from decimal to binary.
* @param {Number} decimalNumber (e.g. 5)
* @return {Number} binaryNumber (e.g. 101)
********************************************************/
function decimalToBinary( decimalNumber ) {
// binaryNumber represents a summation of digit values.
var binaryNumber = 0;
@Karlina-Bytes
Karlina-Bytes / referenceJS.html
Created October 17, 2014 01:00
The line you need to include a JavaScript reference in your HTML file.
<!-- Reference a JavaScript file in the same directory. -->
<script src="functions.js"></script>
@Karlina-Bytes
Karlina-Bytes / baseConverter.html
Last active August 29, 2015 14:08
A user interface for a numerical base converter.
<!--******************************************************
* BaseConvert.html
* Created by Karlina Beringer
* Updated October 17, 2014
* Converts between multiple numerical bases,
* namely bases two through sixteen.
******************************************************
-->
<!DOCTYPE HTML>
<html>