Skip to content

Instantly share code, notes, and snippets.

View tunjos's full-sized avatar

Tunji Olu-Taiwo tunjos

View GitHub Profile
@alphamu
alphamu / Android Privacy Policy Template
Created February 9, 2017 03:17
A template for creating your own privacy policy for Android apps. Look for "[" and "<!--" to see where you need to edit this app in order to create your own privacy olicy.
<html>
<body>
<h2>Privacy Policy</h2>
<p>[Individual or Company Name] built the [App Name] app as a [open source | free | freemium | ad-supported | commercial] app. This SERVICE is provided by [Individual or company name] [at no cost] and is intended
for use as is.</p>
<p>This page is used to inform website visitors regarding [my|our] policies with the collection, use, and
disclosure of Personal Information if anyone decided to use [my|our] Service.</p>
<p>If you choose to use [my|our] Service, then you agree to the collection and use of information in
relation with this policy. The Personal Information that [I|we] collect are used for providing and
improving the Service. [I|We] will not use or share your information with anyone except as described
@wojteklu
wojteklu / clean_code.md
Last active May 3, 2024 08:55
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@pollux-
pollux- / ConnectionSpec.java
Last active March 7, 2019 01:19
Force the connection to use only TLS v.1.2 avoiding the fallback to older version to avoid vulnerabilities
/**
* Force the connection to use only TLS v.1.2 avoiding the fallback to older version to avoid vulnerabilities
*
*/
final ConnectionSpec.Builder connectionSpec =
new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS);
connectionSpec.tlsVersions(TlsVersion.TLS_1_2).build();
@pollux-
pollux- / TLSSocketFactory.java
Created August 8, 2016 02:57
Attaching TLSSocketFactory to OkHttp
/**
* Enable TLS specific version V.1.2
* Issue Details : https://github.com/square/okhttp/issues/1934
*/
TLSSocketFactory tlsSocketFactory;
try {
tlsSocketFactory = new TLSSocketFactory();
httpBuilder.sslSocketFactory(tlsSocketFactory, tlsSocketFactory.systemDefaultTrustManager());
@pollux-
pollux- / TLSSocketFactory.java
Created August 8, 2016 02:55
Force enable TLS v.1.2
public class TLSSocketFactory extends SSLSocketFactory {
private SSLSocketFactory internalSSLSocketFactory;
public TLSSocketFactory() throws KeyManagementException, NoSuchAlgorithmException {
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[] { systemDefaultTrustManager() }, null);
internalSSLSocketFactory = sslContext.getSocketFactory();
}
@pollux-
pollux- / CertificatePinner.java
Last active March 7, 2019 01:19
CertificatePinner -
CertificatePinner certificatePinner = new CertificatePinner.Builder()
.add("api.github.com", "sha256/6wJsqVDF8K19zxfLxV5DGRneLyzso9adVdUN/exDacw=")
.build();
final OkHttpClient client = httpBuilder.certificatePinner(certificatePinner).build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(END_POINT)
.addConverterFactory(GsonConverterFactory.create())
.client(client)
@pollux-
pollux- / publickey
Last active March 7, 2019 01:19
Extract the public key from a certificate
openssl s_client -connect api.github.com:443 | openssl x509 -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64
@alphamu
alphamu / KeyStoreHelper.java
Last active December 28, 2023 18:22
Using Android KeyStore to generate a password. The code create a public/private key pair and uses the base64 encoded form of the certificate to as the password. The code modified the KeystoreHelper class from AOSP demo projects.
/*
* Copyright 2013 The Android Open Source Project
*
* 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