Skip to content

Instantly share code, notes, and snippets.

View johndevs's full-sized avatar
🕺

John Ahlroos johndevs

🕺
View GitHub Profile
@johndevs
johndevs / pg_db_clone.sh
Created October 22, 2023 18:26
Clone Postgres database
PGPASSWORD=[source password] pg_dump -h [DB_hostname] -U [username] -W -d [source_database] -v -Fc | PGPASSWORD=[destination password] pg_restore -h [DB_hostname] -U [username] -W -v -d [destination_database]
@johndevs
johndevs / tag.increment.sh
Created February 5, 2023 16:25
Increment semantic git version tag by one
#!/bin/bash
### Increments the part of the string
## $2: number of part: 0 – major, 1 – minor, 2 – patch
increment_version() {
local delimiter=.
local array=($(echo "$1" | tr $delimiter '\n'))
array[$2]=$((array[$2]+1))
if [ $2 -lt 2 ]; then array[2]=0; fi
@johndevs
johndevs / get-all-files.gql
Last active March 19, 2022 20:54
Github GraphQL - Get all file contents in repository
# Provide $query as a variable.
# The query is the same as you would enter into the search field e.g. "org:johndevs in:name feedreader"
query GetFilesQuery($branch: GitObjectID, $query: String!) {
search(first: 1, type: REPOSITORY, query: $query) {
edges {
node {
... on Repository {
object(expression: "master:", oid: $branch) {
... on Tree {
@johndevs
johndevs / vpn-util.sh
Created August 27, 2021 12:47
Gnome extension script for toggling OpenVPN 3 tunnel status
#!/bin/bash
#
# Provides a utility script for https://gitlab.com/XavierBerger/custom-vpn-toggler to toggle a OpenVPN 3 tunnel
#
# Steps to install:
# 1. Install OpenVPN 3 by following https://www.cactusvpn.com/tutorials/how-to-set-up-openvpn-3-linux/
# 1. Download this script and save it somewhere
# 2. Install the Gnome extension https://extensions.gnome.org/extension/4061/custom-vpn-toggler/
# 3. Set the script path to point to this script

Keybase proof

I hereby claim:

  • I am johndevs on github.
  • I am johndevs (https://keybase.io/johndevs) on keybase.
  • I have a public key ASAh6m8x22AwLjjs9v4GBDXwhHKbFPpnLF5Bs01pVkePHQo

To claim this, I am signing this object:

@johndevs
johndevs / maven-reports.groovy
Created February 19, 2018 16:01
Maven dependency report
#!/usr/bin/groovy
import groovy.xml.MarkupBuilder
def lines = System.in.newReader().readLines()
// Only get INFO lines and the module header
.grep { String line -> line.startsWith('[INFO] ') || line.contains('Building ')}
// Remove the INFO tag
.collect { String line -> (line.split(' ') - '[INFO]').join(' ') }
lines = lines
@johndevs
johndevs / h2tocsv.java
Created January 19, 2021 06:27
H2 to CSV export
///usr/bin/env jbang "$0" "$@" ; exit $?
//
// This is a JBang script. You need JBang to run this script.
//
// To learn more go to https://www.jbang.dev and install JBang.
//
// Run this script:
//
// ./h2tocsv -d <database.mv.db> -t <table> [-f <output file>] [-u db user] [-p db password]
//
@johndevs
johndevs / build.gradle
Last active April 12, 2017 15:44
Sample build.gradle template for Gradle Vaadin Plugin projects
/**
* Applies the latest version of the Vaadin plugin to the project. If a specific
* version of the plugin is wanted, append "?version=0.7" to the url.
*/
apply from: 'http://plugins.jasoft.fi/vaadin.plugin'
/**
* The vaadin extension configures different aspects of how the vaadin plugin behaves
* in the project.
*/
@johndevs
johndevs / plugin.xml
Last active December 9, 2016 07:04
Hide plugin preference page depending on if plugin is installed (why doesn't this work?)
<extension point="org.eclipse.ui.propertyPages">
<page id="com.example.ProjectPreferencesPage"
class="com.example.MyProjectPreferencePage"
category="my-category"
name="Exaple">
<hiddenWhen>
<adapt type="org.eclipse.core.runtime.Platform">
<with variable="platform">
<test property="org.eclipse.core.runtime.isBundleInstalled" args="some.other.plugin"/>
</with>