Skip to content

Instantly share code, notes, and snippets.

View tunjos's full-sized avatar

Tunji Olu-Taiwo tunjos

View GitHub Profile
@apoo
apoo / gist:2279196
Created April 1, 2012 22:40
Managing multiple SSH Keys for different GitHub Accounts
Create separate SSH key for your personal account and your company. Named them with different extensions in your .ssh folder. Upload them to your github account and finally create a config file for your SSH
Create a config file in ~/.ssh/
vim config:
# PERSONAL ACCOUNT Github
Host github.com-COOL
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_COOL
@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- / 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- / 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- / 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
@gitaarik
gitaarik / npmbin.sh
Created March 1, 2016 11:58
Alias to add the `node_modules/.bin/` directory to `$PATH` variable so that you can use executables from node modules.
alias npmbin='echo -e "Setting up npmbin with path:\n$(npm bin)"; export PATH=$(npm bin):$PATH'
@alphamu
alphamu / HorizontalBarView.java
Last active April 29, 2019 21:28
A View that displayers a horizontal bar like the kind that is used in a bar chart.
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.view.View;
@gitaarik
gitaarik / git_bash_prompt.sh
Last active May 17, 2019 23:29
Alters bash to make working with Git in the shell easier. Will set the current repository and branch name in the prompt and makes `g` an alias to `git`.
#!/bin/bash
_git_has_commits() {
if git rev-parse --verify HEAD > /dev/null 2>&1; then
return 0
else
return 1
fi
@swankjesse
swankjesse / RetrofitCachingExample.java
Created June 29, 2013 03:03
Demonstrate HTTP caching with OkHttp and Retrofit.
/*
* Copyright (C) 2013 Square, Inc.
*
* 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
@paulredmond
paulredmond / app.js
Last active September 26, 2020 15:03
Example Vue.js mixins for time
import dateMixin from './mixins/date';
// Globally
Vue.mixin(dateMixin);