Skip to content

Instantly share code, notes, and snippets.

View stargatex's full-sized avatar
🎯
Focusing

Lahiru J stargatex

🎯
Focusing
View GitHub Profile
@FabP93
FabP93 / SSL_Pinning.swift
Last active May 4, 2023 09:18
How to retrieve the SecTrust from the network call and compare it with your own certificate
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
guard
challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust,
let serverTrust = challenge.protectionSpace.serverTrust
else {
completionHandler(URLSession.AuthChallengeDisposition.cancelAuthenticationChallenge, nil)
return
}
guard
func createQuery(for serivce: String) -> [String: Any] {
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrService as String: service,
kSecReturnAttributes as String: true,
kSecReturnData as String: true,
kSecMatchLimit as String: kSecMatchLimitAll
]
return query
}
private boolean checkMapServices(){
if(isServicesOK()){
if(isMapsEnabled()){
return true;
}
}
return false;
}
private void buildAlertMessageNoGps() {
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/White">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
@sharifulislam52
sharifulislam52 / gridLayout.xml
Created June 19, 2018 06:36
Android : GridLayout with CardView
<GridLayout
android:columnCount="2"
android:rowCount="3"
android:alignmentMode="alignMargins"
android:columnOrderPreserved="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="14dp"
>
@joen93
joen93 / RxErrorHandlingCallAdapterFactory.java
Created April 5, 2017 12:56
RxJava2 and Retrofit 2.2.0 compatible factory, which wraps the {@link RxJava2CallAdapterFactory} and takes care of the error conversion.
/**
* RxJava2 and Retrofit 2.2.0 compatible factory,
* which wraps the {@link RxJava2CallAdapterFactory} and takes care of the error conversion.
*
* Based on: https://github.com/square/retrofit/issues/1102#issuecomment-241250796
*/
public class RxErrorHandlingCallAdapterFactory extends CallAdapter.Factory {
private final RxJava2CallAdapterFactory mOriginalCallAdapterFactory;
private RxErrorHandlingCallAdapterFactory() {
@angelolloqui
angelolloqui / SSLPinningValidator.swift
Created August 18, 2016 08:50
SSL pinning validator with implementation for the Subject public key info (SPKI), based on the one at https://github.com/datatheorem/TrustKit
//
// SSLPinningValidator.swift
//
// Created by Angel Garcia on 17/08/16.
//
import Foundation
import CommonCrypto
protocol SSLPinningValidator {
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="your.package.name" >
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
@koesie10
koesie10 / ApiModule.java
Created October 3, 2015 07:40
Retrofit 1 error handling behaviour in Retrofit 2
// Dagger 1 example
@Module(
complete = false,
library = true
)
public final class ApiModule {
@Provides
@Singleton
Retrofit provideRetrofit(Gson gson, Application app) {
return new Retrofit.Builder()
@sheharyarn
sheharyarn / CardSwingAnimations.md
Last active March 16, 2021 08:04
Swing Animations for CardViews in Android

SwingUp Animations for Android

I use these snippets to implement Google Now Card appear-animations on Android. Add these two files to your res/anim/ folder and add a swing_anim_time integer to your values:

<!-- res/values/strings.xml -->
<integer name="swing_anim_time">750</integer>