Skip to content

Instantly share code, notes, and snippets.

@jbaranski
jbaranski / nexus_upload.sh
Last active November 9, 2022 09:36
Artifact upload to nexus using curl
# nexus 2.x
# Assuming you run this command against the directory the jar sits in
#
# r - repository
# hasPom - whether you are supplying the pom or you want one generated. If generated g, a, v, p, and c are not needed
# e - extension
# g - group id
# a - artifact id
# v - version
# p - packaging
@jbaranski
jbaranski / oracledb.py
Created September 4, 2016 20:01
Python Oracle DB connection wrapper
"""
Oracle database connection wrapper
@author: jbaranski
"""
import cx_Oracle
class OracleDB:
"""
Usage:
@jbaranski
jbaranski / multi-table-sort-angular.ts
Last active July 12, 2020 02:26
Multi table angular sort
// assume you have a member on the component like dataSource1: MatTableDataSource<any>; and dataSource2: MatTableDataSource<any>; that
// are the datasources for the two tables
@ViewChildren(MatSort) set matSort(matSortList: QueryList<MatSort>) {
const ref = this;
matSortList.forEach((matSort: any, index: number) => {
const dataSource = ref['dataSource' + (index + 1)];
// https://material.angular.io/components/table/api
// to see about sortingDataAccessor
dataSource.sortingDataAccessor = (item: any, property: string) => {
if (cond1) {
@jbaranski
jbaranski / Trie.js
Last active February 11, 2020 03:39 — forked from tpae/Trie.js
Trie.js - super simple JavaScript implementation
/* tslint:disable */
import { AutocompleteCandidate } from '../autocomplete/candidate';
// Source code token from below link
// https://gist.github.com/tpae/72e1c54471e88b689f85ad2b3940a8f0
// @MODIFIED has been added where modifications have been made
//
// Trie.js - super simple JS implementation
// https://en.wikipedia.org/wiki/Trie
@jbaranski
jbaranski / AddH2UserPass.md
Created August 1, 2020 14:40
Add User and Password to Existing H2 Database

I needed to password protect an existing H2 database. I wanted to do two things:

  • Delete existing ADMIN user, who had no user name or password:

DROP USER "";

  • Create a new user, add a password for the new user:

CREATE USER IF NOT EXISTS example PASSWORD 'example password' ADMIN;

@jbaranski
jbaranski / SingleJarDownload.md
Created August 1, 2020 14:41
Download a Single Dependency with Maven
@jbaranski
jbaranski / DisableCSRFOAuth2SpringBoot.md
Created August 1, 2020 14:42
Disable CSRF while using OAuth 2 in Spring Boot

Many examples on the internet just say to call http.csrf().disable(), but this ends up disabling all authentication (causes the AuthenticationPrincipal to always be null).

Here is how to disable CSRF protection for a REST service when using Spring Boot without disabling all authentication.

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Override
 protected void configure(HttpSecurity http) throws Exception {
@jbaranski
jbaranski / LiquibaseCompositePrimaryKey.md
Created August 1, 2020 14:43
Liquibase Composite Primary Key

Here are two examples of how to define a composite primary key for some table using Liquibase.

  • Add the composite primary key up front during table construction (preferred).
  <changeSet id="1">
    <createTable tableName="some_table">
      <column name="id_1" type="varchar_ignorecase">
        <constraints nullable="false" primaryKey="true" primaryKeyName="PK_SOME_TABLE"></constraints>
 
@jbaranski
jbaranski / SSHSpecificPrivateKey.md
Created August 1, 2020 14:44
SSH Use Specific Private Key

If you have multiple SSH keys generated for different purposes (one for GitHub, one for server administration, etc...) you can specify which private key to use via config.

In ~/.ssh/config you may have the following:

host github.com
 HostName github.com
 IdentityFile ~/.ssh/id_rsa.github
 User <your PC user name (not GitHub user name)>
@jbaranski
jbaranski / ReadYamlAndJson.md
Created August 1, 2020 14:48
Read in YAML or JSON file using Python

The following code will read in a YAML file and store it in a dictionary. The dictionary content is then printed to the console.

config.yaml

test: value
nested:
  test: nestedValue