Skip to content

Instantly share code, notes, and snippets.

View avianey's full-sized avatar
🏕️
Living

Antoine Vianey avianey

🏕️
Living
View GitHub Profile
@avianey
avianey / PowerSet.java
Last active April 9, 2021 17:52
A blazing fast bitmask backed PowerSet java implementation that supports size range ;-)
package fr.pixelprose.count.generator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import static com.google.common.base.Preconditions.checkArgument;
import static java.lang.Math.min;
@avianey
avianey / JobIntentServiceInternal.kt
Created April 9, 2021 17:50
JobIntentService crashing with java.lang.RuntimeException: An error occurred while executing doInBackground()
package androidx.core.app
abstract class JobIntentServiceInternal: JobIntentService() {
/**
* Returns a GenericWorkItem that will fail silently to complete
* if it has been cancelled while executing inside
* the JobIntentService$CommandProcessor#doInBackground loop
* or if dequeue fails
*/
@avianey
avianey / script.sh
Created December 6, 2019 19:38
Wifi driver for XPS-15 with i7-9XXX Ubuntu 18.04
# https://askubuntu.com/questions/1156167/unable-to-get-wifi-adapter-working-clean-19-04-install-network-unclaimed
sudo apt update
sudo apt install git build-essential
git clone https://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/backport-iwlwifi.git
cd backport-iwlwifi/
make defconfig-iwlwifi-public
sed -i 's/CPTCFG_IWLMVM_VENDOR_CMDS=y/# CPTCFG_IWLMVM_VENDOR_CMDS is not set/' .config
make -j4
sudo make install
sudo modprobe iwlwifi
@avianey
avianey / BitSet.kt
Last active April 25, 2020 17:59
Kotlin extensions for java BitSet, with shift left, shit right and shift intersect
infix fun shr(n: Int) {
require(n >= 0) { "'n' must be >= 0" }
if (n == 0 || words.isEmpty()) { return }
val step = n / 64
val shift = n % 64
if (shift == 0 && step == 0) { return }
for (i in words.indices) {
words[i] = when {
i < words.size - 1 - step -> {
@avianey
avianey / DisplayLink-DellXPS15-Ubuntu18.sh
Created November 22, 2019 09:41
Make displaylink D3100 Dell docking station work with Dell XPS15 running ubuntu 18.04
@avianey
avianey / Activity.java
Last active November 19, 2019 14:35
Add Tab with custom click handler along with ViewPager Android Material component
TabLayout tabLayout = findViewById(R.id.tabs);
if (tabLayout != null) {
tabLayout.setupWithViewPager(
pager,
false // avoid listen for change of items in the adapter
);
try {
// Add custom tabs with managed click handler
Method m = tabLayout.getClass().getDeclaredMethod("createTabView", TabLayout.Tab.class);
m.setAccessible(true);
class SampleCode {
public static void main(String[] args) {
// TODO
}
}
@avianey
avianey / BusinessExceptionMapper.java
Last active June 18, 2019 09:19
Jersey custom parameter, annotation and exception mapping
@Provider
public class BusinessExceptionMapper implements ExceptionMapper<BusinessException> {
private static final Logger log = Logger.getLogger(TestEndpoint.class.getName());
private static final ResourceBundle resource =
ResourceBundle.getBundle("com.blogspot.avianey");
@Override
public Response toResponse(BusinessException e) {
java -jar apktool.jar d 321.apk
java -jar apktool.jar b 321 -o 323.apk
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ./your.keystore 323.apk alias
[android-sdk]/build-tools/27.0.2/zipalign -v 4 323.apk 323-aligned.apk
@avianey
avianey / LibGDXCardDeck.java
Last active October 3, 2017 13:55
Generates LibGDX BitmapFont and TextureAtlas at build time with Gradle
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;