Skip to content

Instantly share code, notes, and snippets.

@jbaranski
jbaranski / StartIDEA.md
Last active Aug 6, 2020
Intellij IDEA won't start on Windows 10 for some reason
View StartIDEA.md

For some reason Intellij IDEA won't start on Windows 10 when you double click the shortcut / exe icon.

To start...

cd "C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2\bin"

idea.bat

It will start. The terminal is also really buggy, won't register keystrokes > 90% of the time.

@jbaranski
jbaranski / Img2MBTilesWithGDAL.md
Created Aug 1, 2020
Convert an image (like JPG or TIF) to MBTiles using GDAL
View Img2MBTilesWithGDAL.md

Here are the steps needed to convert an image (like JPG or TIF) to MBTiles using GDAL:

  1. Download and install GDAL (https://gdal.org/, https://anaconda.org/conda-forge/gdal):

       conda install -c conda-forge gdal
    

    Installing GDAL is kind of a pain in the ass, especially on Windows. I'm assuming you'll be able to work out whatever issues you run into here.

  2. Download example jpg and tif map images we can work with:

@jbaranski
jbaranski / SelfHostOpenStreetMapDocker.md
Created Aug 1, 2020
How to self host an Open Street Map server (using Docker)
View SelfHostOpenStreetMapDocker.md

Here are the steps needed to run a self hosted Open Street Map server (using Docker):

  1. Download desired pbf files (like south-carolina-latest.osm.pbf) from https://download.geofabrik.de or just use the following empty planet below:

    
      <?xml version='1.0' encoding='UTF-8'?>
      <osm version="0.6" generator="osmconvert 0.8.8" timestamp="2019-10-23T20:18:02Z">
        <bounds minlat="42.4276" minlon="1.412368" maxlat="42.65717" maxlon="1.787481"/>
      </osm>
    
@jbaranski
jbaranski / GradleTaskAlias.md
Created Aug 1, 2020
Alias a task name in Gradle
View GradleTaskAlias.md

The following snippet is how to alias a task name in Gradle:

build.gradle

    // You can now run "gradle alias" and it would be equivalent to running "gradle taskToAlias"
    task alias {
        dependsOn allprojects.collect { proj ->
            proj.tasks.matching {
                it.name == 'taskToAlias'
            }
View NodeJSLocalModule.md

The following package.json snippet is how to reference a local module in your Node.js project:

package.json

{
  ...
  "dependencies": {
    "local-module": "file:./local-module",
    ...
  }
@jbaranski
jbaranski / ReadYamlAndJson.md
Created Aug 1, 2020
Read in YAML or JSON file using Python
View ReadYamlAndJson.md

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

@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)>
@jbaranski
jbaranski / CentOS.md
Created Aug 1, 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 / 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 / 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 {
You can’t perform that action at this time.