Skip to content

Instantly share code, notes, and snippets.

View rkoshy's full-sized avatar

Renny Koshy rkoshy

View GitHub Profile
@rkoshy
rkoshy / reset_vti.sh
Last active June 12, 2022 21:50
Script to reset VyOS VTI interfaces that are stuck in "Administrative Down".
#!/bin/bash
RUN=/opt/vyatta/bin/vyatta-op-cmd-wrapper
DOWN=`$RUN sh interfaces |grep "A/D"|awk '{print $1}'`
echo Interfaces that need resetting: $DOWN
for TUN in $DOWN
do
PEER=`$RUN sh interfaces vti $TUN |grep peer|sed -e"s/.* peer \([0-9\.]*\)/\1/"`
logger -t "reset_vti.sh" "Resetting $TUN with peer IP $PEER"
$RUN reset vpn ipsec-peer $PEER
done
@rkoshy
rkoshy / gist:db25460c82626da240a64540287e6ed8
Created March 8, 2019 18:57 — forked from krisnod/gist:56ff894f400cce7c742fb11fb2fde9cf
RancherOS on Hetzner using software RAID (RAID 1)
Install:
----------
* Activate Hetzner Rescue System (Debian)
* Connect to Hetzner Rescue System using SSH and live boot RancherOS
(thanks goes to William Fleurant for showing how this can be done: https://github.com/wfleurant/boot-rancheros-hetzner/)
* apt-get update
* apt-get install kexec-tools aria2
@rkoshy
rkoshy / gist:e4545e379be13b1382a68ff54a5cd282
Created March 11, 2019 03:20
Rebuilding software RAID without mdadm.conf
**
SOURCE: https://www.tekovic.com/rebuilding-software-raid-without-mdadmconf
by Sasa Tekovic on 1. September 2015 - 19:55
**
Austing PowersRebuilding software RAID array is very easy when you have your mdadm.conf file at hand, but when you find yourself in a situation without backup of that little config file, e.g. after reinstalling the system or when your migrate disks to the new server, it can be a bit daunting.
Recently I had to reassemble two software RAID1 arrays one small Debian server after OS reinstall. So, there were four hard drives in total and to avoid mix-up and data loss, I had to find out which disk belonged which RAID array. Examining each drive with mdamd provided me with the necessary information.
root@localhost:~# mdadm --examine /dev/sdd1
package org.ioe.tprsa.audio.preProcessings;
/**
* @author Ganesh Tiwari
* @reference 'A New Silence Removal and Endpoint Detection Algorithm
* for Speech and Speaker Recognition Applications' by IIT, Khragpur
*/
public class EndPointDetection {
private float[] originalSignal; //input
private float[] silenceRemovedSignal;//output
private int samplingRate;
@rkoshy
rkoshy / gist:0b8c42b2f9f8a5ce21178fc61aabc378
Last active July 8, 2022 09:38
Get a list of signed jar referenced by a maven project (pom.xml)

From SO link: https://stackoverflow.com/a/54111506 (Rostislav Matl)

#!/bin/bash
mvn_classpath=`mvn dependency:build-classpath -B | awk '/Dependencies classpath:/{getline; print}' | sed -e s/:/\\\\n/g`

for jar in $mvn_classpath; do 
        echo -n `jarsigner -verify $jar | grep verified | wc -l`; echo " $jar"; 
done
@rkoshy
rkoshy / gist:af8b53b8738be955e8238d78511d36f3
Created July 8, 2022 09:40
Excluding crypto artifacts during the maven "shade" creation of an uber-jar
@rkoshy
rkoshy / js-ntp.js
Last active February 3, 2023 10:24
JS for simulating NTP time-sync. Original from: https://jehiah.cz/download/NTP.js, but didn't work - so this one has several edits
/*
NTP.js https://jehiah.cz/a/ntp-for-javascript
copyright Jehiah Czebotar jehiah@gmail.com
licensed under http://unlicense.org/ please modify as needed
to use configure serverUrl to an endpoint that when queried
(with X=timestamp_in_miliseconds)
GET serverUrl + '/' + X
returns a plain-text body:
@rkoshy
rkoshy / initializers.md
Last active November 9, 2023 12:13
Initializer that can be run before a WAR is deployed or during deployment

Just copied and formatted an answer from Marek Gregor - SO link: https://stackoverflow.com/a/46580013


There are several possibilities/levels depending on what you want to do:

Implement Servlet API ServletContextListener interface in your application.

@WebListener
@rkoshy
rkoshy / AsyncInitializer.md
Created November 9, 2023 12:16
Enable Async JAX-RS on Thorntail or Wildfly web-apps

I spent a lot of time trying to figure out how to setup Thorntail/Wildfly JAX-RS apps to allow async operations. Most configuration examples created one problem or another. I finally came across the idea that you could simply activate it by registering a ServletContextListener and changing the setting on the fly during startup.

package com.platform28.service.asyncmessaging.restapi;

import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
@rkoshy
rkoshy / airflow-gcp-creds-in-aws-sm.md
Created January 14, 2024 13:27
Setting up Airflow with GCP (Google Cloud) Credentials stored in AWS Secrets Manager

Storing Google Cloud Platform (GCP) Credentials in AWS Secrets Manager for Apache Airflow to connect to BigQuery

This took me a while to figure out by looking at the code & docs. Most Google searches were directing me to useless articles (usually about storing the creds in GCP Secrets Manager)

  1. Create a service account (or other account)
  2. Create a new key and download the JSON file
  3. Open the file & copy the entire JSON into the clipboard
  4. Create an AWS Secret (name it appropriately, let's say airflow/connection/mydag/gcp
    • Set the key to extra
    • Set the value to the contents to: