Skip to content

Instantly share code, notes, and snippets.

@MariusVolkhart
MariusVolkhart / ContingencyGroupApplyingPasswordListener.cs
Created October 17, 2019 14:07
Encrypting a ZIP with a Contingency Groups
using System;
using System.Text;
using JetBrains.Annotations;
using PKWARE.ArchiveAPI;
using PKWARE.Smartcrypt.MetaClient;
using PKWARE.Smartcrypt.Protocol;
using PKWARE.Smartcrypt.Unstructured.ArchiveSupport;
namespace Your.Namespace
{
@MariusVolkhart
MariusVolkhart / openpgp.txt
Created April 29, 2016 15:03
OpenKeychain Linked Identity
This Gist confirms the Linked Identity in my OpenPGP key, and links it to this GitHub account.
Token for proof:
[Verifying my OpenPGP key: openpgp4fpr:57f3c3aa7f59cf7e650cc7bf37f56b848d9f2a56]
@MariusVolkhart
MariusVolkhart / FragmentNeedingPermission.java
Created September 4, 2015 19:51
Android M Permission Sample using Support Fragment
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// ... Some magical things
if (ContextCompat.checkSelfPermission(getActivity(), READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
// We have access. Life is good.
setupContactsPicker();
} else if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), READ_CONTACTS)) {
@MariusVolkhart
MariusVolkhart / WhereClause.java
Last active June 29, 2022 23:53
A small utility to help you construct SQL query where clauses
/*
* Copyright 2014-2015 Marius Volkhart
*
* 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
@MariusVolkhart
MariusVolkhart / Alternative configuration
Created July 20, 2014 02:46
Manifest Merger bug report
...
// Manifest Information
def versionMajor = 0
def versionMinor = 2
def versionPatch = 0
android {
compileSdkVersion 20
buildToolsVersion "20"
@MariusVolkhart
MariusVolkhart / Observable
Last active October 30, 2023 20:39
Observer Pattern for Java implemented using Interfaces and Generics.This avoids having to cast or use instanceof and allows us to continue using other classes. The drawback is that we have to implement our own boilerplate methods every time.
/**
* Provides the Observable interface for the Observer Pattern.<br/>
* <br/>
* Generics explained:<br/>
* T - The type of the argument that this Observable will push to the Observers.<br/>
* <br/>
* Using this interface for the Observer pattern prevents the need for type casting and for using
* {@code instanceof} to discover types.
*/
public interface Observable<T> {