Skip to content

Instantly share code, notes, and snippets.

@voghDev
voghDev / resize.sh
Created January 31, 2022 11:24
Really simple shell script (almost just an alias) to resize a PNG image
#!/bin/bash
if [ -z $1 ]
then
echo "Usage: ./resize.sh input.png"
else
convert $1 -resize 40% resize-output.png
display resize-output.png
fi
@voghDev
voghDev / collage3.sh
Created January 31, 2022 11:09
Simple script to create a quick horizontal collage appending three images
#!/bin/bash
if [ -z $1 ] || [ -z $3 ]
then
echo "Usage: ./collage3.sh image1.png image2.png image3.png"
else
convert $1 -resize 40% resize1.png
convert $2 -resize 40% resize2.png
convert $3 -resize 40% resize3.png
convert resize1.png resize2.png resize3.png +append collage.png
@voghDev
voghDev / .bashrc
Created January 21, 2021 09:31
Delete all branches except master
git branch | grep -v "master" | xargs git branch -D
alias clearbranches='git branch | grep -v "master" | xargs git branch -D'
@voghDev
voghDev / .bashrc
Created November 18, 2020 14:32
Fix Microphone volume increas in Ubuntu 18.04 (AGC - Automatic Mic Gain)
# Dell XPS 13
while sleep 0.1; do pacmd set-source-volume alsa_input.pci-0000_00_1f.3.analog-stereo 16000; done
# HP Pavilion Laptop (jordihurtado)
while sleep 0.1; do pacmd set-source-volume alsa_input.pci-0000_00_1b.0.analog-stereo 18000; done
@voghDev
voghDev / build.gradle
Created May 21, 2019 10:25
createTestResources method to configure MockMaker for Android Kotlin projects. Compatible with Gradle 5+
task createTestResources {
description = "Allows Mocking non-final classes and data classes in a Kotlin project"
doLast {
def mockMakerFile = new File("$projectDir/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker")
if (System.env.MOCK_MAKER != null) {
logger.info("Using MockMaker ${System.env.MOCK_MAKER}")
mockMakerFile.parentFile.mkdirs()
mockMakerFile.createNewFile()
mockMakerFile.write(System.env.MOCK_MAKER)
} else {
@voghDev
voghDev / GetStringWithParams.java
Created June 27, 2018 07:56
Workaround to pass any second parameter to getString(int resId, String... params) method
when(mockContext.getString(eq(R.string.string_with_param), any(String.class))).thenReturn("Return value");
@voghDev
voghDev / ExtractZipService.kt
Created May 30, 2018 10:04
Android Service that extracts a Zip File into a folder specified on extras
/*
* Copyright (C) 2018 Olmo Gallegos Hernández.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@voghDev
voghDev / SubsamplingPdfPagerAdapter.java
Last active May 28, 2018 11:40
Java version of the Kotlin SubsamplingPdfPagerAdapter. Requires version 1.0.4 of PdfViewPager
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.pdf.PdfRenderer;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import es.voghdev.pdfviewpager.library.R;
@SuppressWarnings("NewApi")
@voghDev
voghDev / SubsamplingPdfPagerAdapter.kt
Last active December 19, 2018 06:47
[Deprecated - see the newer version] PDFPagerAdapter subclass that allows the user to zoom in and out with more image quality. Conversion to Kotlin was very quick and code is not optimal. Suitable for old versions of the library
import android.app.Activity
import android.content.Context
import android.graphics.Bitmap
import android.graphics.pdf.PdfRenderer
import android.support.v4.view.ViewPager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.davemorrissey.labs.subscaleview.ImageSource
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
@voghDev
voghDev / ZoomOutPageTransformer.kt
Created March 14, 2018 13:20
Kotlin port of the original ZoomOutPageTransformer class, found in Android SDK documentation
/*
* Copyright (C) 2018 Olmo Gallegos Hernández.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software