Skip to content

Instantly share code, notes, and snippets.

View renaudcerrato's full-sized avatar

Renaud Cerrato renaudcerrato

View GitHub Profile
@renaudcerrato
renaudcerrato / video2gif.sh
Last active November 28, 2015 19:50
Bash script to convert video to GIF.
#!/bin/bash
set -e
ensure_installed() {
command -v $1 >/dev/null 2>&1 || { echo -e >&2 "$1 not found.\nTry: sudo apt-get install $1.\nAborting."; exit 1; }
}
function usage() {
cat << EOF
@renaudcerrato
renaudcerrato / mount-encfs.sh
Last active November 28, 2015 19:41
GUI script for easy encfs mounting.
#!/bin/sh
set -e
ensure_installed() {
command -v $1 >/dev/null 2>&1 || { echo -e >&2 "$1 not found.\nTry: sudo apt-get install $1.\nAborting."; exit 1; }
}
CFGDIR=$HOME/.encfs
CFGFILE=.mountsettings
@renaudcerrato
renaudcerrato / ArrayRecyclerAdapter.java
Last active April 7, 2021 14:50
Lightweight ArrayAdapter for RecyclerView.
package recyclerview.adapter;
import android.support.v7.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@renaudcerrato
renaudcerrato / WrapperRecyclerAdapter.java
Last active November 7, 2017 20:19
Simple wrapper for RecyclerAdapter.
package recyclerview.adapter;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
@SuppressWarnings("unchecked")
public class WrapperRecyclerAdapter extends RecyclerView.Adapter {
private final RecyclerView.Adapter mAdapter;
@renaudcerrato
renaudcerrato / MergeRecyclerAdapter.java
Created May 15, 2015 13:01
MergeAdapter for RecyclerView
package recyclerview.adapter;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@renaudcerrato
renaudcerrato / TypeSafeSharedPreferences.java
Last active March 22, 2018 17:15
Android's type-safe SharedPreferences: won't throw a ClassCastException anymore if you're calling getLong() instead of getInt(). You can safely call any getter, as long as the value can be converted.
import android.content.SharedPreferences;
import java.util.Map;
import java.util.Set;
public class TypeSafeSharedPreferences implements SharedPreferences {
private final SharedPreferences sharedPreferences;
public Map<String, ?> getAll() {
@renaudcerrato
renaudcerrato / 402-ath_regd_optional.patch
Last active February 28, 2023 15:03
Atheros driver patch to disable EEPROM regulatory restrictions enforcing.
--- a/drivers/net/wireless/ath/regd.c
+++ b/drivers/net/wireless/ath/regd.c
@@ -341,6 +341,10 @@ ath_reg_apply_beaconing_flags(struct wip
struct ieee80211_channel *ch;
unsigned int i;
+#ifdef CONFIG_ATH_USER_REGD
+ return;
+#endif
+
@renaudcerrato
renaudcerrato / hostapd.conf
Created May 27, 2016 13:31
Sample hostapd.conf for documentation.
##### hostapd configuration file ##############################################
# Empty lines and lines starting with # are ignored
# AP netdevice name (without 'ap' postfix, i.e., wlan0 uses wlan0ap for
# management frames with the Host AP driver); wlan0 with many nl80211 drivers
interface=wlan0
# In case of atheros and nl80211 driver interfaces, an additional
# configuration parameter, bridge, may be used to notify hostapd if the
# interface is included in a bridge. This parameter is not used with Host AP
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.os.PowerManager;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import android.view.View;
import java.math.BigInteger;
final public class Base63 {
static public final char[] CHARSET = new char[]{'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','_'};
static private final BigInteger BASE = BigInteger.valueOf(CHARSET.length);
public static String encode(BigInteger integer) {
final StringBuilder sb = new StringBuilder();
BigInteger[] r = new BigInteger[]{integer, null};