Skip to content

Instantly share code, notes, and snippets.

@JonasGroeger
Last active February 15, 2021 11:51
Show Gist options
  • Select an option

  • Save JonasGroeger/a6a56ac92a136c093182310cdde3fb3f to your computer and use it in GitHub Desktop.

Select an option

Save JonasGroeger/a6a56ac92a136c093182310cdde3fb3f to your computer and use it in GitHub Desktop.

JPA

JPA <-> Oracle: Map Double auf Float in der Oracle

Da Oracle FLoat eh 126 bits präzision hat reicht das aus und das hibernate validate geht durch. https://docs.oracle.com/cd/B28359_01/server.111/b28285/sqlqr06.htm#CHDJJEEA

import org.hibernate.dialect.Oracle12cDialect;

import java.sql.Types;

public class Oracle12cDialectExtended extends Oracle12cDialect {

    @Override
    protected void registerNumericTypeMappings() {
        super.registerNumericTypeMappings();
        registerColumnType( Types.DOUBLE, "float" );
    }
}

Maven

JPA Metamodel Java 11

// pom.xml: project > build > plugins
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>${java.version}</source>
        <target>${java.version}</target>
        <annotationProcessorPaths>
            <path>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>${jaxb-api.version}</version>
            </path>
            <path>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-jpamodelgen</artifactId>
                <version>${hibernate.version}</version>
            </path>
        </annotationProcessorPaths>
    </configuration>
</plugin>    

Javascript

Conditionally add property to object

> const condition = false;
> const request = {
      ...(condition ? {id: 5} : {}),
  };
> request
{}

> const condition = true;
> const request = {
      ...(condition ? {id: 5} : {}),
  };
> request
{ id: 5 }

Powershell

# Add -NoLogo to your Powershell Shortcut to hide the Microsoft Logo when starting Powershell

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Set-PSRepository -name PSGallery -InstallationPolicy Trusted

Install-Module Pscx -Scope CurrentUser -AllowClobber
Install-Module posh-git -Scope CurrentUser -AllowClobber

Profile

notepad $profile

insert:

Import-Module PSReadline
Import-Module posh-git

$PROJECT_DIR = "C:\PROJECTS\my-project"

function Set-Project-Location() {
    Set-Location $PROJECT_DIR
}
Set-Project-Location

Other

Unpack *.msi

msiexec.exe /a package.msi /qb TARGETDIR=C:\Users\<user-id>\Downloads\package

Tampermonkey better diff colors

// ==UserScript==
// @name         Better Diff @ Bitbucket
// @namespace    https://jonasgroeger.de/
// @version      0.1
// @description  Makes the diff colors in Bitbucket legiable
// @author       Jonas Gröger
// @match        https://example.com/bitbucket/*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // Removed Line BG Color
    GM_addStyle('.diff-view.text-view .removed.line, .diff-view.text-view .removed.segment-connector, .diff-view.text-view .removed.line .comment-box, .diff-view.text-view .removed.line .bitbucket-gutter-marker { background-color: #ff56006b !important; }');

    // Removed Line eDiff BG Color
    GM_addStyle('.removed.line .ediff-change, .removed.line .ediff-delete { background-color: #ff00004a !important; }')
})();

Show direct commits on branch (not through merge)

git log --no-merges --first-parent

Create SSH-Key

ssh-keygen -t ed25519 -C "enter a comment here" -b 4096

youtube-dl

function youtube-playlist() {
  youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' -i "$@"
}

function youtube-mp3() {
  youtube-dl --extract-audio --audio-format mp3 "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment