Skip to content

Instantly share code, notes, and snippets.

View pollux-'s full-sized avatar

Sree Kumar A.V pollux-

View GitHub Profile
@pollux-
pollux- / sha256 hash
Last active March 26, 2024 20:50
Generating SHA256 hash of a public key from remote server certificate
Creating certificate from remote URL and writing to file (mycertfile.pem)
openssl s_client -showcerts -connect gist.github.com:443 </dev/null 2>/dev/null|openssl x509 -outform PEM >mycertfile.pem
Generating SHA256 hash of public key from a certificate (mycertfile.pem)
openssl x509 -in mycertfile.pem -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64
@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- / 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
@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: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)
import android.content.Context;
import android.support.annotation.NonNull;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.stream.StreamModelLoader;
@pollux-
pollux- / getdeviceart.sh
Created September 3, 2018 09:24 — forked from PaulKinlan/getdeviceart.sh
Screen Record for Android
#! /bin/bash
mkdir -p ./backgrounds
function get_google_device_art {
local device=$1
# Get the Google Device backgrounds
curl "https://developer.android.com/distribute/marketing-tools/device-art-resources/$1/port_back.png" > "./backgrounds/$1_port_back.png"
curl "https://developer.android.com/distribute/marketing-tools/device-art-resources/$1/port_fore.png" > "./backgrounds/$1_port_fore.png"
Dave Thomas: All programming is maintenance programming, because you are rarely writing original code.
If you look at the actual time you spend programming, you write a bit here and then you go back and make a change.
Or you go back and fix a bug. Or you rip it out altogether and replace it with something else.
But you are very quickly maintaining code even if it's a brand new project with a fresh source file.
You spend most of your time in maintenance mode. So you may as well just bite the bullet and say,
"I'm maintaining from day one."
The disciplines that apply to maintenance should apply globally.
https://sriramramani.wordpress.com/2015/05/06/custom-viewgroups/ customview
http://www.javaworld.com/article/2073649/core-java/why-extends-is-evil.html
public class DualProgressView extends View {
private int mSize;
private Paint mPaint;
private RectF mRect;
private float mIndeterminateSweep;
private float mstartAngle;
public DualProgressView(Context context) {
super(context);
init();