Skip to content

Instantly share code, notes, and snippets.

@jbaranski
jbaranski / nexus_upload.sh
Last active May 18, 2020
Artifact upload to nexus using curl
View nexus_upload.sh
# 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 Sep 4, 2016
Python Oracle DB connection wrapper
View oracledb.py
"""
Oracle database connection wrapper
@author: jbaranski
"""
import cx_Oracle
class OracleDB:
"""
Usage:
@jbaranski
jbaranski / multi-table-sort-angular.ts
Last active Jul 12, 2020
Multi table angular sort
View multi-table-sort-angular.ts
// 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 Feb 11, 2020 — forked from tpae/Trie.js
Trie.js - super simple JavaScript implementation
View Trie.js
/* 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 Aug 1, 2020
Add User and Password to Existing H2 Database
View AddH2UserPass.md

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 Aug 1, 2020
Download a Single Dependency with Maven
View SingleJarDownload.md
@jbaranski
jbaranski / DisableCSRFOAuth2SpringBoot.md
Created Aug 1, 2020
Disable CSRF while using OAuth 2 in Spring Boot
View DisableCSRFOAuth2SpringBoot.md

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 Aug 1, 2020
Liquibase Composite Primary Key
View LiquibaseCompositePrimaryKey.md

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>
      </column>
@jbaranski
jbaranski / CentOS.md
Last active Sep 19, 2020
New CentOS 8 Server
View CentOS.md

This post is an evolving draft...

Initial setup (less verbose version of this article)

# Run updates
yum update
yum install nano
# Change root password
passwd root
@jbaranski
jbaranski / SSHSpecificPrivateKey.md
Created Aug 1, 2020
SSH Use Specific Private Key
View SSHSpecificPrivateKey.md

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)>
You can’t perform that action at this time.