Skip to content

Instantly share code, notes, and snippets.

View mediavrog's full-sized avatar

Maik B mediavrog

  • @shackersNFT
  • Germany / Japan
View GitHub Profile
@mediavrog
mediavrog / gist:5625602
Last active March 20, 2024 16:59
Filter out Intents you don"t want to show from a IntentChooser dialog. For example your own app, competing apps or just apps you have a share integration by SDK already :) Based on http://stackoverflow.com/questions/5734678/custom-filtering-of-intent-chooser-based-on-installed-android-package-name/8550043#8550043
// Usage:
// blacklist
String[] blacklist = new String[]{"com.any.package", "net.other.package"};
// your share intent
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "some text");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "a subject");
// ... anything else you want to add
// invoke custom chooser
[detekt-rules build.gradle]
apply plugin: 'kotlin'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}"
implementation "io.gitlab.arturbosch.detekt:detekt-api:${versions.detekt}"
implementation "io.gitlab.arturbosch.detekt:detekt-cli:${versions.detekt}"
testImplementation "io.gitlab.arturbosch.detekt:detekt-test:${versions.detekt}"
testImplementation "junit:junit:${versions.jUnit}"
@mediavrog
mediavrog / gist:49c4f809dffea4e00738a7f5e3bbfa59
Last active April 14, 2023 08:56
CORS in Google Cloud Functions for Firebase
const cors = require('cors')({origin: true});
exports.sample = functions.https.onRequest((req, res) => {
cors(req, res, () => {
res.send('Passed.');
});
});
#!/usr/bin/env bash
# Simulate push locally. Configure the proper `deviceToken`
# to receive a push notification locally and instantaneously in debug/beta apps.
#
# - must have "adb" (Android Device Bridge) installed and executable
# - for script usage see usage() below or run the script without any parameters
# - `com.google.firebase.iid.FirebaseInstanceIdReceiver` receiver must be `exported=true` in `debug/AndroidManifest`
#<application>
# <!-- Expose this receiver to simulate push notifications via /scripts/push/trigger.sh -->
import { task, types } from "hardhat/config";
import fs from "fs";
import { MerkleTree } from "merkletreejs";
import keccak256 from "keccak256";
// ethers library
import "@nomiclabs/hardhat-ethers";
interface PresaleEntry {
address: string,
@mediavrog
mediavrog / settings.gradle
Created February 10, 2023 13:16
Include gradle modules from a directory automatically
/**
* Include all modules in a directory at once.
*/
def includeAllModules(def modulesDirName, def modulePrefix = '') {
file("$rootDir/$modulesDirName").eachDir { dir ->
if (file("$dir/build.gradle").exists() || file("$dir/build.gradle.kts").exists()) {
include "${modulePrefix}:${dir.name}"
project("${modulePrefix}:${dir.name}").projectDir = dir
}
}
@mediavrog
mediavrog / IconizedMenu.java
Last active September 17, 2022 13:17
Android Compatibility popup menu with icons (requires support library v7)
/**
* Seems like the only way to use it currently (as of 10/2018) is through reflection
* see https://resocoder.com/2018/02/02/popup-menu-with-icons-android-kotlin-tutorial-code/
**/
package com.vuzz.snapdish.ui;
import android.content.Context;
import android.support.v7.internal.view.SupportMenuInflater;
import android.support.v7.internal.view.menu.MenuBuilder;
@mediavrog
mediavrog / JapaneseCharacter.java
Last active August 26, 2020 09:03
Simple string conversion from Hiragana to Katakana and vice versa. Uses the JapaneseCharacter class from Duane J. May and combines it with a simple Utility class method to perform the actual conversion.
/**
* JapaneseCharacter contains static functions to do various tests
* on characters to determine if it is one of the various types of
* characters used in the japanese writing system.
* <p/>
* There are also a functions to translate between Katakana, Hiragana,
* and Romaji.
*
* @author Duane J. May <djmay@mayhoo.com>
* @version $Id: JapaneseCharacter.java,v 1.2 2002/04/20 18:10:24 djmay Exp $
@mediavrog
mediavrog / EditText.xml
Created June 4, 2014 02:27
Cursor not visible in EditText in Jelly Bean - this happens if you set a background for the field; to fix it, set the cursorDrawable to @null. Always use this combination when using custom backgrounds.
<EditText
android:id="@+id/my_edit_text"
...
android:background="@drawable/some_bg"
android:textCursorDrawable="@null" />
@mediavrog
mediavrog / main.js
Created October 24, 2016 10:13
Simple bootstrapping for a VueJS app with I18n, Routing and http client
// VueJS with Router, I18n and simple http client
import Vue from "vue"
import VueI18n from "vue-i18n"
import VueRouter from "vue-router"
import VueResource from 'vue-resource'
// 2 pages for the app states
import Splash from "./pages/Splash.vue"
import Main from "./pages/Main.vue"
import App from "./App.vue"
// i18n strings