Skip to content

Instantly share code, notes, and snippets.

View macloo's full-sized avatar
💭
Teaching some Python

Mindy McAdams macloo

💭
Teaching some Python
View GitHub Profile
@macloo
macloo / main.css
Last active January 6, 2020 19:56
CSS file for shoutbox project
html {
font-size: 100%;
box-sizing: border-box;
}
* {
box-sizing: inherit;
}
body {
margin: 0;
background: #000;
@macloo
macloo / radio-test.html
Created December 16, 2015 16:53
Radio buttons that are not visible as radio buttons (Bootstrap)
<div class="row">
<div class="col-xs-12 text-center">
<h2>Select version:</h2>
<div class="btn-group" data-toggle="buttons">
<label id="esv" class="btn btn-primary active">
<input type="radio" autocomplete="off">ESV
</label>
<label id="kjv" class="btn btn-primary">
<input type="radio" autocomplete="off">KJV
</label>
@macloo
macloo / date_string.js
Last active December 17, 2015 02:29
JavaScript for date string
// produce a data string in this format: 2015-12-17 01:31:39
function getDate() {
var date = new Date();
timestamp = date.getUTCFullYear() + '-' +
('00' + (date.getUTCMonth() + 1)).slice(-2) + '-' +
('00' + date.getUTCDate()).slice(-2) + ' ' +
('00' + date.getUTCHours()).slice(-2) + ':' +
('00' + date.getUTCMinutes()).slice(-2) + ':' +
('00' + date.getUTCSeconds()).slice(-2);
import sys
scores = {"A": 1, "C": 3, "B": 3, "E": 1, "D": 2, "G": 2,
"F": 4, "I": 1, "H": 4, "K": 5, "J": 8, "M": 3,
"L": 1, "O": 1, "N": 1, "Q": 10, "P": 3, "S": 1,
"R": 1, "U": 1, "T": 1, "W": 4, "V": 4, "Y": 4,
"X": 8, "Z": 10}
# Get the Scrabble rack from the command line.
if len(sys.argv) < 2:
@macloo
macloo / database.php
Last active January 24, 2024 16:27
Template for a generic PHP connection to a MySQL database
<?php
// allow error reporting
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>
<?php
// put your own values after the equals signs
$server = "localhost";
@macloo
macloo / read_db.php
Last active July 12, 2017 17:05
Example of PHP used (with no JavaScript) to query (read) a database and then write results within HTML
<?php include 'database.php'; ?>
<?php
$query = "SELECT * FROM shouts ORDER BY id DESC LIMIT 20";
$shouts = mysqli_query($conn, $query);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name=viewport content="width=device-width, initial-scale=1">
@macloo
macloo / transact.php
Last active January 26, 2016 14:31
Doing transactions in PHP for MySQL
<?php
// $conn comes from a separate database connection file
// this is a partial, nonworking file
try {
// Let's begin a transaction
mysqli_begin_transaction($conn, MYSQLI_TRANS_START_READ_ONLY);
// There can be a set of queries
// If any one fails, an exception should be thrown
@macloo
macloo / passwords.php
Created January 26, 2016 14:37
Encrypting passwords with PHP for MySQL
<?php
// this is a partial, nonworking file
$salt1 = "qm&h*";
$salt2 = "pg!@";
$first_name = "Bill";
$last_name = "Smith";
$username = "bsmith";
$password = "secret";
$token = hash('ripemd128', "$salt1$password$salt2");
@macloo
macloo / hash_test.php
Created January 27, 2016 01:04
Test of PHP hash() function without a database
<?php
$salt1 = "mj&h*";
$salt2 = "pq!@";
if ( isset($_POST['username']) && isset($_POST['password']) ) {
if ( $_POST['attempt'] == 0 ) {
$username = $_POST['username'];
@macloo
macloo / data_attr_test.html
Created January 30, 2016 03:41
Example of using the jQuery data attribute
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name=viewport content="width=device-width, initial-scale=1">
<title> Test </title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"> </script>
</head>
<body>