Skip to content

Instantly share code, notes, and snippets.

@jakebathman
jakebathman / arrayToTable.php
Created August 14, 2017 20:56
Make a quick HTML table from a PHP array
function arrayToTable(array $values, array $headers = [])
{
$options = [
'tableStyle' => 'border: 1px solid black;border-collapse: collapse;',
'thStyle' => 'border: 1px solid black;padding: 5px 7px;text-align: center;',
'tdStyle' => 'border: 1px solid black;padding: 5px 7px;text-align: center;',
];
$th = "<th style='" . $options['thStyle'] . "'>";
$td = "<td style='" . $options['tdStyle'] . "'>";
@jakebathman
jakebathman / SQL.sublime-syntax
Created August 11, 2017 20:47
Update SQL syntax parsing for Sublime Text 3
# This file is used by Sublime Text 3 to parse code using the SQL syntax.
#
# Below is unchanged from the default, except for a few modifications:
# - Adjusted regex for alias (... AS Foo) to match the alias name as keyword.other.alias-name.sql
# - Fixed regex for table/column name when the name is wraped in backticks or an asterisk (e.g. Foo.`Bar` or Foo.*)
#
%YAML 1.2
---
name: SQL
@jakebathman
jakebathman / yum.conf
Created August 10, 2017 15:58
Yum.conf default color options (CentOS 7)
# Add these lines to /etc/yum.conf if the --color=always option isn't working
# Enable color for all output
color=always
# Default color options according to yum.conf(5)
color_list_installed_older=bold
color_list_installed_newer=bold,yellow
color_list_installed_reinstall=normal
color_list_installed_extra=bold,red
@jakebathman
jakebathman / Grouping rules
Last active April 6, 2017 15:38
A method to group things, using an astronomical metaphor
General rules:
1. There is no limit to the number of objects contained in another
2. There are no smaller/larger versions of objects (i.e. no dwarf planet)
3. An object is not required to contain other objects, nor is it required to be contained by another object (i.e. a planet can exist on its own, without naming a system)
4. This metaphor does not acknowledge the existence of the multiverse.
Rules for grouping:
1. The default unit is a planet
2. Planets can belong to a system
3. Systems can belong to a star cluster
@jakebathman
jakebathman / centos_setup.sh
Created March 14, 2017 14:58
CentOS box initial setup script
#!/bin/bash
# Base box setup steps
# Do the steps below as root user
sudo su
# The steps below are based on a clean install on
# CentOS 7 (build 1608)
# http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1608.raw.tar.gz
@jakebathman
jakebathman / create_new_user.sh
Created March 13, 2017 19:21
Create a new user on CentOS 7 and prep for SSH
#!/bin/bash
# The new user's username (prompt for input)
# Will be stored in variable newUserName
echo -e "\e[92mWhat username should be created? Please Enter:\e[37m"
read -p "Enter new username (no spaces): " newUserName;
echo -e "\n\e[92mNew user will be called: ${newUserName}\e[37m\n"
# Create new user
echo -e "\e[92mCreating the new user as ${newUserName}\e[37m"
@jakebathman
jakebathman / .bashrc
Last active October 17, 2017 18:35
Useful bash aliases or commands
# Parse the ifconfig return for IPs (IPv4 and IPv6) and display them nicely according to adapter
# Yes, it's overkill.
# Yes, it murders regular expressions for no reason.
# Yes, it's not necessary to use this.
# This has been tested on CentOS 6/7, and relies on grep's Perl regex matching
alias myip='ifconfig | grep -o --color=always -P "(^([A-Za-z0-9]+)\:?)|(inet|inet6)\s*(?:addr:?)?\s*((\d{1,3}\.){3}\d{1,3}|((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-
@jakebathman
jakebathman / helper.js
Last active March 1, 2017 14:26
Data.Medicare.Gov helper script
// ==UserScript==
// @name Helper for data.medicare.gov
// @namespace http://tampermonkey.net/
// @version 0.2.1
// @description Ctrl+click copy and more
// @author Jake Bathman
// @downloadURL https://gist.githubusercontent.com/jakebathman/8d2ca9a798e4f3e83baefda2ffc22b32/raw
// @include https://data.medicare.gov/Home-Health-Compare*
// @include https://data.medicare.gov/Hospital-Compare*
// @grant GM_setClipboard
@jakebathman
jakebathman / StateBoundaries.sql
Last active February 12, 2024 00:14
The approximate max/min latitude and longitude for all states and major territories
-- Create the table
CREATE TABLE IF NOT EXISTS `StateBoundaries` (
`State` varchar(10) DEFAULT NULL,
`Name` varchar(255) DEFAULT NULL,
`MinLat` varchar(50) DEFAULT NULL,
`MaxLat` varchar(50) DEFAULT NULL,
`MinLon` varchar(50) DEFAULT NULL,
`MaxLon` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@jakebathman
jakebathman / IDLE-ish Dark.tmtheme
Last active October 11, 2017 14:26
Custom dark theme for Sublime Text 3
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Jake Bathman</string>
<key>name</key>
<string>IDLE-ish Dark</string>
<key>settings</key>
<array>