Skip to content

Instantly share code, notes, and snippets.

View pedrolopix's full-sized avatar

Pedro Lopes pedrolopix

  • CentralGest
  • Cantanhede, Portugal
View GitHub Profile
@mattmalec
mattmalec / Resample.java
Created June 14, 2022 16:12
Resample audio in Java (supporting upsampling and down sampling)
package com.mattmalec.resample;
public class Resample {
public static byte[] resample(byte[] data, int length, boolean stereo, int inFrequency, int outFrequency) {
if (inFrequency < outFrequency)
return upsample(data, length, stereo, inFrequency, outFrequency);
if (inFrequency > outFrequency)
return downsample(data, length, stereo, inFrequency, outFrequency);
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.quarkus:quarkus-smallrye-reactive-messaging-kafka:1.9.0.CR1
//DEPS io.quarkus:quarkus-smallrye-health:1.9.0.CR1
//DEPS org.testcontainers:kafka:1.15.0-rc2
//JAVAC_OPTIONS -parameters
//JAVA_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager
//JAVA_OPTIONS -Dmp.messaging.outgoing.movies-out.connector=smallrye-kafka -Dmp.messaging.outgoing.movies-out.topic=movies -Dmp.messaging.outgoing.movies-out.value.serializer=org.apache.kafka.common.serialization.StringSerializer
//JAVA_OPTIONS -Dmp.messaging.incoming.movies.connector=smallrye-kafka -Dmp.messaging.incoming.movies.value.deserializer=org.apache.kafka.common.serialization.StringDeserializer -Dmp.messaging.incoming.movies.auto.offset.reset=earliest
//JAVA_OPTIONS -Dmp.messaging.incoming.movies.failure-strategy=dead-letter-queue
//JAVA_OPTIONS -Dmp.messaging.incoming.dead-letter-topic-movies.connector=smallrye-kafka -Dmp.messaging.incoming.dead-letter-topic-movies.value.deserializer=org.apache.k
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS info.picocli:picocli:4.2.0
//DEPS org.eclipse.jgit:org.eclipse.jgit:5.8.1.202007141445-r
import org.eclipse.jgit.api.ListBranchCommand;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
@Icaruk
Icaruk / multipleGitProfiles.md
Last active May 2, 2025 03:11
How to have multiple profiles on git

Last update: 30-01-2024
Last view: 01-05-2025

Step 1

Go to your work folder, mine is located at: F:/Work/EnterpriseName/

And then create a .gitconfig-work with the following data:

@thehelvetian
thehelvetian / addRowToSpreadsheet.php
Last active October 31, 2021 20:04
Add a new row to a spreadsheet using Google Sheets API v4
<?php
/**
* This is a proof of concept. In real life you would split up the various parts and allow for different cell value
* types. Also read Leviscowles1986's comment below:
* https://gist.github.com/thehelvetian/2e94d60b796735b167dfb1c7560049ae#gistcomment-1822986
*
* @param array $ary_values An array containing the cell values
* @return bool Request status
*/
function addRowToSpreadsheet($ary_values = array()) {
@aesteve
aesteve / JDK8 OpenShift
Created February 19, 2015 16:05
Download Oracle's JDK 8 on Openshift DIY cartridge
cd $OPENSHIFT_DATA_DIR
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u31-b13/jdk-8u31-linux-x64.tar.gz
tar -zxvf jdk-8u31-linux-x64.tar.gz
rm -f jdk-8u31-linux-x64.tar.gz
# JAVA_HOME and PATH are set in startup hook according to these paths
@daichan4649
daichan4649 / ProgressDialogFragment.java
Last active August 1, 2018 20:29
AsyncTask + ProgressDialogFragment (Android)
public class ProgressDialogFragment extends DialogFragment {
public final static String TITLE = "title";
public final static String MESSAGE = "message";
public final static String MAX = "max";
public final static String CANCELABLE = "cancelable";
public static ProgressDialogFragment newInstance() {
return new ProgressDialogFragment();
}
@ficusk
ficusk / GsonRequest.java
Last active January 6, 2025 22:43
A Volley adapter for JSON requests that will be parsed into Java objects by Gson.
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
@fabriciocolombo
fabriciocolombo / gist:4279304
Created December 13, 2012 20:00
Capturing console output with Delphi
//Anonymous procedure approach by Lars Fosdal
type
TArg<T> = reference to procedure(const Arg: T);
procedure TForm1.CaptureConsoleOutput(const ACommand, AParameters: String; CallBack: TArg<PAnsiChar>);
const
CReadBuffer = 2400;
var
saSecurity: TSecurityAttributes;
hRead: THandle;
@rodionmoiseev
rodionmoiseev / gist:2484934
Created April 25, 2012 00:41
Setting up Play 2.0 in build.gradle
apply plugin: 'java'
apply plugin: 'scala'
// For those using Eclipse or IntelliJ IDEA
apply plugin: 'eclipse'
apply plugin: 'idea'
def findPlay20(){
def pathEnvName = ['PATH', 'Path'].find{ System.getenv()[it] != null }
for(path in System.getenv()[pathEnvName].split(File.pathSeparator)){
for(playExec in ['play.bat', 'play.sh', 'play']){