Skip to content

Instantly share code, notes, and snippets.

View sualeh's full-sized avatar
⚠️
404 Not Found

Sualeh Fatehi sualeh

⚠️
404 Not Found
View GitHub Profile
@sualeh
sualeh / Issue503.java
Last active August 19, 2021 23:39
SchemaCrawler issue #503
package schemacrawler.test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import java.util.regex.Pattern;
import org.junit.jupiter.api.Test;
import schemacrawler.inclusionrule.RegularExpressionRule;
public class Issue503 {
@sualeh
sualeh / how-to-quickly-create-a-test-database.md
Created September 9, 2021 02:25
How to Quickly Create a Test Database

How to Quickly Create a Test Database

Chinook is an open source test database (schema and data) that was created as an alternative to Microsoft's Northwind database. For a while now, Luis Rocha has provided scripts to create this database with his lerocha/chinook-database project. These scripts support building Chinook for Microsoft SQL Server, Oracle, MySQL, PostgreSQL and IBM DB2. However, this project has not been updated in a few years, and the scripts are in different formats and encodings.

schemacrawler/chinook-database builds on the earlier project. The project has an automatic build using GitHub Actions, which pulls scripts from lerocha/chinook-database, cleans them up, and converts them all to UTF-8 with consistent line-endings. Then are are repacked and redistributed in various ways - as a Java jar file for use in Java p

@sualeh
sualeh / eclipse-java-google-style.xml
Created September 10, 2021 23:38
eclipse-java-google-style.xml - with minor tweaks
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="21">
<profile kind="CodeFormatterProfile" name="GoogleStyle" version="21">
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
@sualeh
sualeh / JavaRounding.java
Last active April 7, 2022 22:01
Java Rounding Demo
// See https://www.online-java.com/6uKwX2DOQ9
public class JavaRounding
{
public static void main(String []args)
{
System.out.println(0.9 - 0.1);
System.out.println(0.7 + 0.1);
}
}
@sualeh
sualeh / test_lab1_for_grading.py
Last active September 19, 2022 18:01
COMP-880 Lab 1 Grading Tests
"""Tests for lab1 module."""
import pytest
import lab1
def test_minimum_0():
"""Tests an argument of None, and ensures that no error occurs."""
data = None
assert lab1.minimum(data) is None
@sualeh
sualeh / test_lab3_for_grading.py
Created September 19, 2022 18:02
COMP-880 Lab 3 Grading Tests
"""Tests for lab module."""
import pytest
import schedule
def test_schedule_0():
"""Tests an argument of None, and ensures that no error occurs."""
sch = schedule.Schedule(None, ['Math'])
classes: list = sch.classes_for('Mon')
for day in ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']:
"""Test for lab module."""
from unittest import TestCase
from schedule import Schedule
from unittest import skip
class TestLab3ForGrading(TestCase):
"""Test for Lab 3."""
def test_schedule_happy_path(self):
@sualeh
sualeh / README.md
Created November 20, 2022 00:07
Run Custom Scripts with SchemaCrawler

Run Custom Scripts with SchemaCrawler

See docker-compose and mermaid diagrams

How To Generate mermaid diagrams

  • Save all the files from this gist into a single directory
  • Run docker-compose -f schemacrawler-sqlite-mermaid.yml
@sualeh
sualeh / plantuml.py
Created November 25, 2022 02:27
SchemaCrawler Plant UML Generation
from __future__ import print_function
import re
from schemacrawler.schema import TableRelationshipType # pylint: disable=import-error
from schemacrawler.schemacrawler import IdentifierQuotingStrategy # pylint: disable=import-error
from schemacrawler.utility import MetaDataUtility # pylint: disable=import-error
print("@startuml")
print("""
hide empty methods
!define schema(x) package x <<Rectangle>>
@sualeh
sualeh / README.md
Last active January 22, 2023 21:45
How to Document Your Cassandra Database with One Command (and Nothing to Install)

How to Document Your Cassandra Database with One Command (and Nothing to Install)

Ever wondered what the tables in your Cassandra database look like? Generate a text file of your Cassandra database with one command. You can run this on any system that has Docker installed.

For now, create a Cassandra database in a Docker container. Later you can use the same technique to conect to your own Cassandra database. Create two Docker Compose files for the Cassandra and SchemaCrawler containers. Also create one more with the CQL database creation script. You can find these files in the GitHub gist for this article.

Then open a command shell in the same folder that you created these files, and run:

docker-compose -f schemacrawler.yml -f cassandra.yml up -d