Skip to content

Instantly share code, notes, and snippets.

Jarrod Roberson jarrodhroberson

Block or report user

Report or block jarrodhroberson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jarrodhroberson
jarrodhroberson / tictactoe.py
Created Jul 25, 2019
Python 3 TicTacToe Game for Console
View tictactoe.py
# Import needed modules
import os
import time
import re
# Regular Expression to validate that the input is in the expected format!
inputPattern = re.compile('^\d{1},\d{1}$')
#Initialize a 2D array to represent the board using a SPACE to represent unclaimed cells.
board = [[' ' for x in range(3)] for y in range(3)]
View NATURAL_ORDER.java
public static final Ordering<SubCategory> NATURAL_ORDER;
static
{
NATURAL_ORDER = new Ordering<SubCategory>() {
@Override
public int compare(@Nullable final SubCategory left, @Nullable final SubCategory right)
{
return ComparisonChain.start()
.compare(checkNotNull(left).categoryId, checkNotNull(right).categoryId)
View .bash_aliases
alias ll='ls -lha --color=always'
alias subl='subl --touch --cygstart --'
View String.prototype.format.js
String.prototype.format = function() {
var self = this,
formats = self.match(/{(:?\d*)}/g), // an array of formats `{}` found in the string
counter = 0, // A counter to keep track of what index to replace with
args = arguments; // Dereferencing arguments for use in the nested code blocks
if (formats) {
formats.forEach(function(format) { // We loop through each format expression in the array
var namedMatch = format.match(/{:(\d+)}/), // Checking if the format is a named replacement (i.e. {:1})
reg;
View StreamVsDecorator.java
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import javafx.util.Pair;
import javax.annotation.Nonnull;
import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import static com.google.common.collect.Iterables.*;
View Oracle Drop If Exists.md

From Oracle: If Table Exists:

The best and most efficient way is to catch the "table not found" exception: this avoids the overhead of checking if the table exists twice; and doesn't suffer from the problem that if the DROP fails for some other reason (that might be important) the exception is still raised to the caller:

BEGIN
   EXECUTE IMMEDIATE 'DROP TABLE mytable';
EXCEPTION
   WHEN OTHERS THEN
      IF SQLCODE != -942 THEN
         RAISE;
@jarrodhroberson
jarrodhroberson / IsEmpty.java
Last active Sep 3, 2019
Custom IsEmpty Hamcrest Matcher
View IsEmpty.java
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import javax.annotation.Nonnull;
import java.lang.reflect.InvocationTargetException;
/** Matches any class that has an <code>isEmpty()</code> method
* that returns a <code>boolean</code>
@jarrodhroberson
jarrodhroberson / UUID SQL.md
Last active Sep 5, 2017
converting RAW UUID types to Strings via SQL
View UUID SQL.md
Database Storage Type How to convert
Oracle RAW(16) REGEXP_REPLACE(binary-guid, '(.{8})(.{4})(.{4})(.{4})(.\*)', '\1-\2-\3-\4-\5')()
SQL Server UNIQUEIDENTIFIER CONVERT(CHAR(36), binary-guid)
MySQL BINARY(16) CONCAT_WS('-',
SUBSTR(HEX(binary-guid), 1, 8),
SUBSTR(HEX(binary-guid), 9, 4),
SUBSTR(HEX(binary-guid), 13, 4),
SUBSTR(HEX(binary-guid), 17, 4),
SUBSTR(HEX(binary-guid), 21))
View CloseAllResourcesWhenYouAreDonePreJava7.java
import java.sql.*;
public class CloseAllResourcesWhenYouAreDonePreJava7
{
public static void main(final String[] args)
{
try
{
final Connection cn = DriverManager.getConnection("jdbc:mysql://localhost/mydb", "root", "");
try
@jarrodhroberson
jarrodhroberson / autocomments.js
Last active Sep 6, 2018
stackoverflow auto-comments
View autocomments.js
callback(
[
{
"description": "[Only ask a single question per question, click this text to find out why.](https://meta.stackoverflow.com/questions/275908/more-than-one-question-per-post)",
"name": "[Q] Single Question Only"
},
{
"description": "[Never post pictures of text when you can post the actual text. Be sure that it is properly formatted and readable.](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question)",
"name": "[Q] No Pictures of Text"
},
You can’t perform that action at this time.